40 #include <catalog/pg_type.h> 41 #include <utils/rangetypes.h> 42 #if POSTGRESQL_VERSION_NUMBER < 110000 43 #include <utils/timestamp.h> 64 #define DatumGetTboxP(X) ((TBOX *) DatumGetPointer(X)) 65 #define TboxPGetDatum(X) PointerGetDatum(X) 66 #define PG_GETARG_TBOX_P(n) DatumGetTboxP(PG_GETARG_DATUM(n)) 67 #define PG_RETURN_TBOX_P(x) return TboxPGetDatum(x) 71 extern TBOX *
tbox_make(
bool hasx,
bool hast,
double xmin,
double xmax,
72 TimestampTz tmin, TimestampTz tmax);
73 extern void tbox_set(
TBOX *box,
bool hasx,
bool hast,
double xmin,
74 double xmax, TimestampTz tmin, TimestampTz tmax);
78 const Interval *duration);
88 extern Datum
tbox_in(PG_FUNCTION_ARGS);
89 extern Datum
tbox_out(PG_FUNCTION_ARGS);
129 extern Datum
tbox_xmin(PG_FUNCTION_ARGS);
130 extern Datum
tbox_xmax(PG_FUNCTION_ARGS);
131 extern Datum
tbox_tmin(PG_FUNCTION_ARGS);
132 extern Datum
tbox_tmax(PG_FUNCTION_ARGS);
185 extern Datum
tbox_cmp(PG_FUNCTION_ARGS);
186 extern Datum
tbox_lt(PG_FUNCTION_ARGS);
187 extern Datum
tbox_le(PG_FUNCTION_ARGS);
188 extern Datum
tbox_gt(PG_FUNCTION_ARGS);
189 extern Datum
tbox_ge(PG_FUNCTION_ARGS);
190 extern Datum
tbox_eq(PG_FUNCTION_ARGS);
191 extern Datum
tbox_ne(PG_FUNCTION_ARGS);
TBOX * tbox_union_internal(const TBOX *box1, const TBOX *box2)
Returns the union of the temporal boxes (internal function)
Definition: tbox.c:1204
void range_to_tbox_internal(TBOX *box, const RangeType *r)
Transform the range to a temporal box (internal function)
Definition: tbox.c:401
Structure to represent periods.
Definition: timetypes.h:52
void ensure_has_X_tbox(const TBOX *box)
Ensure that the temporal box has X values.
Definition: tbox.c:157
bool before_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box is strictly before the second one (internal function) ...
Definition: tbox.c:1104
Datum before_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box is strictly before the second one.
Definition: tbox.c:1116
Datum tbox_intersection(PG_FUNCTION_ARGS)
Returns the intersection of the temporal boxes.
Definition: tbox.c:1279
Datum tbox_to_floatrange(PG_FUNCTION_ARGS)
Cast the temporal box value as a float range value.
Definition: tbox.c:644
Datum int_timestamp_to_tbox(PG_FUNCTION_ARGS)
Transform the integer and the timestamp to a temporal box.
Definition: tbox.c:540
Datum adjacent_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the temporal boxes are adjacent.
Definition: tbox.c:992
void tbox_set(TBOX *box, bool hasx, bool hast, double xmin, double xmax, TimestampTz tmin, TimestampTz tmax)
Set the temporal box from the argument values.
Definition: tbox.c:75
TBOX * tbox_make(bool hasx, bool hast, double xmin, double xmax, TimestampTz tmin, TimestampTz tmax)
Constructs a newly allocated temporal box.
Definition: tbox.c:62
Datum tbox_gt(PG_FUNCTION_ARGS)
Returns true if the first temporal box value is greater than the second one.
Definition: tbox.c:1461
bool right_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box is strictly to the right of the second one (internal function)...
Definition: tbox.c:1056
bool tbox_eq_internal(const TBOX *box1, const TBOX *box2)
Returns true if the two temporal boxes are equal (internal function)
Definition: tbox.c:1476
Datum float_to_tbox(PG_FUNCTION_ARGS)
Transform the float to a temporal box.
Definition: tbox.c:375
Datum tbox_eq(PG_FUNCTION_ARGS)
Returns true if the two temporal boxes are equal.
Definition: tbox.c:1493
Datum float_period_to_tbox(PG_FUNCTION_ARGS)
Transform the float and the period to a temporal box.
Definition: tbox.c:580
Datum timestampset_to_tbox(PG_FUNCTION_ARGS)
Transform the period set to a temporal box.
Definition: tbox.c:472
Datum same_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the temporal boxes are equal on the common dimensions.
Definition: tbox.c:955
int16 flags
flags
Definition: tbox.h:59
bool after_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box is strictly after the second one (internal function) ...
Definition: tbox.c:1152
Datum overafter_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box does not extend before the second one.
Definition: tbox.c:1188
Datum overlaps_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the temporal boxes overlap.
Definition: tbox.c:927
Datum tbox_expand_value(PG_FUNCTION_ARGS)
Expand the value dimension of the temporal box with the double value.
Definition: tbox.c:771
bool contained_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box is contained by the second one (internal function) ...
Definition: tbox.c:889
void ensure_has_T_tbox(const TBOX *box)
Ensure that the temporal box has T values.
Definition: tbox.c:168
Datum overleft_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box does not extend to the right of the second one...
Definition: tbox.c:1044
bool overleft_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box does not extend to the right of the second one (internal funct...
Definition: tbox.c:1032
bool overright_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box does not extend to the left of the second one (internal functi...
Definition: tbox.c:1080
Datum number_to_tbox(PG_FUNCTION_ARGS)
void timestamp_to_tbox_internal(TBOX *box, TimestampTz t)
Transform the timestamp to a temporal box (internal function)
Definition: tbox.c:434
Datum tbox_lt(PG_FUNCTION_ARGS)
Returns true if the first temporal box value is less than the second one.
Definition: tbox.c:1420
Datum tbox_tmax(PG_FUNCTION_ARGS)
Returns the maximum timestamp of the temporal box value.
Definition: tbox.c:740
void timestampset_to_tbox_internal(TBOX *box, const TimestampSet *ts)
Transform the period set to a temporal box (internal function)
Definition: tbox.c:458
Datum overright_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box does not extend to the left of the second one.
Definition: tbox.c:1092
Datum tbox_xmax(PG_FUNCTION_ARGS)
Returns the maximum X value of the temporal box value.
Definition: tbox.c:714
void float_to_tbox_internal(TBOX *box, double d)
Transform the float to a temporal box (internal function)
Definition: tbox.c:363
void number_to_box(TBOX *box, Datum value, Oid basetypid)
Transform the value to a temporal box (internal function only)
Definition: tbox.c:324
void periodset_to_tbox_internal(TBOX *box, const PeriodSet *ps)
Transform the period set to a temporal box (internal function)
Definition: tbox.c:510
Datum tbox_tmin(PG_FUNCTION_ARGS)
Returns the minimum timestamp of the temporal box value.
Definition: tbox.c:727
Datum timestamp_to_tbox(PG_FUNCTION_ARGS)
Transform the timestamp to a temporal box.
Definition: tbox.c:446
bool overafter_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box does not extend before the second one (internal function) ...
Definition: tbox.c:1176
Structure to represent period sets.
Definition: timetypes.h:84
Datum tbox_le(PG_FUNCTION_ARGS)
Returns true if the first temporal box value is less than or equal to the second one.
Definition: tbox.c:1434
Datum period_to_tbox(PG_FUNCTION_ARGS)
Transform the period to a temporal box.
Definition: tbox.c:498
void ensure_same_dimensionality_tbox(const TBOX *box1, const TBOX *box2)
Ensure that the temporal boxes have the same dimensionality.
Definition: tbox.c:179
TimestampTz tmax
maximum timestamp
Definition: tbox.h:58
Datum float_timestamp_to_tbox(PG_FUNCTION_ARGS)
Transform the float and the timestamp to a temporal box.
Definition: tbox.c:553
bool overbefore_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box does not extend after the second one (internal function) ...
Definition: tbox.c:1128
void period_to_tbox_internal(TBOX *box, const Period *p)
Transform the period to a temporal box (internal function)
Definition: tbox.c:485
double xmin
minimum number value
Definition: tbox.h:55
Structure to represent temporal boxes.
Definition: tbox.h:53
Datum tbox_in(PG_FUNCTION_ARGS)
Input function for temporal boxes.
Definition: tbox.c:204
bool same_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the temporal boxes are equal on the common dimensions (internal function) ...
Definition: tbox.c:939
Datum tbox_set_precision(PG_FUNCTION_ARGS)
Set the precision of the value dimension of the temporal box to the number of decimal places...
Definition: tbox.c:812
TBOX * tbox_copy(const TBOX *box)
Returns a copy of the temporal box value.
Definition: tbox.c:111
Functions for time types based on TimestampTz, that is, TimestampSet, Period, and PeriodSet...
Structure to represent timestamp sets.
Definition: timetypes.h:73
bool adjacent_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the temporal boxes are adjacent (internal function)
Definition: tbox.c:967
TBOX * tbox_intersection_internal(const TBOX *box1, const TBOX *box2)
Returns the intersection of the temporal boxes (internal function)
Definition: tbox.c:1247
Datum tbox_expand_temporal(PG_FUNCTION_ARGS)
Expand the time dimension of the temporal box with the interval value.
Definition: tbox.c:799
Datum after_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box is strictly after the second one.
Definition: tbox.c:1164
bool contains_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box contains the second one (internal function) ...
Definition: tbox.c:861
Datum range_to_tbox(PG_FUNCTION_ARGS)
Transform the range to a temporal box.
Definition: tbox.c:414
bool overlaps_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the temporal boxes overlap (internal function)
Definition: tbox.c:911
Datum range_timestamp_to_tbox(PG_FUNCTION_ARGS)
Transform the range and the timestamp to a temporal box.
Definition: tbox.c:593
Datum tbox_constructor(PG_FUNCTION_ARGS)
Construct a temporal box value from the arguments.
Definition: tbox.c:276
void tbox_expand(TBOX *box1, const TBOX *box2)
Expand the first temporal box value with the second one.
Definition: tbox.c:122
Datum tbox_ne(PG_FUNCTION_ARGS)
Returns true if the two temporal boxes are different.
Definition: tbox.c:1505
Datum tbox_xmin(PG_FUNCTION_ARGS)
Returns the minimum X value of the temporal box value.
Definition: tbox.c:701
Datum tbox_ge(PG_FUNCTION_ARGS)
Returns true if the first temporal box value is greater than or equal to the second one...
Definition: tbox.c:1448
Datum tbox_to_period(PG_FUNCTION_ARGS)
Cast the temporal box value as a period value.
Definition: tbox.c:659
void tbox_shift_tscale(TBOX *box, const Interval *start, const Interval *duration)
Shift and/or scale the time span of the temporal box by the interval.
Definition: tbox.c:134
Datum tbox_cmp(PG_FUNCTION_ARGS)
Returns -1, 0, or 1 depending on whether the first temporal box value is less than, equal, or greater than the second one.
Definition: tbox.c:1407
int tbox_cmp_internal(const TBOX *box1, const TBOX *box2)
Returns -1, 0, or 1 depending on whether the first temporal box value is less than, equal to, or greater than the second one (internal function).
Definition: tbox.c:1360
Datum right_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box is strictly to the right of the second one.
Definition: tbox.c:1068
double xmax
maximum number value
Definition: tbox.h:56
Datum int_period_to_tbox(PG_FUNCTION_ARGS)
Transform the integer and the period to a temporal box.
Definition: tbox.c:566
Datum tbox_out(PG_FUNCTION_ARGS)
Output function for temporal boxes.
Definition: tbox.c:260
Datum overbefore_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box does not extend after the second one.
Definition: tbox.c:1140
Datum left_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box is strictly to the left of the second one. ...
Definition: tbox.c:1020
Datum contained_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box is contained by the second one.
Definition: tbox.c:899
TimestampTz tmin
minimum timestamp
Definition: tbox.h:57
Datum int_to_tbox(PG_FUNCTION_ARGS)
Transform the integer to a temporal box.
Definition: tbox.c:351
bool left_tbox_tbox_internal(const TBOX *box1, const TBOX *box2)
Returns true if the first temporal box is strictly to the left of the second one (internal function) ...
Definition: tbox.c:1008
Datum tbox_union(PG_FUNCTION_ARGS)
Returns the union of the temporal boxes.
Definition: tbox.c:1234
Datum range_period_to_tbox(PG_FUNCTION_ARGS)
Transform the range and the period to a temporal box.
Definition: tbox.c:617
Datum contains_tbox_tbox(PG_FUNCTION_ARGS)
Returns true if the first temporal box contains the second one.
Definition: tbox.c:877
Datum tbox_constructor_t(PG_FUNCTION_ARGS)
Construct a temporal box value from the timestamps.
Definition: tbox.c:306
Datum periodset_to_tbox(PG_FUNCTION_ARGS)
Transform the period set to a temporal box.
Definition: tbox.c:524
void int_to_tbox_internal(TBOX *box, int i)
Transform the integer to a temporal box (internal function)
Definition: tbox.c:339
TBOX * tbox_minus_internal(const TBOX *box1, const TBOX *box2)