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/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 444 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:55
PG_FUNCTION_INFO_V1(gin_btree_consistent)
static Datum gin_btree_extract_value(FunctionCallInfo fcinfo, bool is_varlena)
Definition: btree_gin.c:32
#define PG_FUNCTION_ARGS
Definition: fmgr.h:163
static Datum gin_btree_compare_prefix(FunctionCallInfo fcinfo)
Definition: btree_gin.c:108

Definition at line 185 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 397 of file btree_gin.c.

Referenced by gin_numeric_cmp().

Typedef Documentation

◆ QueryInfo

Function Documentation

◆ gin_btree_compare_prefix()

static Datum gin_btree_compare_prefix ( FunctionCallInfo  fcinfo)
static

Definition at line 108 of file btree_gin.c.

References BTEqualStrategyNumber, BTGreaterEqualStrategyNumber, BTGreaterStrategyNumber, BTLessEqualStrategyNumber, BTLessStrategyNumber, CallerFInfoFunctionCall2(), cmp(), QueryInfo::datum, DatumGetInt32, elog, ERROR, FunctionCallInfoData::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.

109 {
110  Datum a = PG_GETARG_DATUM(0);
111  Datum b = PG_GETARG_DATUM(1);
112  QueryInfo *data = (QueryInfo *) PG_GETARG_POINTER(3);
113  int32 res,
114  cmp;
115 
117  data->typecmp,
118  fcinfo->flinfo,
120  (data->strategy == BTLessStrategyNumber ||
122  ? data->datum : a,
123  b));
124 
125  switch (data->strategy)
126  {
128  /* If original datum > indexed one then return match */
129  if (cmp > 0)
130  res = 0;
131  else
132  res = 1;
133  break;
135  /* The same except equality */
136  if (cmp >= 0)
137  res = 0;
138  else
139  res = 1;
140  break;
142  if (cmp != 0)
143  res = 1;
144  else
145  res = 0;
146  break;
148  /* If original datum <= indexed one then return match */
149  if (cmp <= 0)
150  res = 0;
151  else
152  res = 1;
153  break;
155  /* If original datum <= indexed one then return match */
156  /* If original datum == indexed one then continue scan */
157  if (cmp < 0)
158  res = 0;
159  else if (cmp == 0)
160  res = -1;
161  else
162  res = 1;
163  break;
164  default:
165  elog(ERROR, "unrecognized strategy number: %d",
166  data->strategy);
167  res = 0;
168  }
169 
170  PG_RETURN_INT32(res);
171 }
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define DatumGetInt32(X)
Definition: postgres.h:457
Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition: fmgr.c:1086
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:238
#define PG_RETURN_INT32(x)
Definition: fmgr.h:319
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:246
#define PG_GET_COLLATION()
Definition: fmgr.h:168
signed int int32
Definition: c.h:313
Datum datum
Definition: btree_gin.c:24
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
StrategyNumber strategy
Definition: btree_gin.c:23
FmgrInfo * flinfo
Definition: fmgr.h:79
#define ERROR
Definition: elog.h:43
Datum(* typecmp)(FunctionCallInfo)
Definition: btree_gin.c:26
uintptr_t Datum
Definition: postgres.h:367
#define elog
Definition: elog.h:219
#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 175 of file btree_gin.c.

References PG_GETARG_POINTER, and PG_RETURN_BOOL.

Referenced by gin_btree_compare_prefix().

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

◆ 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 55 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.

