PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nbtcompare.c File Reference
#include "postgres.h"
#include <limits.h>
#include "utils/fmgrprotos.h"
#include "utils/skipsupport.h"
#include "utils/sortsupport.h"
Include dependency graph for nbtcompare.c:

Go to the source code of this file.

Macros

#define A_LESS_THAN_B   (-1)
 
#define A_GREATER_THAN_B   1
 

Functions

Datum btboolcmp (PG_FUNCTION_ARGS)
 
static Datum bool_decrement (Relation rel, Datum existing, bool *underflow)
 
static Datum bool_increment (Relation rel, Datum existing, bool *overflow)
 
Datum btboolskipsupport (PG_FUNCTION_ARGS)
 
Datum btint2cmp (PG_FUNCTION_ARGS)
 
static int btint2fastcmp (Datum x, Datum y, SortSupport ssup)
 
Datum btint2sortsupport (PG_FUNCTION_ARGS)
 
static Datum int2_decrement (Relation rel, Datum existing, bool *underflow)
 
static Datum int2_increment (Relation rel, Datum existing, bool *overflow)
 
Datum btint2skipsupport (PG_FUNCTION_ARGS)
 
Datum btint4cmp (PG_FUNCTION_ARGS)
 
Datum btint4sortsupport (PG_FUNCTION_ARGS)
 
static Datum int4_decrement (Relation rel, Datum existing, bool *underflow)
 
static Datum int4_increment (Relation rel, Datum existing, bool *overflow)
 
Datum btint4skipsupport (PG_FUNCTION_ARGS)
 
Datum btint8cmp (PG_FUNCTION_ARGS)
 
static int btint8fastcmp (Datum x, Datum y, SortSupport ssup)
 
Datum btint8sortsupport (PG_FUNCTION_ARGS)
 
static Datum int8_decrement (Relation rel, Datum existing, bool *underflow)
 
static Datum int8_increment (Relation rel, Datum existing, bool *overflow)
 
Datum btint8skipsupport (PG_FUNCTION_ARGS)
 
Datum btint48cmp (PG_FUNCTION_ARGS)
 
Datum btint84cmp (PG_FUNCTION_ARGS)
 
Datum btint24cmp (PG_FUNCTION_ARGS)
 
Datum btint42cmp (PG_FUNCTION_ARGS)
 
Datum btint28cmp (PG_FUNCTION_ARGS)
 
Datum btint82cmp (PG_FUNCTION_ARGS)
 
Datum btoidcmp (PG_FUNCTION_ARGS)
 
static int btoidfastcmp (Datum x, Datum y, SortSupport ssup)
 
Datum btoidsortsupport (PG_FUNCTION_ARGS)
 
static Datum oid_decrement (Relation rel, Datum existing, bool *underflow)
 
static Datum oid_increment (Relation rel, Datum existing, bool *overflow)
 
Datum btoidskipsupport (PG_FUNCTION_ARGS)
 
Datum btoidvectorcmp (PG_FUNCTION_ARGS)
 
Datum btcharcmp (PG_FUNCTION_ARGS)
 
static Datum char_decrement (Relation rel, Datum existing, bool *underflow)
 
static Datum char_increment (Relation rel, Datum existing, bool *overflow)
 
