PostgreSQL Source Code git master
btree_ts.c File Reference
#include "postgres.h"
#include <limits.h>
#include "btree_gist.h"
#include "btree_utils_num.h"
#include "utils/fmgrprotos.h"
#include "utils/timestamp.h"
#include "utils/float.h"
#include "utils/sortsupport.h"
Include dependency graph for btree_ts.c:

Go to the source code of this file.

Data Structures

struct  tsKEY
 

Macros

#define TimestampGetDatumFast(X)   PointerGetDatum(&(X))
 
#define penalty_check_max_float(val)
 

Functions

 PG_FUNCTION_INFO_V1 (gbt_ts_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_tstz_compress)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_fetch)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_union)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_picksplit)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_distance)
 
 PG_FUNCTION_INFO_V1 (gbt_tstz_consistent)
 
 PG_FUNCTION_INFO_V1 (gbt_tstz_distance)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_penalty)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_same)
 
 PG_FUNCTION_INFO_V1 (gbt_ts_sortsupport)
 
static bool gbt_tsgt (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_tsge (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_tseq (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_tsle (const void *a, const void *b, FmgrInfo *flinfo)
 
static bool gbt_tslt (const void *a, const void *b, FmgrInfo *flinfo)
 
static int gbt_tskey_cmp (const void *a, const void *b, FmgrInfo *flinfo)
 
static float8 gbt_ts_dist (const void *a, const void *b, FmgrInfo *flinfo)
 
 PG_FUNCTION_INFO_V1 (ts_dist)
 
Datum ts_dist (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (tstz_dist)
 
Datum tstz_dist (PG_FUNCTION_ARGS)
 
static Timestamp tstz_to_ts_gmt (TimestampTz ts)
 
Datum gbt_ts_compress (PG_FUNCTION_ARGS)
 
Datum gbt_tstz_compress (PG_FUNCTION_ARGS)
 
Datum gbt_ts_fetch (PG_FUNCTION_ARGS)
 
Datum gbt_ts_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_ts_distance (PG_FUNCTION_ARGS)
 
Datum gbt_tstz_consistent (PG_FUNCTION_ARGS)
 
Datum gbt_tstz_distance (PG_FUNCTION_ARGS)
 
Datum gbt_ts_union (PG_FUNCTION_ARGS)
 
Datum gbt_ts_penalty (PG_FUNCTION_ARGS)
 
Datum gbt_ts_picksplit (PG_FUNCTION_ARGS)
 
Datum gbt_ts_same (PG_FUNCTION_ARGS)
 
static int gbt_ts_ssup_cmp (Datum x, Datum y, SortSupport ssup)
 
Datum gbt_ts_sortsupport (PG_FUNCTION_ARGS)
 

Variables

static const gbtree_ninfo tinfo
 

Macro Definition Documentation

◆ penalty_check_max_float

#define penalty_check_max_float (   val)
Value:
do { \
if ( val > FLT_MAX ) \
val = FLT_MAX; \
if ( val < -FLT_MAX ) \
val = -FLT_MAX; \
} while (0)
long val
Definition: informix.c:689

Definition at line 341 of file btree_ts.c.

◆ TimestampGetDatumFast

#define TimestampGetDatumFast (   X)    PointerGetDatum(&(X))

Definition at line 39 of file btree_ts.c.

Function Documentation

◆ gbt_ts_compress()

Datum gbt_ts_compress ( PG_FUNCTION_ARGS  )

Definition at line 206 of file btree_ts.c.

207{
208 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
209
211}
static const gbtree_ninfo tinfo
Definition: btree_ts.c:130
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_ts_consistent()

Datum gbt_ts_consistent ( PG_FUNCTION_ARGS  )

Definition at line 248 of file btree_ts.c.

249{
250 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
253
254 /* Oid subtype = PG_GETARG_OID(3); */
255 bool *recheck = (bool *) PG_GETARG_POINTER(4);
256 tsKEY *kkk = (tsKEY *) DatumGetPointer(entry->key);
258
259 /* All cases served by this function are exact */
260 *recheck = false;
261
262 key.lower = (GBT_NUMKEY *) &kkk->lower;
263 key.upper = (GBT_NUMKEY *) &kkk->upper;
264
265 PG_RETURN_BOOL(gbt_num_consistent(&key, &query, &strategy,
266 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
267}
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
int64 Timestamp
Definition: timestamp.h:38
#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
Definition: btree_ts.c:16
Timestamp lower
Definition: btree_ts.c:17
Timestamp upper
Definition: btree_ts.c:18
#define PG_GETARG_TIMESTAMP(n)
Definition: timestamp.h:63

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

◆ gbt_ts_dist()

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

Definition at line 115 of file btree_ts.c.

116{
117 const Timestamp *aa = (const Timestamp *) a;
118 const Timestamp *bb = (const Timestamp *) b;
119 Interval *i;
120
122 return get_float8_infinity();
123
127 return fabs(INTERVAL_TO_SEC(i));
128}
Datum timestamp_mi(PG_FUNCTION_ARGS)
Definition: timestamp.c:2845
#define TimestampGetDatumFast(X)
Definition: btree_ts.c:39
#define INTERVAL_TO_SEC(ivp)
#define TIMESTAMP_NOT_FINITE(j)
Definition: timestamp.h:169
static float8 get_float8_infinity(void)
Definition: float.h:94
#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, get_float8_infinity(), i, INTERVAL_TO_SEC, timestamp_mi(), TIMESTAMP_NOT_FINITE, and TimestampGetDatumFast.

◆ gbt_ts_distance()

Datum gbt_ts_distance ( PG_FUNCTION_ARGS  )

Definition at line 270 of file btree_ts.c.

271{
272 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
274
275 /* Oid subtype = PG_GETARG_OID(3); */
276 tsKEY *kkk = (tsKEY *) DatumGetPointer(entry->key);
278
279 key.lower = (GBT_NUMKEY *) &kkk->lower;
280 key.upper = (GBT_NUMKEY *) &kkk->upper;
281
283 &tinfo, fcinfo->flinfo));
284}
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, tsKEY::lower, PG_GETARG_POINTER, PG_GETARG_TIMESTAMP, PG_RETURN_FLOAT8, tinfo, and tsKEY::upper.

◆ gbt_ts_fetch()

Datum gbt_ts_fetch ( PG_FUNCTION_ARGS  )

Definition at line 240 of file btree_ts.c.

241{
242 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
243
245}
GISTENTRY * gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)

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

◆ gbt_ts_penalty()

Datum gbt_ts_penalty ( PG_FUNCTION_ARGS  )

Definition at line 351 of file btree_ts.c.

352{
353 tsKEY *origentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
354 tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
355 float *result = (float *) PG_GETARG_POINTER(2);
356
357 double orgdbl[2],
358 newdbl[2];
359
360 /*
361 * We are always using "double" timestamps here. Precision should be good
362 * enough.
363 */
364 orgdbl[0] = ((double) origentry->lower);
365 orgdbl[1] = ((double) origentry->upper);
366 newdbl[0] = ((double) newentry->lower);
367 newdbl[1] = ((double) newentry->upper);
368
369 penalty_check_max_float(orgdbl[0]);
370 penalty_check_max_float(orgdbl[1]);
371 penalty_check_max_float(newdbl[0]);
372 penalty_check_max_float(newdbl[1]);
373
374 penalty_num(result, orgdbl[0], orgdbl[1], newdbl[0], newdbl[1]);
375
376 PG_RETURN_POINTER(result);
377}
#define penalty_check_max_float(val)
Definition: btree_ts.c:341
#define penalty_num(result, olower, oupper, nlower, nupper)

References DatumGetPointer(), sort-test::key, tsKEY::lower, penalty_check_max_float, penalty_num, PG_GETARG_POINTER, PG_RETURN_POINTER, and tsKEY::upper.

◆ gbt_ts_picksplit()

Datum gbt_ts_picksplit ( PG_FUNCTION_ARGS  )

Definition at line 381 of file btree_ts.c.

382{
385 &tinfo, fcinfo->flinfo));
386}
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_ts_same()

Datum gbt_ts_same ( PG_FUNCTION_ARGS  )

Definition at line 389 of file btree_ts.c.

390{
391 tsKEY *b1 = (tsKEY *) PG_GETARG_POINTER(0);
392 tsKEY *b2 = (tsKEY *) PG_GETARG_POINTER(1);
393 bool *result = (bool *) PG_GETARG_POINTER(2);
394
395 *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
396 PG_RETURN_POINTER(result);
397}
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_ts_sortsupport()

Datum gbt_ts_sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 412 of file btree_ts.c.

413{
415
417 ssup->ssup_extra = NULL;
418
420}
static int gbt_ts_ssup_cmp(Datum x, Datum y, SortSupport ssup)
Definition: btree_ts.c:400
#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_ts_ssup_cmp(), PG_GETARG_POINTER, PG_RETURN_VOID, and SortSupportData::ssup_extra.

◆ gbt_ts_ssup_cmp()

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

Definition at line 400 of file btree_ts.c.

401{
402 tsKEY *arg1 = (tsKEY *) DatumGetPointer(x);
403 tsKEY *arg2 = (tsKEY *) DatumGetPointer(y);
404
405 /* for leaf items we expect lower == upper, so only compare lower */
409}
Datum timestamp_cmp(PG_FUNCTION_ARGS)
Definition: timestamp.c:2270
int y
Definition: isn.c:76
int x
Definition: isn.c:75
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:207

References DatumGetInt32(), DatumGetPointer(), DirectFunctionCall2, tsKEY::lower, timestamp_cmp(), TimestampGetDatumFast, x, and y.

Referenced by gbt_ts_sortsupport().

◆ gbt_ts_union()

Datum gbt_ts_union ( PG_FUNCTION_ARGS  )

Definition at line 331 of file btree_ts.c.

332{
334 void *out = palloc(sizeof(tsKEY));
335
336 *(int *) PG_GETARG_POINTER(1) = sizeof(tsKEY);
337 PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo));
338}
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_tseq()

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

