MobilityDB 1.3
Loading...
Searching...
No Matches
postgres_types.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2025, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2025, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 *
28 *****************************************************************************/
29
36#ifndef POSTGRES_TYPES_H
37#define POSTGRES_TYPES_H
38
39/* PostgreSQL */
40#include <postgres.h>
41#if MEOS
42#include "postgres_int_defs.h"
43#else
44#include <utils/date.h>
45#include <utils/timestamp.h>
46#endif /* MEOS */
47
48#if POSTGRESQL_VERSION_NUMBER < 170000
49/*
50 * Infinite intervals are represented by setting all fields to the minimum or
51 * maximum integer values.
52 */
53#define INTERVAL_NOBEGIN(i) \
54 do { \
55 (i)->time = PG_INT64_MIN; \
56 (i)->day = PG_INT32_MIN; \
57 (i)->month = PG_INT32_MIN; \
58 } while (0)
59
60#define INTERVAL_IS_NOBEGIN(i) \
61 ((i)->month == PG_INT32_MIN && (i)->day == PG_INT32_MIN && (i)->time == PG_INT64_MIN)
62
63#define INTERVAL_NOEND(i) \
64 do { \
65 (i)->time = PG_INT64_MAX; \
66 (i)->day = PG_INT32_MAX; \
67 (i)->month = PG_INT32_MAX; \
68 } while (0)
69
70#define INTERVAL_IS_NOEND(i) \
71 ((i)->month == PG_INT32_MAX && (i)->day == PG_INT32_MAX && (i)->time == PG_INT64_MAX)
72
73#define INTERVAL_NOT_FINITE(i) (INTERVAL_IS_NOBEGIN(i) || INTERVAL_IS_NOEND(i))
74#endif /* POSTGRESQL_VERSION_NUMBER < 170000 */
75
76/* Functions adapted from int.c */
77
78extern int32 int4_in(const char *str);
79extern char *int4_out(int32 val);
80
81/* Functions adapted from int8.c */
82
83extern int64 int8_in(const char *str);
84extern char *int8_out(int64 val);
85
86/* Functions adapted from float.c */
87
88extern float8 float8_in(const char *num, const char *type_name,
89 const char *orig_string);
90extern char *float8_out(double num, int maxdd);
91extern float8 pg_dsin(float8 arg1);
92extern float8 pg_dcos(float8 arg1);
93extern float8 pg_datan(float8 arg1);
94extern float8 pg_datan2(float8 arg1, float8 arg2);
95
96/* Functions adadpted from timestamp.c */
97
98
99
100extern void interval_negate(const Interval *interval, Interval *result);
101extern DateADT pg_date_in(const char *str);
102extern char *pg_date_out(DateADT d);
103extern int pg_interval_cmp(const Interval *interv1, const Interval *interv2);
104extern Interval *pg_interval_in(const char *str, int32 prec);
105extern Interval *pg_interval_justify_hours(const Interval *span);
106extern char *pg_interval_out(const Interval *interv);
107extern Timestamp pg_timestamp_in(const char *str, int32 typmod);
108extern char *pg_timestamp_out(Timestamp t);
109extern TimestampTz pg_timestamptz_in(const char *str, int32 prec);
110extern char *pg_timestamptz_out(TimestampTz t);
111
112/* Functions adapted from hashfn.h and hashfn.c */
113
115extern uint32 pg_hashint8(int64 val);
116extern uint32 pg_hashfloat8(float8 key);
118extern uint64 pg_hashint8extended(int64 val, uint64 seed);
119extern uint64 pg_hashfloat8extended(float8 key, uint64 seed);
120extern uint32 pg_hashtext(text *key);
121extern uint64 pg_hashtextextended(text *key, uint64 seed);
122
123/*****************************************************************************/
124
125#endif /* POSTGRES_TYPES_H */
double float8
Definition: c.h:581
int64 Timestamp
Definition: postgres_ext_defs.in.h:21
int64 TimestampTz
Definition: postgres_ext_defs.in.h:22
unsigned int uint32
Definition: postgres_ext_defs.in.h:16
signed int int32
Definition: postgres_ext_defs.in.h:11
int32 DateADT
Definition: postgres_ext_defs.in.h:19
unsigned long int uint64
Definition: postgres_ext_defs.in.h:17
long int int64
Definition: postgres_ext_defs.in.h:12
uint32 hash_bytes_uint32(uint32 k)
Definition: hashfn.c:610
float8 float8_in(const char *num, const char *type_name, const char *orig_string)
Definition: postgres_types.c:447
float8 pg_datan2(float8 arg1, float8 arg2)
Return the arctan of two doubles (radians)
Definition: postgres_types.c:571
char * pg_timestamp_out(Timestamp t)
Definition: postgres_types.c:1412
float8 pg_datan(float8 arg1)
Return the arctan of a double (radians)
Definition: postgres_types.c:546
uint32 pg_hashfloat8(float8 key)
Get the 32-bit hash value of an float64 value.
Definition: postgres_types.c:2544
float8 pg_dcos(float8 arg1)
Return the cosine of arg1 (radians)
Definition: postgres_types.c:505
DateADT pg_date_in(const char *str)
Definition: postgres_types.c:614
float8 pg_dsin(float8 arg1)
Return the sine of arg1 (radians)
Definition: postgres_types.c:477
int64 int8_in(const char *str)
Return an int8 from a string.
Definition: postgres_types.c:275
uint64 pg_hashfloat8extended(float8 key, uint64 seed)
Get the 64-bit hash value of a float64 value.
Definition: postgres_types.c:2568
int32 int4_in(const char *str)
Return an int4 from a string.
Definition: postgres_types.c:243
uint64 pg_hashtextextended(text *key, uint64 seed)
Get the 32-bit hash value of an text value.
Definition: postgres_types.c:2597
Interval * pg_interval_justify_hours(const Interval *span)
Add an interval to a timestamp data type.
Definition: postgres_types.c:2009
uint32 pg_hashtext(text *key)
Get the 32-bit hash value of an text value.
Definition: postgres_types.c:2585
uint64 hash_bytes_uint32_extended(uint32 k, uint64 seed)
Definition: hashfn.c:631
char * pg_interval_out(const Interval *interv)
Definition: postgres_types.c:1806
int pg_interval_cmp(const Interval *interv1, const Interval *interv2)
Definition: postgres_types.c:2223
TimestampTz pg_timestamptz_in(const char *str, int32 prec)
Definition: postgres_types.c:1351
char * int8_out(int64 val)
Return a string from an int8.
Definition: postgres_types.c:294
char * pg_date_out(DateADT d)
Definition: postgres_types.c:717
uint32 pg_hashint8(int64 val)
Get the 32-bit hash value of an int64 value.
Definition: postgres_types.c:2509
uint64 pg_hashint8extended(int64 val, uint64 seed)
Get the 64-bit hash value of an int64 value.
Definition: postgres_types.c:2530
Timestamp pg_timestamp_in(const char *str, int32 typmod)
Definition: postgres_types.c:1330
char * pg_timestamptz_out(TimestampTz t)
Definition: postgres_types.c:1429
char * int4_out(int32 val)
Return a string from an int4.
Definition: postgres_types.c:255
Interval * pg_interval_in(const char *str, int32 prec)
Definition: postgres_types.c:1659
char * float8_out(double num, int maxdd)
Definition: postgres_types.c:462
void interval_negate(const Interval *interval, Interval *result)
Negate an interval.
Definition: postgres_types.c:2064
Definition: postgres_ext_defs.in.h:27
Definition: postgres_ext_defs.in.h:34