PostgreSQL Source Code git master
btree_time.c File Reference
#include "postgres.h"
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "utils/fmgrprotos.h"
#include "utils/date.h"
#include "utils/sortsupport.h"
#include "utils/timestamp.h"
Include dependency graph for btree_time.c:

Go to the source code of this file.

Data Structures

struct  timeKEY
 

Macros

#define TimeADTGetDatumFast(X)   PointerGetDatum(&(X))
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_time_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_timetz_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_time_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_time_union)
 
 PG_FUNCTION_INFO_V1 (gbt_time_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_time_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_time_distance)
 
 PG_FUNCTION_INFO_V1 (gbt_timetz_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_time_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_time_same)
 
 PG_FUNCTION_INFO_V1 (gbt_time_sortsupport)
 
 PG_FUNCTION_INFO_V1 (gbt_timetz_sortsupport)
 
static bool gbt_timegt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_timege (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_timeeq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_timele (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_timelt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_timekey_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
static float8 gbt_time_dist (const void *a, const void *b, FmgrInfo *flinfo)
 
 PG_FUNCTION_INFO_V1 (time_dist)
 
Datum time_dist (PG_FUNCTION_ARGS)
 
Datum gbt_time_compress (PG_FUNCTION_ARGS)
 
Datum gbt_timetz_compress (PG_FUNCTION_ARGS)
 
Datum gbt_time_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_time_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_time_distance (PG_FUNCTION_ARGS)
 
Datum gbt_timetz_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_time_union (PG_FUNCTION_ARGS)
 
Datum gbt_time_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_time_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_time_same (PG_FUNCTION_ARGS)
 
static int gbt_timekey_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_time_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Macro Definition Documentation

◆ TimeADTGetDatumFast

#define TimeADTGetDatumFast (   X)    PointerGetDatum(&(X))

Definition at line 37 of file btree_time.c.

Function Documentation

◆ gbt_time_compress()

Datum gbt_time_compress ( PG_FUNCTION_ARGS  )

Definition at line 156 of file btree_time.c.

157{
158 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
159
161}
static const gbtree_ninfo tinfo
Definition: btree_time.c:124
GISTENTRY * gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361

References gbt_num_compress(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_time_consistent()

Datum gbt_time_consistent ( PG_FUNCTION_ARGS  )

Definition at line 198 of file btree_time.c.

199{
200 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
201 TimeADT query = PG_GETARG_TIMEADT(1);
203
204 /* Oid subtype = PG_GETARG_OID(3); */
205 bool *recheck = (bool *) PG_GETARG_POINTER(4);
206 timeKEY *kkk = (timeKEY *) DatumGetPointer(entry->key);
208
209 /* All cases served by this function are exact */
210 *recheck = false;
211
212 key.lower = (GBT_NUMKEY *) &kkk->lower;
213 key.upper = (GBT_NUMKEY *) &kkk->upper;
214
215 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
216 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
217}
bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
char GBT_NUMKEY
#define PG_GETARG_TIMEADT(n)
Definition: date.h:90
int64 TimeADT
Definition: date.h:25
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:272
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
#define GIST_LEAF(entry)
Definition: gist.h:171
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:317
uint16 StrategyNumber
Definition: stratnum.h:22
Datum key
Definition: gist.h:161
TimeADT lower
Definition: btree_time.c:15
TimeADT upper
Definition: btree_time.c:16

References DatumGetPointer(), gbt_num_consistent(), GIST_LEAF, GISTENTRY::key, sort-test::key, timeKEY::lower, PG_GETARG_POINTER, PG_GETARG_TIMEADT, PG_GETARG_UINT16, PG_RETURN_BOOL, tinfo, and timeKEY::upper.

◆ gbt_time_dist()

static float8 gbt_time_dist ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 111 of file btree_time.c.

112{
113 const TimeADT *aa = (const TimeADT *) a;
114 const TimeADT *bb = (const TimeADT *) b;
115 Interval *i;
116
119 TimeADTGetDatumFast(*bb)));
120 return fabs(INTERVAL_TO_SEC(i));
121}
#define TimeADTGetDatumFast(X)
Definition: btree_time.c:37
#define INTERVAL_TO_SEC(ivp)
Datum time_mi_time(PG_FUNCTION_ARGS)
Definition: date.c:2098
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:684
int b
Definition: isn.c:74
int a
Definition: isn.c:73
int i
Definition: isn.c:77
static Interval * DatumGetIntervalP(Datum X)
Definition: timestamp.h:40

References a, b, DatumGetIntervalP(), DirectFunctionCall2, i, INTERVAL_TO_SEC, time_mi_time(), and TimeADTGetDatumFast.

◆ gbt_time_distance()

Datum gbt_time_distance ( PG_FUNCTION_ARGS  )

Definition at line 220 of file btree_time.c.

221{
222 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
223 TimeADT query = PG_GETARG_TIMEADT(1);
224
225 /* Oid subtype = PG_GETARG_OID(3); */
226 timeKEY *kkk = (timeKEY *) DatumGetPointer(entry->key);
228
229 key.lower = (GBT_NUMKEY *) &kkk->lower;
230 key.upper = (GBT_NUMKEY *) &kkk->upper;
231
233 &tinfo, fcinfo->flinfo));
234}
float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query, bool is_leaf, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
#define PG_RETURN_FLOAT8(x)
Definition: fmgr.h:367