59 {
60  Datum datum = PG_GETARG_DATUM(0);
61  int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
62  StrategyNumber strategy = PG_GETARG_UINT16(2);
63  bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
64  Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
65  Datum *entries = (Datum *) palloc(sizeof(Datum));
66  QueryInfo *data = (QueryInfo *) palloc(sizeof(QueryInfo));
67  bool *ptr_partialmatch;
68 
69  *nentries = 1;
70  ptr_partialmatch = *partialmatch = (bool *) palloc(sizeof(bool));
71  *ptr_partialmatch = false;
72  if (is_varlena)
73  datum = PointerGetDatum(PG_DETOAST_DATUM(datum));
74  data->strategy = strategy;
75  data->datum = datum;
76  data->is_varlena = is_varlena;
77  data->typecmp = typecmp;
78  *extra_data = (Pointer *) palloc(sizeof(Pointer));
79  **extra_data = (Pointer) data;
80 
81  switch (strategy)
82  {
85  entries[0] = leftmostvalue();
86  *ptr_partialmatch = true;
87  break;
90  *ptr_partialmatch = true;
91  /* FALLTHROUGH */
93  entries[0] = datum;
94  break;
95  default:
96  elog(ERROR, "unrecognized strategy number: %d", strategy);
97  }
98 
99  PG_RETURN_POINTER(entries);
100 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:326
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
bool is_varlena
Definition: btree_gin.c:25
#define PointerGetDatum(X)
Definition: postgres.h:541
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:238
uint16 StrategyNumber
Definition: stratnum.h:22
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:246
signed int int32
Definition: c.h:313
Datum datum
Definition: btree_gin.c:24
#define BTLessEqualStrategyNumber
Definition: stratnum.h:30
StrategyNumber strategy
Definition: btree_gin.c:23
char * Pointer
Definition: c.h:302
#define ERROR
Definition: elog.h:43
Datum(* typecmp)(FunctionCallInfo)
Definition: btree_gin.c:26
uintptr_t Datum
Definition: postgres.h:367
#define PG_GETARG_UINT16(n)
Definition: fmgr.h:242
void * palloc(Size size)
Definition: mcxt.c:924
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:210
#define elog
Definition: elog.h:219
#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 32 of file btree_gin.c.

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

33 {
34  Datum datum = PG_GETARG_DATUM(0);
35  int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
36  Datum *entries = (Datum *) palloc(sizeof(Datum));
37 
38  if (is_varlena)
39  datum = PointerGetDatum(PG_DETOAST_DATUM(datum));
40  entries[0] = datum;
41  *nentries = 1;
42 
43  PG_RETURN_POINTER(entries);
44 }
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:326
#define PointerGetDatum(X)
Definition: postgres.h:541
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:238
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:246
signed int int32
Definition: c.h:313
uintptr_t Datum
Definition: postgres.h:367
void * palloc(Size size)
Definition: mcxt.c:924
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:210

◆ gin_enum_cmp()

Datum gin_enum_cmp ( PG_FUNCTION_ARGS  )

Definition at line 449 of file btree_gin.c.

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

Referenced by leftmostvalue_enum().

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

◆ gin_numeric_cmp()

Datum gin_numeric_cmp ( PG_FUNCTION_ARGS  )

Definition at line 402 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().

403 {
406  int res = 0;
407 
408  if (NUMERIC_IS_LEFTMOST(a))
409  {
410  res = (NUMERIC_IS_LEFTMOST(b)) ? 0 : -1;
411  }
412  else if (NUMERIC_IS_LEFTMOST(b))
413  {
414  res = 1;
415  }
416  else
417  {
419  NumericGetDatum(a),
420  NumericGetDatum(b)));
421  }
422 
423  PG_RETURN_INT32(res);
424 }
#define DatumGetInt32(X)
Definition: postgres.h:457
#define NumericGetDatum(X)
Definition: numeric.h:51
Datum numeric_cmp(PG_FUNCTION_ARGS)
Definition: numeric.c:2032
#define PG_RETURN_INT32(x)
Definition: fmgr.h:319
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:246
struct NumericData * Numeric
Definition: numeric.h:43
#define NUMERIC_IS_LEFTMOST(x)
Definition: btree_gin.c:397
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:592

◆ leftmostvalue_bit()

static Datum leftmostvalue_bit ( void  )
static

Definition at line 368 of file btree_gin.c.

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

369 {
371  CStringGetDatum(""),
372  ObjectIdGetDatum(0),
373  Int32GetDatum(-1));
374 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
Datum bit_in(PG_FUNCTION_ARGS)
Definition: varbit.c:114
#define CStringGetDatum(X)
Definition: postgres.h:563
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:594
#define Int32GetDatum(X)
Definition: postgres.h:464

◆ leftmostvalue_bool()

static Datum leftmostvalue_bool ( void  )
static

Definition at line 509 of file btree_gin.c.

References BoolGetDatum, btboolcmp(), and GIN_SUPPORT.

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

◆ leftmostvalue_char()

static Datum leftmostvalue_char ( void  )
static

Definition at line 358 of file btree_gin.c.

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

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

◆ leftmostvalue_date()

static Datum leftmostvalue_date ( void  )
static

Definition at line 297 of file btree_gin.c.

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

298 {
300 }
#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 477 of file btree_gin.c.

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

478 {
480 }
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define InvalidOid
Definition: postgres_ext.h:36

◆ leftmostvalue_float4()

static Datum leftmostvalue_float4 ( void  )
static

Definition at line 234 of file btree_gin.c.

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

235 {
237 }
float get_float4_infinity(void)
Definition: float.c:143
Datum Float4GetDatum(float4 X)
Definition: fmgr.c:1889

◆ leftmostvalue_float8()

static Datum leftmostvalue_float8 ( void  )
static

Definition at line 242 of file btree_gin.c.

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

243 {
245 }
Datum Float8GetDatum(float8 X)
Definition: fmgr.c:1901
double get_float8_infinity(void)
Definition: float.c:118

◆ leftmostvalue_inet()

static Datum leftmostvalue_inet ( void  )
static

Definition at line 338 of file btree_gin.c.

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

