PostgreSQL Source Code  git master
btree_gin.c File Reference
#include "postgres.h"
#include <limits.h>
#include "access/stratnum.h"
#include "utils/builtins.h"
#include "utils/bytea.h"
#include "utils/cash.h"
#include "utils/date.h"
#include "utils/float.h"
#include "utils/inet.h"
#include "utils/numeric.h"
#include "utils/timestamp.h"
#include "utils/varbit.h"
#include "utils/uuid.h"
Include dependency graph for btree_gin.c:

Go to the source code of this file.

Data Structures

struct  QueryInfo
 

Macros

#define GIN_SUPPORT(type, is_varlena, leftmostvalue, typecmp)
 
#define NUMERIC_IS_LEFTMOST(x)   ((x) == NULL)
 
#define ENUM_IS_LEFTMOST(x)   ((x) == InvalidOid)
 

Typedefs

typedef struct QueryInfo QueryInfo
 

Functions

static Datum gin_btree_extract_value (FunctionCallInfo fcinfo, bool is_varlena)
 
static Datum gin_btree_extract_query (FunctionCallInfo fcinfo, bool is_varlena, Datum(*leftmostvalue)(void), Datum(*typecmp)(FunctionCallInfo))
 
static Datum gin_btree_compare_prefix (FunctionCallInfo fcinfo)
 
 PG_FUNCTION_INFO_V1 (gin_btree_consistent)
 
Datum gin_btree_consistent (PG_FUNCTION_ARGS)
 
static Datum leftmostvalue_int2 (void)
 
static Datum leftmostvalue_int4 (void)
 
static Datum leftmostvalue_int8 (void)
 
static Datum leftmostvalue_float4 (void)
 
static Datum leftmostvalue_float8 (void)
 
static Datum leftmostvalue_money (void)
 
static Datum leftmostvalue_oid (void)
 
static Datum leftmostvalue_timestamp (void)
 
static Datum leftmostvalue_time (void)
 
static Datum leftmostvalue_timetz (void)
 
static Datum leftmostvalue_date (void)
 
static Datum leftmostvalue_interval (void)
 
static Datum leftmostvalue_macaddr (void)
 
static Datum leftmostvalue_macaddr8 (void)
 
static Datum leftmostvalue_inet (void)
 
static Datum leftmostvalue_text (void)
 
static Datum leftmostvalue_char (void)
 
static Datum leftmostvalue_bit (void)
 
static Datum leftmostvalue_varbit (void)
 
 PG_FUNCTION_INFO_V1 (gin_numeric_cmp)
 
Datum gin_numeric_cmp (PG_FUNCTION_ARGS)
 
static Datum leftmostvalue_numeric (void)
 
 PG_FUNCTION_INFO_V1 (gin_enum_cmp)
 
Datum gin_enum_cmp (PG_FUNCTION_ARGS)
 
static Datum leftmostvalue_enum (void)
 
static Datum leftmostvalue_uuid (void)
 
static Datum leftmostvalue_name (void)
 
static Datum leftmostvalue_bool (void)
 

Variables

 PG_MODULE_MAGIC
 

Macro Definition Documentation

◆ ENUM_IS_LEFTMOST

#define ENUM_IS_LEFTMOST (   x)    ((x) == InvalidOid)

Definition at line 445 of file btree_gin.c.

Referenced by gin_enum_cmp().

◆ GIN_SUPPORT