References DatumGetPointer(), gbt_num_distance(), GIST_LEAF, GISTENTRY::key, sort-test::key, timeKEY::lower, PG_GETARG_POINTER, PG_GETARG_TIMEADT, PG_RETURN_FLOAT8, tinfo, and timeKEY::upper.

◆ gbt_time_fetch()

Datum gbt_time_fetch ( PG_FUNCTION_ARGS  )

Definition at line 190 of file btree_time.c.

191{
192 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
193
195}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

References gbt_num_fetch(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_time_penalty()

Datum gbt_time_penalty ( PG_FUNCTION_ARGS  )

Definition at line 272 of file btree_time.c.

273{
274 timeKEY *origentry = (timeKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
276 float *result = (float *) PG_GETARG_POINTER(2);
277 Interval *intr;
278 double res;
279 double res2;
280
282 TimeADTGetDatumFast(newentry->upper),
283 TimeADTGetDatumFast(origentry->upper)));
284 res = INTERVAL_TO_SEC(intr);
285 res = Max(res, 0);
286
288 TimeADTGetDatumFast(origentry->lower),
289 TimeADTGetDatumFast(newentry->lower)));
290 res2 = INTERVAL_TO_SEC(intr);
291 res2 = Max(res2, 0);
292
293 res += res2;
294
295 *result = 0.0;
296
297 if (res > 0)
298 {
300 TimeADTGetDatumFast(origentry->upper),
301 TimeADTGetDatumFast(origentry->lower)));
302 *result += FLT_MIN;
303 *result += (float) (res / (res + INTERVAL_TO_SEC(intr)));
304 *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
305 }
306
307 PG_RETURN_POINTER(result);
308}
#define Max(x, y)
Definition: c.h:969

References DatumGetIntervalP(), DatumGetPointer(), DirectFunctionCall2, INTERVAL_TO_SEC, sort-test::key, timeKEY::lower, Max, PG_GETARG_POINTER, PG_RETURN_POINTER, time_mi_time(), TimeADTGetDatumFast, and timeKEY::upper.

◆ gbt_time_picksplit()

Datum gbt_time_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 311 of file btree_time.c.

312{
315 &tinfo, fcinfo->flinfo));
316}
GIST_SPLITVEC * gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References gbt_num_picksplit(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_time_same()

Datum gbt_time_same ( PG_FUNCTION_ARGS  )

Definition at line 319 of file btree_time.c.

320{
321 timeKEY *b1 = (timeKEY *) PG_GETARG_POINTER(0);
322 timeKEY *b2 = (timeKEY *) PG_GETARG_POINTER(1);
323 bool *result = (bool *) PG_GETARG_POINTER(2);
324
325 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
326 PG_RETURN_POINTER(result);
327}
bool gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)

References gbt_num_same(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_time_sortsupport()

Datum gbt_time_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 342 of file btree_time.c.

343{
345
347 ssup->ssup_extra = NULL;
348
350}
static int gbt_timekey_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_time.c:330
#define PG_RETURN_VOID()
Definition: fmgr.h:349
struct SortSupportData * SortSupport
Definition: sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition: sortsupport.h:106
void * ssup_extra
Definition: sortsupport.h:87

References SortSupportData::comparator, gbt_timekey_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_time_union()

Datum gbt_time_union ( PG_FUNCTION_ARGS  )

Definition at line 262 of file btree_time.c.

263{
265 void *out = palloc(sizeof(timeKEY));
266
267 *(int *) PG_GETARG_POINTER(1) = sizeof(timeKEY);
268 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
269}
void * gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_ninfo *tinfo, FmgrInfo *flinfo)
void * palloc(Size size)
Definition: mcxt.c:1945

References gbt_num_union(), palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, and tinfo.

◆ gbt_timeeq()

static bool gbt_timeeq ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 64 of file btree_time.c.

65{
66 const TimeADT *aa = (const TimeADT *) a;
67 const TimeADT *bb = (const TimeADT *) b;
68
72}
Datum time_eq(PG_FUNCTION_ARGS)
Definition: date.c:1745
static bool DatumGetBool(Datum X)
Definition: postgres.h:95