Definition at line 68 of file btree_ts.c.

69{
70 const Timestamp *aa = (const Timestamp *) a;
71 const Timestamp *bb = (const Timestamp *) b;
72
76}
Datum timestamp_eq(PG_FUNCTION_ARGS)
Definition: timestamp.c:2216
static bool DatumGetBool(Datum X)
Definition: postgres.h:95

References a, b, DatumGetBool(), DirectFunctionCall2, timestamp_eq(), and TimestampGetDatumFast.

◆ gbt_tsge()

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

Definition at line 57 of file btree_ts.c.

58{
59 const Timestamp *aa = (const Timestamp *) a;
60 const Timestamp *bb = (const Timestamp *) b;
61
65}
Datum timestamp_ge(PG_FUNCTION_ARGS)
Definition: timestamp.c:2261

References a, b, DatumGetBool(), DirectFunctionCall2, timestamp_ge(), and TimestampGetDatumFast.

◆ gbt_tsgt()

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

Definition at line 46 of file btree_ts.c.

47{
48 const Timestamp *aa = (const Timestamp *) a;
49 const Timestamp *bb = (const Timestamp *) b;
50
54}
Datum timestamp_gt(PG_FUNCTION_ARGS)
Definition: timestamp.c:2243

References a, b, DatumGetBool(), DirectFunctionCall2, timestamp_gt(), and TimestampGetDatumFast.