Datum btcharskipsupport (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ A_GREATER_THAN_B

#define A_GREATER_THAN_B   1

Definition at line 69 of file nbtcompare.c.

◆ A_LESS_THAN_B

#define A_LESS_THAN_B   (-1)

Definition at line 68 of file nbtcompare.c.

Function Documentation

◆ bool_decrement()

static Datum bool_decrement ( Relation  rel,
Datum  existing,
bool *  underflow 
)
static

Definition at line 83 of file nbtcompare.c.

84{
85 bool bexisting = DatumGetBool(existing);
86
87 if (bexisting == false)
88 {
89 /* return value is undefined */
90 *underflow = true;
91 return (Datum) 0;
92 }
93
94 *underflow = false;
95 return BoolGetDatum(bexisting - 1);
96}
static bool DatumGetBool(Datum X)
Definition: postgres.h:95
uintptr_t Datum
Definition: postgres.h:69
static Datum BoolGetDatum(bool X)
Definition: postgres.h:107

References BoolGetDatum(), and DatumGetBool().

Referenced by btboolskipsupport().

◆ bool_increment()

static Datum bool_increment ( Relation  rel,
Datum  existing,
bool *  overflow 
)
static

Definition at line 99 of file nbtcompare.c.

100{
101 bool bexisting = DatumGetBool(existing);
102
103 if (bexisting == true)
104 {
105 /* return value is undefined */
106 *overflow = true;
107 return (Datum) 0;
108 }
109
110 *overflow = false;
111 return BoolGetDatum(bexisting + 1);
112}

References BoolGetDatum(), and DatumGetBool().

Referenced by btboolskipsupport().

◆ btboolcmp()

Datum btboolcmp ( PG_FUNCTION_ARGS  )

Definition at line 74 of file nbtcompare.c.

75{
76 bool a = PG_GETARG_BOOL(0);
77 bool b = PG_GETARG_BOOL(1);
78
80}
int32_t int32
Definition: c.h:498
#define PG_RETURN_INT32(x)
Definition: fmgr.h:354
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
int b
Definition: isn.c:74
int a
Definition: isn.c:73

References a, b, PG_GETARG_BOOL, and PG_RETURN_INT32.

◆ btboolskipsupport()

Datum btboolskipsupport ( PG_FUNCTION_ARGS  )

Definition at line 115 of file nbtcompare.c.

116{
118
119 sksup->decrement = bool_decrement;
120 sksup->increment = bool_increment;
121 sksup->low_elem = BoolGetDatum(false);
122 sksup->high_elem = BoolGetDatum(true);
123
125}
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
static Datum bool_increment(Relation rel, Datum existing, bool *overflow)
Definition: nbtcompare.c:99
static Datum bool_decrement(Relation rel, Datum existing, bool *underflow)
Definition: nbtcompare.c:83
struct SkipSupportData * SkipSupport
Definition: skipsupport.h:50
SkipSupportIncDec decrement
Definition: skipsupport.h:91
SkipSupportIncDec increment
Definition: skipsupport.h:92

References bool_decrement(), bool_increment(), BoolGetDatum(), SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, SkipSupportData::low_elem, PG_GETARG_POINTER, and PG_RETURN_VOID.

◆ btcharcmp()

Datum btcharcmp ( PG_FUNCTION_ARGS  )

Definition at line 546 of file nbtcompare.c.

547{
548 char a = PG_GETARG_CHAR(0);
549 char b = PG_GETARG_CHAR(1);
550
551 /* Be careful to compare chars as unsigned */
552 PG_RETURN_INT32((int32) ((uint8) a) - (int32) ((uint8) b));
553}
uint8_t uint8
Definition: c.h:500
#define PG_GETARG_CHAR(n)
Definition: fmgr.h:273

References a, b, PG_GETARG_CHAR, and PG_RETURN_INT32.

◆ btcharskipsupport()

Datum btcharskipsupport ( PG_FUNCTION_ARGS  )

Definition at line 588 of file nbtcompare.c.

589{
591
592 sksup->decrement = char_decrement;
593 sksup->increment = char_increment;
594
595 /* btcharcmp compares chars as unsigned */
596 sksup->low_elem = UInt8GetDatum(0);
597 sksup->high_elem = UInt8GetDatum(UCHAR_MAX);
598
600}
static Datum char_decrement(Relation rel, Datum existing, bool *underflow)
Definition: nbtcompare.c:556
static Datum char_increment(Relation rel, Datum existing, bool *overflow)
Definition: nbtcompare.c:572
static Datum UInt8GetDatum(uint8 X)
Definition: postgres.h:157

References char_decrement(), char_increment(), SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, SkipSupportData::low_elem, PG_GETARG_POINTER, PG_RETURN_VOID, and UInt8GetDatum().

◆ btint24cmp()

Datum btint24cmp ( PG_FUNCTION_ARGS  )

Definition at line 384 of file nbtcompare.c.

385{
388
389 if (a > b)
391 else if (a == b)
393 else
395}
int16_t int16
Definition: c.h:497
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
#define PG_GETARG_INT16(n)
Definition: fmgr.h:271
#define A_GREATER_THAN_B
Definition: nbtcompare.c:69
#define A_LESS_THAN_B
Definition: nbtcompare.c:68

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT16, PG_GETARG_INT32, and PG_RETURN_INT32.

◆ btint28cmp()

Datum btint28cmp ( PG_FUNCTION_ARGS  )

Definition at line 412 of file nbtcompare.c.

413{
416
417 if (a > b)
419 else if (a == b)
421 else
423}
int64_t int64
Definition: c.h:499
#define PG_GETARG_INT64(n)
Definition: fmgr.h:283

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_INT32.

◆ btint2cmp()

Datum btint2cmp ( PG_FUNCTION_ARGS  )

Definition at line 128 of file nbtcompare.c.

129{
132
134}

References a, b, PG_GETARG_INT16, and PG_RETURN_INT32.

◆ btint2fastcmp()

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

Definition at line 137 of file nbtcompare.c.

138{
141
142 return (int) a - (int) b;
143}
int y
Definition: isn.c:76
int x
Definition: isn.c:75
static int16 DatumGetInt16(Datum X)
Definition: postgres.h:167

References a, b, DatumGetInt16(), x, and y.

Referenced by btint2sortsupport().

◆ btint2skipsupport()

Datum btint2skipsupport ( PG_FUNCTION_ARGS  )

Definition at line 187 of file nbtcompare.c.

188{
190
191 sksup->decrement = int2_decrement;
192 sksup->increment = int2_increment;
195
197}
#define PG_INT16_MIN
Definition: c.h:556
#define PG_INT16_MAX
Definition: c.h:557
static Datum int2_decrement(Relation rel, Datum existing, bool *underflow)
Definition: nbtcompare.c:155
static Datum int2_increment(Relation rel, Datum existing, bool *overflow)
Definition: nbtcompare.c:171
static Datum Int16GetDatum(int16 X)
Definition: postgres.h:177

References SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, Int16GetDatum(), int2_decrement(), int2_increment(), SkipSupportData::low_elem, PG_GETARG_POINTER, PG_INT16_MAX, PG_INT16_MIN, and PG_RETURN_VOID.

◆ btint2sortsupport()

Datum btint2sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 146 of file nbtcompare.c.

147{
149
152}
static int btint2fastcmp(Datum x, Datum y, SortSupport ssup)
Definition: nbtcompare.c:137
struct SortSupportData * SortSupport
Definition: sortsupport.h:58
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Definition: sortsupport.h:106

References btint2fastcmp(), SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.

◆ btint42cmp()

Datum btint42cmp ( PG_FUNCTION_ARGS  )

Definition at line 398 of file nbtcompare.c.

399{
402
403 if (a > b)
405 else if (a == b)
407 else
409}

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT16, PG_GETARG_INT32, and PG_RETURN_INT32.

◆ btint48cmp()

Datum btint48cmp ( PG_FUNCTION_ARGS  )

Definition at line 356 of file nbtcompare.c.

357{
360
361 if (a > b)
363 else if (a == b)
365 else
367}

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT32.

◆ btint4cmp()

Datum btint4cmp ( PG_FUNCTION_ARGS  )

Definition at line 200 of file nbtcompare.c.

201{
204
205 if (a > b)
207 else if (a == b)
209 else
211}

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT32, and PG_RETURN_INT32.

◆ btint4skipsupport()

Datum btint4skipsupport ( PG_FUNCTION_ARGS  )

Definition at line 255 of file nbtcompare.c.

256{
258
259 sksup->decrement = int4_decrement;
260 sksup->increment = int4_increment;
263
265}
#define PG_INT32_MAX
Definition: c.h:560
#define PG_INT32_MIN
Definition: c.h:559
static Datum int4_increment(Relation rel, Datum existing, bool *overflow)
Definition: nbtcompare.c:239
static Datum int4_decrement(Relation rel, Datum existing, bool *underflow)
Definition: nbtcompare.c:223
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:217

References SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, Int32GetDatum(), int4_decrement(), int4_increment(), SkipSupportData::low_elem, PG_GETARG_POINTER, PG_INT32_MAX, PG_INT32_MIN, and PG_RETURN_VOID.

◆ btint4sortsupport()

Datum btint4sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 214 of file nbtcompare.c.

215{
217
220}
int ssup_datum_int32_cmp(Datum x, Datum y, SortSupport ssup)
Definition: tuplesort.c:3166

References SortSupportData::comparator, PG_GETARG_POINTER, PG_RETURN_VOID, and ssup_datum_int32_cmp().

◆ btint82cmp()

Datum btint82cmp ( PG_FUNCTION_ARGS  )

Definition at line 426 of file nbtcompare.c.

427{
430
431 if (a > b)
433 else if (a == b)
435 else
437}

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_INT32.

◆ btint84cmp()

Datum btint84cmp ( PG_FUNCTION_ARGS  )

Definition at line 370 of file nbtcompare.c.

371{
374
375 if (a > b)
377 else if (a == b)
379 else
381}

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT32.

◆ btint8cmp()

Datum btint8cmp ( PG_FUNCTION_ARGS  )

Definition at line 268 of file nbtcompare.c.

269{
272
273 if (a > b)
275 else if (a == b)
277 else
279}

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_INT64, and PG_RETURN_INT32.

◆ btint8fastcmp()

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

Definition at line 283 of file nbtcompare.c.

284{
287
288 if (a > b)
289 return A_GREATER_THAN_B;
290 else if (a == b)
291 return 0;
292 else
293 return A_LESS_THAN_B;
294}
static int64 DatumGetInt64(Datum X)
Definition: postgres.h:390

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, DatumGetInt64(), x, and y.

Referenced by btint8sortsupport().

◆ btint8skipsupport()

Datum btint8skipsupport ( PG_FUNCTION_ARGS  )

Definition at line 343 of file nbtcompare.c.

344{
346
347 sksup->decrement = int8_decrement;
348 sksup->increment = int8_increment;
351
353}
#define PG_INT64_MAX
Definition: c.h:563
#define PG_INT64_MIN
Definition: c.h:562
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1807
static Datum int8_decrement(Relation rel, Datum existing, bool *underflow)
Definition: nbtcompare.c:311
static Datum int8_increment(Relation rel, Datum existing, bool *overflow)
Definition: nbtcompare.c:327

References SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, Int64GetDatum(), int8_decrement(), int8_increment(), SkipSupportData::low_elem, PG_GETARG_POINTER, PG_INT64_MAX, PG_INT64_MIN, and PG_RETURN_VOID.

◆ btint8sortsupport()

Datum btint8sortsupport ( PG_FUNCTION_ARGS  )

Definition at line 298 of file nbtcompare.c.

299{
301
302#if SIZEOF_DATUM >= 8
303 ssup->comparator = ssup_datum_signed_cmp;
304#else
306#endif
308}
static int btint8fastcmp(Datum x, Datum y, SortSupport ssup)
Definition: nbtcompare.c:283

References btint8fastcmp(), SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.

◆ btoidcmp()

Datum btoidcmp ( PG_FUNCTION_ARGS  )

Definition at line 440 of file nbtcompare.c.

441{
442 Oid a = PG_GETARG_OID(0);
443 Oid b = PG_GETARG_OID(1);
444
445 if (a > b)
447 else if (a == b)
449 else
451}
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
unsigned int Oid
Definition: postgres_ext.h:30

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, PG_GETARG_OID, and PG_RETURN_INT32.

◆ btoidfastcmp()

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

Definition at line 454 of file nbtcompare.c.

455{
458
459 if (a > b)
460 return A_GREATER_THAN_B;
461 else if (a == b)
462 return 0;
463 else
464 return A_LESS_THAN_B;
465}
static Oid DatumGetObjectId(Datum X)
Definition: postgres.h:247

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, DatumGetObjectId(), x, and y.

Referenced by btoidsortsupport().

◆ btoidskipsupport()

Datum btoidskipsupport ( PG_FUNCTION_ARGS  )

Definition at line 509 of file nbtcompare.c.

510{
512
513 sksup->decrement = oid_decrement;
514 sksup->increment = oid_increment;
517
519}
static Datum oid_increment(Relation rel, Datum existing, bool *overflow)
Definition: nbtcompare.c:493
static Datum oid_decrement(Relation rel, Datum existing, bool *underflow)
Definition: nbtcompare.c:477
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:257
#define InvalidOid
Definition: postgres_ext.h:35
#define OID_MAX
Definition: postgres_ext.h:38

References SkipSupportData::decrement, SkipSupportData::high_elem, SkipSupportData::increment, InvalidOid, SkipSupportData::low_elem, ObjectIdGetDatum(), oid_decrement(), oid_increment(), OID_MAX, PG_GETARG_POINTER, and PG_RETURN_VOID.

◆ btoidsortsupport()

Datum btoidsortsupport ( PG_FUNCTION_ARGS  )

Definition at line 468 of file nbtcompare.c.

469{
471
472 ssup->comparator = btoidfastcmp;
474}
static int btoidfastcmp(Datum x, Datum y, SortSupport ssup)
Definition: nbtcompare.c:454

References btoidfastcmp(), SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.

◆ btoidvectorcmp()

Datum btoidvectorcmp ( PG_FUNCTION_ARGS  )

Definition at line 522 of file nbtcompare.c.

523{
526 int i;
527
528 /* We arbitrarily choose to sort first by vector length */
529 if (a->dim1 != b->dim1)
530 PG_RETURN_INT32(a->dim1 - b->dim1);
531
532 for (i = 0; i < a->dim1; i++)
533 {
534 if (a->values[i] != b->values[i])
535 {
536 if (a->values[i] > b->values[i])
538 else
540 }
541 }
543}
int i
Definition: isn.c:77
Definition: c.h:697

References a, A_GREATER_THAN_B, A_LESS_THAN_B, b, i, PG_GETARG_POINTER, and PG_RETURN_INT32.

Referenced by oidvectoreq(), oidvectorge(), oidvectorgt(), oidvectorle(), oidvectorlt(), and oidvectorne().

◆ char_decrement()

static Datum char_decrement ( Relation  rel,
Datum  existing,
bool *  underflow 
)
static

Definition at line 556 of file nbtcompare.c.

557{
558 uint8 cexisting = UInt8GetDatum(existing);
559
560 if (cexisting == 0)
561 {
562 /* return value is undefined */
563 *underflow = true;
564 return (Datum) 0;
565 }
566
567 *underflow = false;
568 return CharGetDatum((uint8) cexisting - 1);
569}
static Datum CharGetDatum(char X)
Definition: postgres.h:127

References CharGetDatum(), and UInt8GetDatum().

Referenced by btcharskipsupport().

◆ char_increment()

static Datum char_increment ( Relation  rel,
Datum  existing,
bool *  overflow 
)
static

Definition at line 572 of file nbtcompare.c.

573{
574 uint8 cexisting = UInt8GetDatum(existing);
575
576 if (cexisting == UCHAR_MAX)
577 {
578 /* return value is undefined */
579 *overflow = true;
580 return (Datum) 0;
581 }
582
583 *overflow = false;
584 return CharGetDatum((uint8) cexisting + 1);
585}

References CharGetDatum(), and UInt8GetDatum().

Referenced by btcharskipsupport().

◆ int2_decrement()

static Datum int2_decrement ( Relation  rel,
Datum  existing,
bool *  underflow 
)
static

Definition at line 155 of file nbtcompare.c.

156{
157 int16 iexisting = DatumGetInt16(existing);
158
159 if (iexisting == PG_INT16_MIN)
160 {
161 /* return value is undefined */
162 *underflow = true;
163 return (Datum) 0;
164 }
165
166 *underflow = false;
167 return Int16GetDatum(iexisting - 1);
168}

References DatumGetInt16(), Int16GetDatum(), and PG_INT16_MIN.

Referenced by btint2skipsupport().

◆ int2_increment()

static Datum int2_increment ( Relation  rel,
Datum  existing,
bool *  overflow 
)
static

Definition at line 171 of file nbtcompare.c.

172{
173 int16 iexisting = DatumGetInt16(existing);
174
175 if (iexisting == PG_INT16_MAX)
176 {
177 /* return value is undefined */
178 *overflow = true;
179 return (Datum) 0;
180 }
181
182 *overflow = false;
183 return Int16GetDatum(iexisting + 1);
184}

References DatumGetInt16(), Int16GetDatum(), and PG_INT16_MAX.

Referenced by btint2skipsupport().

◆ int4_decrement()

static Datum int4_decrement ( Relation  rel,
Datum  existing,
bool *  underflow 
)
static

Definition at line 223 of file nbtcompare.c.

224{
225 int32 iexisting = DatumGetInt32(existing);
226
227 if (iexisting == PG_INT32_MIN)
228 {
229 /* return value is undefined */
230 *underflow = true;
231 return (Datum) 0;
232 }
233
234 *underflow = false;
235 return Int32GetDatum(iexisting - 1);
236}
static int32 DatumGetInt32(Datum X)
Definition: postgres.h:207

References DatumGetInt32(), Int32GetDatum(), and PG_INT32_MIN.

Referenced by btint4skipsupport().

◆ int4_increment()

static Datum int4_increment ( Relation  rel,
Datum  existing,
bool *  overflow 
)
static

Definition at line 239 of file nbtcompare.c.

240{
241 int32 iexisting = DatumGetInt32(existing);
242
243 if (iexisting == PG_INT32_MAX)
244 {
245 /* return value is undefined */
246 *overflow = true;
247 return (Datum) 0;
248 }
249
250 *overflow = false;
251 return Int32GetDatum(iexisting + 1);
252}

References DatumGetInt32(), Int32GetDatum(), and PG_INT32_MAX.

Referenced by btint4skipsupport().

◆ int8_decrement()

static Datum int8_decrement ( Relation  rel,
Datum  existing,
bool *  underflow 
)
static

Definition at line 311 of file nbtcompare.c.

312{
313 int64 iexisting = DatumGetInt64(existing);
314
315 if (iexisting == PG_INT64_MIN)
316 {
317 /* return value is undefined */
318 *underflow = true;
319 return (Datum) 0;
320 }
321
322 *underflow = false;
323 return Int64GetDatum(iexisting - 1);
324}

References DatumGetInt64(), Int64GetDatum(), and PG_INT64_MIN.

Referenced by btint8skipsupport().

◆ int8_increment()

static Datum int8_increment ( Relation  rel,
Datum  existing,
bool *  overflow 
)
static

Definition at line 327 of file nbtcompare.c.

328{
329 int64 iexisting = DatumGetInt64(existing);
330
331 if (iexisting == PG_INT64_MAX)
332 {
333 /* return value is undefined */
334 *overflow = true;
335 return (Datum) 0;
336 }
337
338 *overflow = false;
339 return Int64GetDatum(iexisting + 1);
340}

References DatumGetInt64(), Int64GetDatum(), and PG_INT64_MAX.

Referenced by btint8skipsupport().

◆ oid_decrement()

static Datum oid_decrement ( Relation  rel,
Datum  existing,
bool *  underflow 
)
static

Definition at line 477 of file nbtcompare.c.

478{
479 Oid oexisting = DatumGetObjectId(existing);
480
481 if (oexisting == InvalidOid)
482 {
483 /* return value is undefined */
484 *underflow = true;
485 return (Datum) 0;
486 }
487
488 *underflow = false;
489 return ObjectIdGetDatum(oexisting - 1);
490}

References DatumGetObjectId(), InvalidOid, and ObjectIdGetDatum().

Referenced by btoidskipsupport().

◆ oid_increment()

static Datum oid_increment ( Relation  rel,
Datum  existing,
bool *  overflow 
)
static

Definition at line 493 of file nbtcompare.c.

494{
495 Oid oexisting = DatumGetObjectId(existing);
496
497 if (oexisting == OID_MAX)
498 {
499 /* return value is undefined */
500 *overflow = true;
501 return (Datum) 0;
502 }
503
504 *overflow = false;
505 return ObjectIdGetDatum(oexisting + 1);
506}

References DatumGetObjectId(), ObjectIdGetDatum(), and OID_MAX.

Referenced by btoidskipsupport().