References a, b, DatumGetBool(), DirectFunctionCall2, time_eq(), and TimeADTGetDatumFast.

◆ gbt_timege()

static bool gbt_timege ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 53 of file btree_time.c.

54{
55 const TimeADT *aa = (const TimeADT *) a;
56 const TimeADT *bb = (const TimeADT *) b;
57
61}
Datum time_ge(PG_FUNCTION_ARGS)
Definition: date.c:1790

References a, b, DatumGetBool(), DirectFunctionCall2, time_ge(), and TimeADTGetDatumFast.

◆ gbt_timegt()

static bool gbt_timegt ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 42 of file btree_time.c.

43{
44 const TimeADT *aa = (const TimeADT *) a;
45 const TimeADT *bb = (const TimeADT *) b;
46
50}
Datum time_gt(PG_FUNCTION_ARGS)
Definition: date.c:1781

References a, b, DatumGetBool(), DirectFunctionCall2, time_gt(), and TimeADTGetDatumFast.

◆ gbt_timekey_cmp()

static int gbt_timekey_cmp ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 97 of file btree_time.c.

98{
99 timeKEY *ia = (timeKEY *) (((const Nsrt *) a)->t);
100 timeKEY *ib = (timeKEY *) (((const Nsrt *) b)->t);
101 int res;
102
104 if (res == 0)
106
107 return res;
108}
Datum time_cmp(PG_FUNCTION_ARGS)
Definition: date.c:1799
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:207

References a, b, DatumGetInt32(), DirectFunctionCall2, timeKEY::lower, time_cmp(), TimeADTGetDatumFast, and timeKEY::upper.

◆ gbt_timekey_ssup_cmp()

static int gbt_timekey_ssup_cmp ( Datum  x,
Datum  y,
SortSupport  ssup 
)
static

Definition at line 330 of file btree_time.c.

331{
332 timeKEY *arg1 = (timeKEY *) DatumGetPointer(x);
333 timeKEY *arg2 = (timeKEY *) DatumGetPointer(y);
334
335 /* for leaf items we expect lower == upper, so only compare lower */
338 TimeADTGetDatumFast(arg2->lower)));
339}
int y
Definition: isn.c:76
int x
Definition: isn.c:75

References DatumGetInt32(), DatumGetPointer(), DirectFunctionCall2, timeKEY::lower, time_cmp(), TimeADTGetDatumFast, x, and y.

Referenced by gbt_time_sortsupport().

◆ gbt_timele()

static bool gbt_timele ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 75 of file btree_time.c.

76{
77 const TimeADT *aa = (const TimeADT *) a;
78 const TimeADT *bb = (const TimeADT *) b;
79
83}
Datum time_le(PG_FUNCTION_ARGS)
Definition: date.c:1772

References a, b, DatumGetBool(), DirectFunctionCall2, time_le(), and TimeADTGetDatumFast.

◆ gbt_timelt()

static bool gbt_timelt ( const void *  a,
const void *  b,
FmgrInfo flinfo 
)
static

Definition at line 86 of file btree_time.c.

87{
88 const TimeADT *aa = (const TimeADT *) a;
89 const TimeADT *bb = (const TimeADT *) b;
90
94}
Datum time_lt(PG_FUNCTION_ARGS)
Definition: date.c:1763

References a, b, DatumGetBool(), DirectFunctionCall2, time_lt(), and TimeADTGetDatumFast.

◆ gbt_timetz_compress()

Datum gbt_timetz_compress ( PG_FUNCTION_ARGS  )

Definition at line 164 of file btree_time.c.

165{
166 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
167 GISTENTRY *retval;
168
169 if (entry->leafkey)
170 {
171 timeKEY *r = (timeKEY *) palloc(sizeof(timeKEY));
172 TimeTzADT *tz = DatumGetTimeTzADTP(entry->key);
173 TimeADT tmp;
174
175 retval = palloc(sizeof(GISTENTRY));
176
177 /* We are using the time + zone only to compress */
178 tmp = tz->time + (tz->zone * INT64CONST(1000000));
179 r->lower = r->upper = tmp;
180 gistentryinit(*retval, PointerGetDatum(r),
181 entry->rel, entry->page,
182 entry->offset, false);
183 }
184 else
185 retval = entry;
186 PG_RETURN_POINTER(retval);
187}
#define INT64CONST(x)
Definition: c.h:516
static TimeTzADT * DatumGetTimeTzADTP(Datum X)
Definition: date.h:66
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:245
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:327
OffsetNumber offset
Definition: gist.h:164
Page page
Definition: gist.h:163
Relation rel
Definition: gist.h:162
bool leafkey
Definition: gist.h:165
Definition: date.h:28
TimeADT time
Definition: date.h:29
int32 zone
Definition: date.h:30