◆ gbt_tskey_cmp()

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

Definition at line 101 of file btree_ts.c.

102{
103 tsKEY *ia = (tsKEY *) (((const Nsrt *) a)->t);
104 tsKEY *ib = (tsKEY *) (((const Nsrt *) b)->t);
105 int res;
106
108 if (res == 0)
110
111 return res;
112}

References a, b, DatumGetInt32(), DirectFunctionCall2, tsKEY::lower, timestamp_cmp(), TimestampGetDatumFast, and tsKEY::upper.

◆ gbt_tsle()

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

Definition at line 79 of file btree_ts.c.

80{
81 const Timestamp *aa = (const Timestamp *) a;
82 const Timestamp *bb = (const Timestamp *) b;
83
87}
Datum timestamp_le(PG_FUNCTION_ARGS)
Definition: timestamp.c:2252

References a, b, DatumGetBool(), DirectFunctionCall2, timestamp_le(), and TimestampGetDatumFast.

◆ gbt_tslt()

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

Definition at line 90 of file btree_ts.c.

91{
92 const Timestamp *aa = (const Timestamp *) a;
93 const Timestamp *bb = (const Timestamp *) b;
94
98}
Datum timestamp_lt(PG_FUNCTION_ARGS)
Definition: timestamp.c:2234