#define GIN_SUPPORT (   type,
  is_varlena,
  leftmostvalue,
  typecmp 
)
Value:
PG_FUNCTION_INFO_V1(gin_extract_value_##type); \
Datum \
gin_extract_value_##type(PG_FUNCTION_ARGS) \
{ \
return gin_btree_extract_value(fcinfo, is_varlena); \
} \
PG_FUNCTION_INFO_V1(gin_extract_query_##type); \
Datum \
gin_extract_query_##type(PG_FUNCTION_ARGS) \
{ \
return gin_btree_extract_query(fcinfo, \
is_varlena, leftmostvalue, typecmp); \
} \
PG_FUNCTION_INFO_V1(gin_compare_prefix_##type); \
Datum \
gin_compare_prefix_##type(PG_FUNCTION_ARGS) \
{ \
return gin_btree_compare_prefix(fcinfo); \
}
static Datum gin_btree_extract_query(FunctionCallInfo fcinfo, bool is_varlena, Datum(*leftmostvalue)(void), Datum(*typecmp)(FunctionCallInfo))
Definition: btree_gin.c:56
PG_FUNCTION_INFO_V1(gin_btree_consistent)
static Datum gin_btree_extract_value(FunctionCallInfo fcinfo, bool is_varlena)
Definition: btree_gin.c:33
#define PG_FUNCTION_ARGS
Definition: fmgr.h:188
static Datum gin_btree_compare_prefix(FunctionCallInfo fcinfo)
Definition: btree_gin.c:109

Definition at line 186 of file btree_gin.c.

Referenced by leftmostvalue_bit(), leftmostvalue_bool(), leftmostvalue_char(), leftmostvalue_date(), leftmostvalue_enum(), leftmostvalue_float4(), leftmostvalue_float8(), leftmostvalue_inet(), leftmostvalue_int2(), leftmostvalue_int4(), leftmostvalue_int8(), leftmostvalue_interval(), leftmostvalue_macaddr(), leftmostvalue_macaddr8(), leftmostvalue_money(), leftmostvalue_name(), leftmostvalue_numeric(), leftmostvalue_oid(), leftmostvalue_text(), leftmostvalue_time(), leftmostvalue_timestamp(), leftmostvalue_timetz(), leftmostvalue_uuid(), and leftmostvalue_varbit().

◆ NUMERIC_IS_LEFTMOST

#define NUMERIC_IS_LEFTMOST (   x)    ((x) == NULL)

Definition at line 398 of file btree_gin.c.

Referenced by gin_numeric_cmp().

Typedef Documentation

◆ QueryInfo

typedef struct QueryInfo QueryInfo

Function Documentation

◆ gin_btree_compare_prefix()

static Datum gin_btree_compare_prefix ( FunctionCallInfo  fcinfo)
static

Definition at line 109 of file btree_gin.c.

References BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, CallerFInfoFunctionCall2(), cmp(), QueryInfo::datum, DatumGetInt32, elog, ERROR, FunctionCallInfoBaseData::flinfo, gin_btree_consistent(), PG_FUNCTION_INFO_V1(), PG_GET_COLLATION, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_INT32, QueryInfo::strategy, and QueryInfo::typecmp.

110 {
111  Datum a = PG_GETARG_DATUM(0);
112  Datum b = PG_GETARG_DATUM(1);
113  QueryInfo *data = (QueryInfo *) PG_GETARG_POINTER(3);
114  int32 res,
115  cmp;
116 
118  data->typecmp,
119  fcinfo->flinfo,
121  (data->strategy == BTLessStrategyNumber ||
123  ? data->datum : a,
124  b));
125 
126  switch (data->strategy)
127  {
129  /* If original datum > indexed one then return match */
130  if (cmp > 0)
131  res = 0;
132  else
133  res = 1;
134  break;
136  /* The same except equality */
137  if (cmp >= 0)
138  res = 0;
139  else
140  res = 1;
141  break;
143  if (cmp != 0)
144  res = 1;
145  else
146  res = 0;
147  break;
149  /* If original datum <= indexed one then return match */
150  if (cmp <= 0)
151  res = 0;
152  else
153  res = 1;
154  break;
156  /* If original datum <= indexed one then return match */
157  /* If original datum == indexed one then continue scan */
158  if (cmp < 0)
159  res = 0;
160  else if (cmp == 0)
161  res = -1;
162  else
163  res = 1;
164  break;
165  default:
166  elog(ERROR, "unrecognized strategy number: %d",
167  data->strategy);
168  res = 0;
169  }
170 
171  PG_RETURN_INT32(res);
172 }
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define DatumGetInt32(X)
Definition: postgres.h:472
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:263
#define PG_RETURN_INT32(x)
Definition: fmgr.h:344
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
#define PG_GET_COLLATION()
Definition: fmgr.h:193
signed int int32
Definition: c.h:346
Datum datum
Definition: btree_gin.c:25
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
StrategyNumber strategy
Definition: btree_gin.c:24
#define ERROR
Definition: elog.h:43
Datum(* typecmp)(FunctionCallInfo)
Definition: btree_gin.c:27
uintptr_t Datum
Definition: postgres.h:367
FmgrInfo * flinfo
Definition: fmgr.h:87
#define elog(elevel,...)
Definition: elog.h:226
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31
#define BTGreaterEqualStrategyNumber
Definition: stratnum.h:32
static int cmp(const chr *x, const chr *y, size_t len)
Definition: regc_locale.c:742

◆ gin_btree_consistent()

Datum gin_btree_consistent ( PG_FUNCTION_ARGS  )

Definition at line 176 of file btree_gin.c.

References PG_GETARG_POINTER, and PG_RETURN_BOOL.

Referenced by gin_btree_compare_prefix().

177 {
178  bool *recheck = (bool *) PG_GETARG_POINTER(5);
179 
180  *recheck = false;
181  PG_RETURN_BOOL(true);
182 }
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:349

◆ gin_btree_extract_query()

static Datum gin_btree_extract_query ( FunctionCallInfo  fcinfo,
bool  is_varlena,
Datum(*)(void)  leftmostvalue,
Datum(*)(FunctionCallInfo typecmp 
)
static

Definition at line 56 of file btree_gin.c.

References BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, QueryInfo::datum, elog, ERROR, QueryInfo::is_varlena, palloc(), PG_DETOAST_DATUM, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_GETARG_UINT16, PG_RETURN_POINTER, PointerGetDatum, QueryInfo::strategy, and QueryInfo::typecmp.

60 {
61  Datum datum = PG_GETARG_DATUM(0);
62  int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
63  StrategyNumber strategy = PG_GETARG_UINT16(2);
64  bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
65  Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
66  Datum *entries = (Datum *) palloc(sizeof(Datum));
67  QueryInfo *data = (QueryInfo *) palloc(sizeof(QueryInfo));
68  bool *ptr_partialmatch;
69 
70  *nentries = 1;
71  ptr_partialmatch = *partialmatch = (bool *) palloc(sizeof(bool));
72  *ptr_partialmatch = false;
73  if (is_varlena)
74  datum = PointerGetDatum(PG_DETOAST_DATUM(datum));
75  data->strategy = strategy;
76  data->datum = datum;
77  data->is_varlena = is_varlena;
78  data->typecmp = typecmp;
79  *extra_data = (Pointer *) palloc(sizeof(Pointer));
80  **extra_data = (Pointer) data;
81 
82  switch (strategy)
83  {
86  entries[0] = leftmostvalue();
87  *ptr_partialmatch = true;
88  break;
91  *ptr_partialmatch = true;
92  /* FALLTHROUGH */
94  entries[0] = datum;
95  break;
96  default:
97  elog(ERROR, "unrecognized strategy number: %d", strategy);
98  }
99 
100  PG_RETURN_POINTER(entries);
101 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
bool is_varlena
Definition: btree_gin.c:26
#define PointerGetDatum(X)
Definition: postgres.h:556
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:263
uint16 StrategyNumber
Definition: stratnum.h:22
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
signed int int32
Definition: c.h:346
Datum datum
Definition: btree_gin.c:25
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
StrategyNumber strategy
Definition: btree_gin.c:24
char * Pointer
Definition: c.h:335
#define ERROR
Definition: elog.h:43
Datum(* typecmp)(FunctionCallInfo)
Definition: btree_gin.c:27
uintptr_t Datum
Definition: postgres.h:367
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:267
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:226
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:235
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31
#define BTGreaterEqualStrategyNumber
Definition: stratnum.h:32

◆ gin_btree_extract_value()

static Datum gin_btree_extract_value ( FunctionCallInfo  fcinfo,
bool  is_varlena 
)
static

Definition at line 33 of file btree_gin.c.

References QueryInfo::datum, palloc(), PG_DETOAST_DATUM, PG_GETARG_DATUM, PG_GETARG_POINTER, PG_RETURN_POINTER, and PointerGetDatum.

34 {
35  Datum datum = PG_GETARG_DATUM(0);
36  int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
37  Datum *entries = (Datum *) palloc(sizeof(Datum));
38 
39  if (is_varlena)
40  datum = PointerGetDatum(PG_DETOAST_DATUM(datum));
41  entries[0] = datum;
42  *nentries = 1;
43 
44  PG_RETURN_POINTER(entries);
45 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:351
#define PointerGetDatum(X)
Definition: postgres.h:556
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:263
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
signed int int32
Definition: c.h:346
uintptr_t Datum
Definition: postgres.h:367
void * palloc(Size size)
Definition: mcxt.c:949
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:235

◆ gin_enum_cmp()

Datum gin_enum_cmp ( PG_FUNCTION_ARGS  )

Definition at line 450 of file btree_gin.c.

References CallerFInfoFunctionCall2(), DatumGetInt32, enum_cmp(), ENUM_IS_LEFTMOST, FunctionCallInfoBaseData::flinfo, ObjectIdGetDatum, PG_GET_COLLATION, PG_GETARG_OID, and PG_RETURN_INT32.

Referenced by leftmostvalue_enum().

451 {
452  Oid a = PG_GETARG_OID(0);
453  Oid b = PG_GETARG_OID(1);
454  int res = 0;
455 
456  if (ENUM_IS_LEFTMOST(a))
457  {
458  res = (ENUM_IS_LEFTMOST(b)) ? 0 : -1;
459  }
460  else if (ENUM_IS_LEFTMOST(b))
461  {
462  res = 1;
463  }
464  else
465  {
467  enum_cmp,
468  fcinfo->flinfo,
470  ObjectIdGetDatum(a),
471  ObjectIdGetDatum(b)));
472  }
473 
474  PG_RETURN_INT32(res);
475 }
#define DatumGetInt32(X)
Definition: postgres.h:472
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
#define PG_RETURN_INT32(x)
Definition: fmgr.h:344
unsigned int Oid
Definition: postgres_ext.h:31
#define PG_GET_COLLATION()
Definition: fmgr.h:193
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define PG_GETARG_OID(n)
Definition: fmgr.h:270
#define ENUM_IS_LEFTMOST(x)
Definition: btree_gin.c:445
Datum enum_cmp(PG_FUNCTION_ARGS)
Definition: enum.c:373

◆ gin_numeric_cmp()

Datum gin_numeric_cmp ( PG_FUNCTION_ARGS  )

Definition at line 403 of file btree_gin.c.

References DatumGetInt32, DirectFunctionCall2, numeric_cmp(), NUMERIC_IS_LEFTMOST, NumericGetDatum, PG_GETARG_POINTER, and PG_RETURN_INT32.

Referenced by leftmostvalue_numeric().

404 {
407  int res = 0;
408 
409  if (NUMERIC_IS_LEFTMOST(a))
410  {
411  res = (NUMERIC_IS_LEFTMOST(b)) ? 0 : -1;
412  }
413  else if (NUMERIC_IS_LEFTMOST(b))
414  {
415  res = 1;
416  }
417  else
418  {
420  NumericGetDatum(a),
421  NumericGetDatum(b)));
422  }
423 
424  PG_RETURN_INT32(res);
425 }
#define DatumGetInt32(X)
Definition: postgres.h:472
#define NumericGetDatum(X)
Definition: numeric.h:51
Datum numeric_cmp(PG_FUNCTION_ARGS)
Definition: numeric.c:2046
#define PG_RETURN_INT32(x)
Definition: fmgr.h:344
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:271
struct NumericData * Numeric
Definition: numeric.h:43
#define NUMERIC_IS_LEFTMOST(x)
Definition: btree_gin.c:398
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:619

◆ leftmostvalue_bit()

static Datum leftmostvalue_bit ( void  )
static

Definition at line 369 of file btree_gin.c.

References bit(), bit_in(), bitcmp(), CStringGetDatum, DirectFunctionCall3, GIN_SUPPORT, Int32GetDatum, and ObjectIdGetDatum.

370 {
372  CStringGetDatum(""),
373  ObjectIdGetDatum(0),
374  Int32GetDatum(-1));
375 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Datum bit_in(PG_FUNCTION_ARGS)
Definition: varbit.c:146
#define CStringGetDatum(X)
Definition: postgres.h:578
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:621
#define Int32GetDatum(X)
Definition: postgres.h:479

◆ leftmostvalue_bool()

static Datum leftmostvalue_bool ( void  )
static

Definition at line 510 of file btree_gin.c.

References BoolGetDatum, btboolcmp(), and GIN_SUPPORT.

511 {
512  return BoolGetDatum(false);
513 }
#define BoolGetDatum(X)
Definition: postgres.h:402

◆ leftmostvalue_char()

static Datum leftmostvalue_char ( void  )
static

Definition at line 359 of file btree_gin.c.

References btcharcmp(), byteacmp(), CharGetDatum, GIN_SUPPORT, and leftmostvalue_text().

360 {
361  return CharGetDatum(SCHAR_MIN);
362 }
#define CharGetDatum(X)
Definition: postgres.h:416

◆ leftmostvalue_date()

static Datum leftmostvalue_date ( void  )
static

Definition at line 298 of file btree_gin.c.

References date_cmp(), DateADTGetDatum, DATEVAL_NOBEGIN, and GIN_SUPPORT.

299 {
301 }
#define DateADTGetDatum(X)
Definition: date.h:57
#define DATEVAL_NOBEGIN
Definition: date.h:36

◆ leftmostvalue_enum()

static Datum leftmostvalue_enum ( void  )
static

Definition at line 478 of file btree_gin.c.

References gin_enum_cmp(), GIN_SUPPORT, InvalidOid, and ObjectIdGetDatum.

479 {
481 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define InvalidOid
Definition: postgres_ext.h:36

◆ leftmostvalue_float4()

static Datum leftmostvalue_float4 ( void  )
static

Definition at line 235 of file btree_gin.c.

References btfloat4cmp(), Float4GetDatum(), get_float4_infinity(), and GIN_SUPPORT.

236 {
238 }
Datum Float4GetDatum(float4 X)
Definition: fmgr.c:1711
static float4 get_float4_infinity(void)
Definition: float.h:70

◆ leftmostvalue_float8()

static Datum leftmostvalue_float8 ( void  )
static

Definition at line 243 of file btree_gin.c.

References btfloat8cmp(), Float8GetDatum(), get_float8_infinity(), and GIN_SUPPORT.

244 {
246 }
static float8 get_float8_infinity(void)
Definition: float.h:90
Datum Float8GetDatum(float8 X)
Definition: fmgr.c:1723

◆ leftmostvalue_inet()

static Datum leftmostvalue_inet ( void  )
static

Definition at line 339 of file btree_gin.c.

References CStringGetDatum, DirectFunctionCall1, GIN_SUPPORT, inet_in(), and network_cmp().

340 {
341  return DirectFunctionCall1(inet_in, CStringGetDatum("0.0.0.0/0"));
342 }
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:617
#define CStringGetDatum(X)
Definition: postgres.h:578
Datum inet_in(PG_FUNCTION_ARGS)
Definition: network.c:122

◆ leftmostvalue_int2()

static Datum leftmostvalue_int2 ( void  )
static

Definition at line 211 of file btree_gin.c.

References btint2cmp(), GIN_SUPPORT, and Int16GetDatum.

212 {
213  return Int16GetDatum(SHRT_MIN);
214 }
#define Int16GetDatum(X)
Definition: postgres.h:451

◆ leftmostvalue_int4()

static Datum leftmostvalue_int4 ( void  )
static

Definition at line 219 of file btree_gin.c.

References btint4cmp(), GIN_SUPPORT, and Int32GetDatum.

220 {
221  return Int32GetDatum(INT_MIN);
222 }
#define Int32GetDatum(X)
Definition: postgres.h:479

◆ leftmostvalue_int8()

static Datum leftmostvalue_int8 ( void  )
static

Definition at line 227 of file btree_gin.c.

References btint8cmp(), GIN_SUPPORT, Int64GetDatum(), and PG_INT64_MIN.

228 {
229  return Int64GetDatum(PG_INT64_MIN);
230 }
#define PG_INT64_MIN
Definition: c.h:443
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1699

◆ leftmostvalue_interval()

static Datum leftmostvalue_interval ( void  )
static

Definition at line 306 of file btree_gin.c.

References Interval::day, DT_NOBEGIN, GIN_SUPPORT, interval_cmp(), IntervalPGetDatum, Interval::month, palloc(), and Interval::time.

307 {
308  Interval *v = palloc(sizeof(Interval));
309 
310  v->time = DT_NOBEGIN;
311  v->day = 0;
312  v->month = 0;
313  return IntervalPGetDatum(v);
314 }
int32 day
Definition: timestamp.h:47
#define IntervalPGetDatum(X)
Definition: timestamp.h:33
TimeOffset time
Definition: timestamp.h:45
int32 month
Definition: timestamp.h:48
void * palloc(Size size)
Definition: mcxt.c:949
#define DT_NOBEGIN
Definition: timestamp.h:109

◆ leftmostvalue_macaddr()

static Datum leftmostvalue_macaddr ( void  )
static

Definition at line 319 of file btree_gin.c.

References GIN_SUPPORT, macaddr_cmp(), MacaddrPGetDatum, and palloc0().

320 {
321  macaddr *v = palloc0(sizeof(macaddr));
322 
323  return MacaddrPGetDatum(v);
324 }
#define MacaddrPGetDatum(X)
Definition: inet.h:132
void * palloc0(Size size)
Definition: mcxt.c:980
Definition: inet.h:94

◆ leftmostvalue_macaddr8()

static Datum leftmostvalue_macaddr8 ( void  )
static

Definition at line 329 of file btree_gin.c.

References GIN_SUPPORT, macaddr8_cmp(), Macaddr8PGetDatum, and palloc0().

330 {
331  macaddr8 *v = palloc0(sizeof(macaddr8));
332 
333  return Macaddr8PGetDatum(v);
334 }
Definition: inet.h:107
void * palloc0(Size size)
Definition: mcxt.c:980
#define Macaddr8PGetDatum(X)
Definition: inet.h:138

◆ leftmostvalue_money()

static Datum leftmostvalue_money ( void  )
static

Definition at line 251 of file btree_gin.c.

References cash_cmp(), GIN_SUPPORT, Int64GetDatum(), and PG_INT64_MIN.

252 {
253  return Int64GetDatum(PG_INT64_MIN);
254 }
#define PG_INT64_MIN
Definition: c.h:443
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1699

◆ leftmostvalue_name()

static Datum leftmostvalue_name ( void  )
static

Definition at line 500 of file btree_gin.c.

References btnamecmp(), GIN_SUPPORT, name, NAMEDATALEN, NameGetDatum, and palloc0().

501 {
502  NameData *result = (NameData *) palloc0(NAMEDATALEN);
503 
504  return NameGetDatum(result);
505 }
#define NameGetDatum(X)
Definition: postgres.h:595
#define NAMEDATALEN
Definition: c.h:603
void * palloc0(Size size)
Definition: mcxt.c:980

◆ leftmostvalue_numeric()

static Datum leftmostvalue_numeric ( void  )
static

Definition at line 428 of file btree_gin.c.

References gin_numeric_cmp(), GIN_SUPPORT, and PointerGetDatum.

429 {
430  return PointerGetDatum(NULL);
431 }
#define PointerGetDatum(X)
Definition: postgres.h:556

◆ leftmostvalue_oid()

static Datum leftmostvalue_oid ( void  )
static

Definition at line 259 of file btree_gin.c.

References btoidcmp(), GIN_SUPPORT, and ObjectIdGetDatum.

260 {
261  return ObjectIdGetDatum(0);
262 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:507

◆ leftmostvalue_text()

static Datum leftmostvalue_text ( void  )
static

Definition at line 349 of file btree_gin.c.

References bpchar(), bpcharcmp(), bttextcmp(), cstring_to_text_with_len(), GIN_SUPPORT, and PointerGetDatum.

Referenced by leftmostvalue_char().

350 {
352 }
#define PointerGetDatum(X)
Definition: postgres.h:556
text * cstring_to_text_with_len(const char *s, int len)
Definition: varlena.c:183

◆ leftmostvalue_time()

static Datum leftmostvalue_time ( void  )
static

Definition at line 277 of file btree_gin.c.

References GIN_SUPPORT, time_cmp(), and TimeADTGetDatum.

278 {
279  return TimeADTGetDatum(0);
280 }
#define TimeADTGetDatum(X)
Definition: date.h:58

◆ leftmostvalue_timestamp()

static Datum leftmostvalue_timestamp ( void  )
static

Definition at line 267 of file btree_gin.c.

References DT_NOBEGIN, GIN_SUPPORT, timestamp_cmp(), and TimestampGetDatum.

268 {
270 }
#define TimestampGetDatum(X)
Definition: timestamp.h:31
#define DT_NOBEGIN
Definition: timestamp.h:109

◆ leftmostvalue_timetz()

static Datum leftmostvalue_timetz ( void  )
static

Definition at line 285 of file btree_gin.c.

References GIN_SUPPORT, palloc(), TimeTzADT::time, timetz_cmp(), TimeTzADTPGetDatum, and TimeTzADT::zone.

286 {
287  TimeTzADT *v = palloc(sizeof(TimeTzADT));
288 
289  v->time = 0;
290  v->zone = -24 * 3600; /* XXX is that true? */
291 
292  return TimeTzADTPGetDatum(v);
293 }
TimeADT time
Definition: date.h:29
#define TimeTzADTPGetDatum(X)
Definition: date.h:59
int32 zone
Definition: date.h:30
void * palloc(Size size)
Definition: mcxt.c:949
Definition: date.h:27

◆ leftmostvalue_uuid()

static Datum leftmostvalue_uuid ( void  )
static

Definition at line 486 of file btree_gin.c.

References GIN_SUPPORT, palloc0(), uuid_cmp(), and UUIDPGetDatum.

487 {
488  /*
489  * palloc0 will create the UUID with all zeroes:
490  * "00000000-0000-0000-0000-000000000000"
491  */
492  pg_uuid_t *retval = (pg_uuid_t *) palloc0(sizeof(pg_uuid_t));
493 
494  return UUIDPGetDatum(retval);
495 }
#define UUIDPGetDatum(X)
Definition: uuid.h:26
void * palloc0(Size size)
Definition: mcxt.c:980
Definition: uuid.h:20

◆ leftmostvalue_varbit()

static Datum leftmostvalue_varbit ( void  )
static

Definition at line 380 of file btree_gin.c.

References bitcmp(), CStringGetDatum, DirectFunctionCall3, GIN_SUPPORT, Int32GetDatum, ObjectIdGetDatum, varbit(), and varbit_in().

381 {
383  CStringGetDatum(""),
384  ObjectIdGetDatum(0),
385  Int32GetDatum(-1));
386 }
Datum varbit_in(PG_FUNCTION_ARGS)
Definition: varbit.c:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define CStringGetDatum(X)
Definition: postgres.h:578
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:621
#define Int32GetDatum(X)
Definition: postgres.h:479

◆ PG_FUNCTION_INFO_V1() [1/3]

PG_FUNCTION_INFO_V1 ( gin_btree_consistent  )

◆ PG_FUNCTION_INFO_V1() [2/3]

PG_FUNCTION_INFO_V1 ( gin_numeric_cmp  )

◆ PG_FUNCTION_INFO_V1() [3/3]

PG_FUNCTION_INFO_V1 ( gin_enum_cmp  )

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 20 of file btree_gin.c.