References DatumGetTimeTzADTP(), gistentryinit, INT64CONST, GISTENTRY::key, GISTENTRY::leafkey, timeKEY::lower, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), GISTENTRY::rel, TimeTzADT::time, timeKEY::upper, and TimeTzADT::zone.

◆ gbt_timetz_consistent()

Datum gbt_timetz_consistent ( PG_FUNCTION_ARGS  )

Definition at line 237 of file btree_time.c.

238{
239 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
242
243 /* Oid subtype = PG_GETARG_OID(3); */
244 bool *recheck = (bool *) PG_GETARG_POINTER(4);
245 timeKEY *kkk = (timeKEY *) DatumGetPointer(entry->key);
246 TimeADT qqq;
248
249 /* All cases served by this function are inexact */
250 *recheck = true;
251
252 qqq = query->time + (query->zone * INT64CONST(1000000));
253
254 key.lower = (GBT_NUMKEY *) &kkk->lower;
255 key.upper = (GBT_NUMKEY *) &kkk->upper;
256
257 PG_RETURN_BOOL(gbt_num_consistent(&key, &qqq, &strategy,
258 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
259}
#define PG_GETARG_TIMETZADT_P(n)
Definition: date.h:91

References DatumGetPointer(), gbt_num_consistent(), GIST_LEAF, INT64CONST, GISTENTRY::key, sort-test::key, timeKEY::lower, PG_GETARG_POINTER, PG_GETARG_TIMETZADT_P, PG_GETARG_UINT16, PG_RETURN_BOOL, TimeTzADT::time, tinfo, timeKEY::upper, and TimeTzADT::zone.

◆ PG_FUNCTION_INFO_V1() [1/13]

PG_FUNCTION_INFO_V1 ( gbt_time_compress  )

◆ PG_FUNCTION_INFO_V1() [2/13]

PG_FUNCTION_INFO_V1 ( gbt_time_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/13]

PG_FUNCTION_INFO_V1 ( gbt_time_distance  )

◆ PG_FUNCTION_INFO_V1() [4/13]

PG_FUNCTION_INFO_V1 ( gbt_time_fetch  )

◆ PG_FUNCTION_INFO_V1() [5/13]

PG_FUNCTION_INFO_V1 ( gbt_time_penalty  )

◆ PG_FUNCTION_INFO_V1() [6/13]

PG_FUNCTION_INFO_V1 ( gbt_time_picksplit  )

◆ PG_FUNCTION_INFO_V1() [7/13]

PG_FUNCTION_INFO_V1 ( gbt_time_same  )

◆ PG_FUNCTION_INFO_V1() [8/13]

PG_FUNCTION_INFO_V1 ( gbt_time_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [9/13]

PG_FUNCTION_INFO_V1 ( gbt_time_union  )

◆ PG_FUNCTION_INFO_V1() [10/13]

PG_FUNCTION_INFO_V1 ( gbt_timetz_compress  )

◆ PG_FUNCTION_INFO_V1() [11/13]

PG_FUNCTION_INFO_V1 ( gbt_timetz_consistent  )

◆ PG_FUNCTION_INFO_V1() [12/13]

PG_FUNCTION_INFO_V1 ( gbt_timetz_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [13/13]

PG_FUNCTION_INFO_V1 ( time_dist  )

◆ time_dist()

Datum time_dist ( PG_FUNCTION_ARGS  )

Definition at line 141 of file btree_time.c.

142{
145 PG_GETARG_DATUM(1));
146
148}
Interval * abs_interval(Interval *a)
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
uintptr_t Datum
Definition: postgres.h:69
#define PG_RETURN_INTERVAL_P(x)
Definition: timestamp.h:69

References abs_interval(), DatumGetIntervalP(), DirectFunctionCall2, PG_GETARG_DATUM, PG_RETURN_INTERVAL_P, and time_mi_time().

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(TimeADT),
16,
}
@ gbt_t_time
Definition: btree_gist.h:26
static bool gbt_timeeq(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:64
static bool gbt_timele(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:75
static bool gbt_timelt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:86
static bool gbt_timegt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:42
static bool gbt_timege(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:53
static int gbt_timekey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:97
static float8 gbt_time_dist(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_time.c:111

Definition at line 124 of file btree_time.c.

Referenced by gbt_time_compress(), gbt_time_consistent(), gbt_time_distance(), gbt_time_fetch(), gbt_time_picksplit(), gbt_time_same(), gbt_time_union(), and gbt_timetz_consistent().