References a, b, DatumGetBool(), DirectFunctionCall2, timestamp_lt(), and TimestampGetDatumFast.

◆ gbt_tstz_compress()

Datum gbt_tstz_compress ( PG_FUNCTION_ARGS  )

Definition at line 214 of file btree_ts.c.

215{
216 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
217 GISTENTRY *retval;
218
219 if (entry->leafkey)
220 {
221 tsKEY *r = (tsKEY *) palloc(sizeof(tsKEY));
224
225 gmt = tstz_to_ts_gmt(ts);
226
227 retval = palloc(sizeof(GISTENTRY));
228 r->lower = r->upper = gmt;
229 gistentryinit(*retval, PointerGetDatum(r),
230 entry->rel, entry->page,
231 entry->offset, false);
232 }
233 else
234 retval = entry;
235
236 PG_RETURN_POINTER(retval);
237}
static Timestamp tstz_to_ts_gmt(TimestampTz ts)
Definition: btree_ts.c:198
int64 TimestampTz
Definition: timestamp.h:39
#define gistentryinit(e, k, r, pg, o, l)
Definition: gist.h:245
static const char gmt[]
Definition: localtime.c:53
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
static TimestampTz DatumGetTimestampTz(Datum X)
Definition: timestamp.h:34

References DatumGetTimestampTz(), gistentryinit, gmt, GISTENTRY::key, GISTENTRY::leafkey, tsKEY::lower, GISTENTRY::offset, GISTENTRY::page, palloc(), PG_GETARG_POINTER, PG_RETURN_POINTER, PointerGetDatum(), GISTENTRY::rel, tstz_to_ts_gmt(), and tsKEY::upper.

◆ gbt_tstz_consistent()

Datum gbt_tstz_consistent ( PG_FUNCTION_ARGS  )

Definition at line 287 of file btree_ts.c.

288{
289 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
292
293 /* Oid subtype = PG_GETARG_OID(3); */
294 bool *recheck = (bool *) PG_GETARG_POINTER(4);
295 char *kkk = (char *) DatumGetPointer(entry->key);
297 Timestamp qqq;
298
299 /* All cases served by this function are exact */
300 *recheck = false;
301
302 key.lower = (GBT_NUMKEY *) &kkk[0];
303 key.upper = (GBT_NUMKEY *) &kkk[MAXALIGN(tinfo.size)];
304 qqq = tstz_to_ts_gmt(query);
305
306 PG_RETURN_BOOL(gbt_num_consistent(&key, &qqq, &strategy,
307 GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
308}
#define MAXALIGN(LEN)
Definition: c.h:782
#define PG_GETARG_TIMESTAMPTZ(n)
Definition: timestamp.h:64

References DatumGetPointer(), gbt_num_consistent(), GIST_LEAF, GISTENTRY::key, sort-test::key, MAXALIGN, PG_GETARG_POINTER, PG_GETARG_TIMESTAMPTZ, PG_GETARG_UINT16, PG_RETURN_BOOL, gbtree_ninfo::size, tinfo, and tstz_to_ts_gmt().

◆ gbt_tstz_distance()

Datum gbt_tstz_distance ( PG_FUNCTION_ARGS  )

Definition at line 311 of file btree_ts.c.

312{
313 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
315
316 /* Oid subtype = PG_GETARG_OID(3); */
317 char *kkk = (char *) DatumGetPointer(entry->key);
319 Timestamp qqq;
320
321 key.lower = (GBT_NUMKEY *) &kkk[0];
322 key.upper = (GBT_NUMKEY *) &kkk[MAXALIGN(tinfo.size)];
323 qqq = tstz_to_ts_gmt(query);
324
326 &tinfo, fcinfo->flinfo));
327}