339 {
340  return DirectFunctionCall1(inet_in, CStringGetDatum("0.0.0.0/0"));
341 }
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:590
#define CStringGetDatum(X)
Definition: postgres.h:563
Datum inet_in(PG_FUNCTION_ARGS)
Definition: network.c:80

◆ leftmostvalue_int2()

static Datum leftmostvalue_int2 ( void  )
static

Definition at line 210 of file btree_gin.c.

References btint2cmp(), GIN_SUPPORT, and Int16GetDatum.

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

◆ leftmostvalue_int4()

static Datum leftmostvalue_int4 ( void  )
static

Definition at line 218 of file btree_gin.c.

References btint4cmp(), GIN_SUPPORT, and Int32GetDatum.

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

◆ leftmostvalue_int8()

static Datum leftmostvalue_int8 ( void  )
static

Definition at line 226 of file btree_gin.c.

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

227 {
228  return Int64GetDatum(PG_INT64_MIN);
229 }
#define PG_INT64_MIN
Definition: c.h:410
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1877

◆ leftmostvalue_interval()

static Datum leftmostvalue_interval ( void  )
static

Definition at line 305 of file btree_gin.c.

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

306 {
307  Interval *v = palloc(sizeof(Interval));
308 
309  v->time = DT_NOBEGIN;
310  v->day = 0;
311  v->month = 0;
312  return IntervalPGetDatum(v);
313 }
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:924
#define DT_NOBEGIN
Definition: timestamp.h:109

◆ leftmostvalue_macaddr()

static Datum leftmostvalue_macaddr ( void  )
static

Definition at line 318 of file btree_gin.c.

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

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

◆ leftmostvalue_macaddr8()

static Datum leftmostvalue_macaddr8 ( void  )
static

Definition at line 328 of file btree_gin.c.

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

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

◆ leftmostvalue_money()

static Datum leftmostvalue_money ( void  )
static

Definition at line 250 of file btree_gin.c.

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

251 {
252  return Int64GetDatum(PG_INT64_MIN);
253 }
#define PG_INT64_MIN
Definition: c.h:410
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1877

◆ leftmostvalue_name()

static Datum leftmostvalue_name ( void  )
static

Definition at line 499 of file btree_gin.c.

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

500 {
501  NameData *result = (NameData *) palloc0(NAMEDATALEN);
502 
503  return NameGetDatum(result);
504 }
#define NameGetDatum(X)
Definition: postgres.h:580
#define NAMEDATALEN
Definition: c.h:570
void * palloc0(Size size)
Definition: mcxt.c:955

◆ leftmostvalue_numeric()

static Datum leftmostvalue_numeric ( void  )
static

Definition at line 427 of file btree_gin.c.

References gin_numeric_cmp(), GIN_SUPPORT, and PointerGetDatum.

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

◆ leftmostvalue_oid()

static Datum leftmostvalue_oid ( void  )
static

Definition at line 258 of file btree_gin.c.

References btoidcmp(), GIN_SUPPORT, and ObjectIdGetDatum.

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

◆ leftmostvalue_text()

static Datum leftmostvalue_text ( void  )
static

Definition at line 348 of file btree_gin.c.

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

Referenced by leftmostvalue_char().

349 {
351 }
#define PointerGetDatum(X)
Definition: postgres.h:541
text * cstring_to_text_with_len(const char *s, int len)
Definition: varlena.c:161

◆ leftmostvalue_time()

static Datum leftmostvalue_time ( void  )
static

Definition at line 276 of file btree_gin.c.

References GIN_SUPPORT, time_cmp(), and TimeADTGetDatum.

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

◆ leftmostvalue_timestamp()

static Datum leftmostvalue_timestamp ( void  )
static

Definition at line 266 of file btree_gin.c.

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

267 {
269 }
#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 284 of file btree_gin.c.

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

285 {
286  TimeTzADT *v = palloc(sizeof(TimeTzADT));
287 
288  v->time = 0;
289  v->zone = -24 * 3600; /* XXX is that true? */
290 
291  return TimeTzADTPGetDatum(v);
292 }
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:924
Definition: date.h:27

◆ leftmostvalue_uuid()

static Datum leftmostvalue_uuid ( void  )
static

Definition at line 485 of file btree_gin.c.

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

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

◆ leftmostvalue_varbit()

static Datum leftmostvalue_varbit ( void  )
static

Definition at line 379 of file btree_gin.c.

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

380 {
382  CStringGetDatum(""),
383  ObjectIdGetDatum(0),
384  Int32GetDatum(-1));
385 }
Datum varbit_in(PG_FUNCTION_ARGS)
Definition: varbit.c:430
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
#define CStringGetDatum(X)
Definition: postgres.h:563
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:594
#define Int32GetDatum(X)
Definition: postgres.h:464

◆ 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 19 of file btree_gin.c.