References DatumGetPointer(), gbt_num_distance(), GIST_LEAF, GISTENTRY::key, sort-test::key, MAXALIGN, PG_GETARG_POINTER, PG_GETARG_TIMESTAMPTZ, PG_RETURN_FLOAT8, gbtree_ninfo::size, tinfo, and tstz_to_ts_gmt().

◆ PG_FUNCTION_INFO_V1() [1/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_compress  )

◆ PG_FUNCTION_INFO_V1() [2/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_consistent  )

◆ PG_FUNCTION_INFO_V1() [3/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_distance  )

◆ PG_FUNCTION_INFO_V1() [4/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_fetch  )

◆ PG_FUNCTION_INFO_V1() [5/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_penalty  )

◆ PG_FUNCTION_INFO_V1() [6/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_picksplit  )

◆ PG_FUNCTION_INFO_V1() [7/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_same  )

◆ PG_FUNCTION_INFO_V1() [8/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_sortsupport  )

◆ PG_FUNCTION_INFO_V1() [9/14]

PG_FUNCTION_INFO_V1 ( gbt_ts_union  )

◆ PG_FUNCTION_INFO_V1() [10/14]

PG_FUNCTION_INFO_V1 ( gbt_tstz_compress  )

◆ PG_FUNCTION_INFO_V1() [11/14]

PG_FUNCTION_INFO_V1 ( gbt_tstz_consistent  )

◆ PG_FUNCTION_INFO_V1() [12/14]

PG_FUNCTION_INFO_V1 ( gbt_tstz_distance  )

◆ PG_FUNCTION_INFO_V1() [13/14]

PG_FUNCTION_INFO_V1 ( ts_dist  )

◆ PG_FUNCTION_INFO_V1() [14/14]

PG_FUNCTION_INFO_V1 ( tstz_dist  )

◆ ts_dist()

Datum ts_dist ( PG_FUNCTION_ARGS  )

Definition at line 147 of file btree_ts.c.

148{
151 Interval *r;
152
154 {
155 Interval *p = palloc(sizeof(Interval));
156
157 p->day = INT_MAX;
158 p->month = INT_MAX;
159 p->time = PG_INT64_MAX;
161 }
162 else
165 PG_GETARG_DATUM(1)));
167}
Interval * abs_interval(Interval *a)
#define PG_INT64_MAX
Definition: c.h:563
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
int32 day
Definition: timestamp.h:51
int32 month
Definition: timestamp.h:52
TimeOffset time
Definition: timestamp.h:49
#define PG_RETURN_INTERVAL_P(x)
Definition: timestamp.h:69

References a, abs_interval(), b, DatumGetIntervalP(), Interval::day, DirectFunctionCall2, Interval::month, palloc(), PG_GETARG_DATUM, PG_GETARG_TIMESTAMP, PG_INT64_MAX, PG_RETURN_INTERVAL_P, Interval::time, timestamp_mi(), and TIMESTAMP_NOT_FINITE.

◆ tstz_dist()

◆ tstz_to_ts_gmt()

static Timestamp tstz_to_ts_gmt ( TimestampTz  ts)
inlinestatic

Definition at line 198 of file btree_ts.c.

199{
200 /* No timezone correction is needed, since GMT is offset 0 by definition */
201 return (Timestamp) ts;
202}

Referenced by gbt_tstz_compress(), gbt_tstz_consistent(), and gbt_tstz_distance().

Variable Documentation

◆ tinfo

const gbtree_ninfo tinfo
static
Initial value:
=
{
sizeof(Timestamp),
16,
}
@ gbt_t_ts
Definition: btree_gist.h:23
static bool gbt_tsle(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:79
static bool gbt_tsgt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:46
static bool gbt_tslt(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:90
static bool gbt_tsge(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:57
static int gbt_tskey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:101
static bool gbt_tseq(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:68
static float8 gbt_ts_dist(const void *a, const void *b, FmgrInfo *flinfo)
Definition: btree_ts.c:115

Definition at line 130 of file btree_ts.c.

Referenced by gbt_ts_compress(), gbt_ts_consistent(), gbt_ts_distance(), gbt_ts_fetch(), gbt_ts_picksplit(), gbt_ts_same(), gbt_ts_union(), gbt_tstz_consistent(), and gbt_tstz_distance().