Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Functions | Variables

btree_gin.c File Reference

#include "postgres.h"
#include <limits.h>
#include "access/skey.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 dependency graph for btree_gin.c:

Go to the source code of this file.

Data Structures

struct  TypeInfo
struct  QueryInfo

Defines

#define GIN_EXTRACT_VALUE(type)
#define GIN_EXTRACT_QUERY(type)
#define GIN_COMPARE_PREFIX(type)
#define GIN_SUPPORT(type)
#define NUMERIC_IS_LEFTMOST(x)   ((x) == NULL)

Typedefs

typedef struct TypeInfo TypeInfo
typedef struct QueryInfo QueryInfo

Functions

 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_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)

Variables

 PG_MODULE_MAGIC
static TypeInfo TypeInfo_int2 = {false, leftmostvalue_int2, btint2cmp}
static TypeInfo TypeInfo_int4 = {false, leftmostvalue_int4, btint4cmp}
static TypeInfo TypeInfo_int8 = {false, leftmostvalue_int8, btint8cmp}
static TypeInfo TypeInfo_float4 = {false, leftmostvalue_float4, btfloat4cmp}
static TypeInfo TypeInfo_float8 = {false, leftmostvalue_float8, btfloat8cmp}
static TypeInfo TypeInfo_money = {false, leftmostvalue_money, cash_cmp}
static TypeInfo TypeInfo_oid = {false, leftmostvalue_oid, btoidcmp}
static TypeInfo TypeInfo_timestamp = {false, leftmostvalue_timestamp, timestamp_cmp}
static TypeInfo TypeInfo_timestamptz = {false, leftmostvalue_timestamp, timestamp_cmp}
static TypeInfo TypeInfo_time = {false, leftmostvalue_time, time_cmp}
static TypeInfo TypeInfo_timetz = {false, leftmostvalue_timetz, timetz_cmp}
static TypeInfo TypeInfo_date = {false, leftmostvalue_date, date_cmp}
static TypeInfo TypeInfo_interval = {false, leftmostvalue_interval, interval_cmp}
static TypeInfo TypeInfo_macaddr = {false, leftmostvalue_macaddr, macaddr_cmp}
static TypeInfo TypeInfo_inet = {true, leftmostvalue_inet, network_cmp}
static TypeInfo TypeInfo_cidr = {true, leftmostvalue_inet, network_cmp}
static TypeInfo TypeInfo_text = {true, leftmostvalue_text, bttextcmp}
static TypeInfo TypeInfo_char = {false, leftmostvalue_char, btcharcmp}
static TypeInfo TypeInfo_bytea = {true, leftmostvalue_text, byteacmp}
static TypeInfo TypeInfo_bit = {true, leftmostvalue_bit, bitcmp}
static TypeInfo TypeInfo_varbit = {true, leftmostvalue_varbit, bitcmp}
static TypeInfo TypeInfo_numeric = {true, leftmostvalue_numeric, gin_numeric_cmp}

Define Documentation

#define GIN_COMPARE_PREFIX (   type  ) 

Definition at line 110 of file btree_gin.c.

#define GIN_EXTRACT_QUERY (   type  ) 

Definition at line 60 of file btree_gin.c.

#define GIN_EXTRACT_VALUE (   type  ) 
Value:
PG_FUNCTION_INFO_V1(gin_extract_value_##type);                              \
Datum       gin_extract_value_##type(PG_FUNCTION_ARGS);                     \
Datum                                                                       \
gin_extract_value_##type(PG_FUNCTION_ARGS)                                  \
{                                                                           \
    Datum       datum = PG_GETARG_DATUM(0);                                 \
    int32      *nentries = (int32 *) PG_GETARG_POINTER(1);                  \
    Datum      *entries = (Datum *) palloc(sizeof(Datum));                  \
                                                                            \
    if ( TypeInfo_##type.is_varlena )                                       \
        datum = PointerGetDatum(PG_DETOAST_DATUM(datum));                   \
    entries[0] = datum;                                                     \
    *nentries = 1;                                                          \
                                                                            \
    PG_RETURN_POINTER(entries);                                             \
}

Definition at line 33 of file btree_gin.c.

#define GIN_SUPPORT (   type  ) 
Value:

Definition at line 178 of file btree_gin.c.

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

Definition at line 404 of file btree_gin.c.

Referenced by gin_numeric_cmp().


Typedef Documentation

typedef struct QueryInfo QueryInfo
typedef struct TypeInfo TypeInfo

Function Documentation

Datum gin_btree_consistent ( PG_FUNCTION_ARGS   ) 

Definition at line 187 of file btree_gin.c.

References PG_GETARG_POINTER, and PG_RETURN_BOOL.

{
    bool       *recheck = (bool *) PG_GETARG_POINTER(5);

    *recheck = false;
    PG_RETURN_BOOL(true);
}

Datum gin_numeric_cmp ( PG_FUNCTION_ARGS   ) 
static Datum leftmostvalue_bit ( void   )  [static]
static Datum leftmostvalue_char ( void   )  [static]

Definition at line 360 of file btree_gin.c.

References CharGetDatum.

{
    return CharGetDatum(SCHAR_MIN);
}

static Datum leftmostvalue_date ( void   )  [static]

Definition at line 301 of file btree_gin.c.

References DateADTGetDatum, and DATEVAL_NOBEGIN.

static Datum leftmostvalue_float4 ( void   )  [static]

Definition at line 226 of file btree_gin.c.

References Float4GetDatum(), and get_float4_infinity().

static Datum leftmostvalue_float8 ( void   )  [static]

Definition at line 235 of file btree_gin.c.

References Float8GetDatum(), and get_float8_infinity().

static Datum leftmostvalue_inet ( void   )  [static]
static Datum leftmostvalue_int2 ( void   )  [static]

Definition at line 196 of file btree_gin.c.

References Int16GetDatum.

{
    return Int16GetDatum(SHRT_MIN);
}

static Datum leftmostvalue_int4 ( void   )  [static]

Definition at line 205 of file btree_gin.c.

References Int32GetDatum.

{
    return Int32GetDatum(INT_MIN);
}

static Datum leftmostvalue_int8 ( void   )  [static]

Definition at line 214 of file btree_gin.c.

References Int64GetDatum(), and SEQ_MINVALUE.

{
    /*
     * Use sequence's definition to keep compatibility.
     */
    return Int64GetDatum(SEQ_MINVALUE);
}

static Datum leftmostvalue_interval ( void   )  [static]

Definition at line 310 of file btree_gin.c.

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

{
    Interval   *v = palloc(sizeof(Interval));

    v->time = DT_NOBEGIN;
    v->day = 0;
    v->month = 0;
    return IntervalPGetDatum(v);
}

static Datum leftmostvalue_macaddr ( void   )  [static]

Definition at line 324 of file btree_gin.c.

References MacaddrPGetDatum, and palloc0().

{
    macaddr    *v = palloc0(sizeof(macaddr));

    return MacaddrPGetDatum(v);
}

static Datum leftmostvalue_money ( void   )  [static]

Definition at line 244 of file btree_gin.c.

References Int64GetDatum(), and SEQ_MINVALUE.

{
    /*
     * Use sequence's definition to keep compatibility.
     */
    return Int64GetDatum(SEQ_MINVALUE);
}

static Datum leftmostvalue_numeric ( void   )  [static]

Definition at line 435 of file btree_gin.c.

References NULL, and PointerGetDatum.

{
    return PointerGetDatum(NULL);
}

static Datum leftmostvalue_oid ( void   )  [static]

Definition at line 256 of file btree_gin.c.

References ObjectIdGetDatum.

{
    return ObjectIdGetDatum(0);
}

static Datum leftmostvalue_text ( void   )  [static]

Definition at line 351 of file btree_gin.c.

References cstring_to_text_with_len(), and PointerGetDatum.

static Datum leftmostvalue_time ( void   )  [static]

Definition at line 278 of file btree_gin.c.

References TimeADTGetDatum.

{
    return TimeADTGetDatum(0);
}

static Datum leftmostvalue_timestamp ( void   )  [static]

Definition at line 265 of file btree_gin.c.

References DT_NOBEGIN, and TimestampGetDatum.

static Datum leftmostvalue_timetz ( void   )  [static]

Definition at line 287 of file btree_gin.c.

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

{
    TimeTzADT  *v = palloc(sizeof(TimeTzADT));

    v->time = 0;
    v->zone = -24 * 3600;       /* XXX is that true? */

    return TimeTzADTPGetDatum(v);
}

static Datum leftmostvalue_varbit ( void   )  [static]
PG_FUNCTION_INFO_V1 ( gin_numeric_cmp   ) 
PG_FUNCTION_INFO_V1 ( gin_btree_consistent   ) 

Variable Documentation

Definition at line 18 of file btree_gin.c.

TypeInfo TypeInfo_bit = {true, leftmostvalue_bit, bitcmp} [static]

Definition at line 380 of file btree_gin.c.

TypeInfo TypeInfo_bytea = {true, leftmostvalue_text, byteacmp} [static]

Definition at line 368 of file btree_gin.c.

TypeInfo TypeInfo_char = {false, leftmostvalue_char, btcharcmp} [static]

Definition at line 364 of file btree_gin.c.

TypeInfo TypeInfo_cidr = {true, leftmostvalue_inet, network_cmp} [static]

Definition at line 346 of file btree_gin.c.

TypeInfo TypeInfo_date = {false, leftmostvalue_date, date_cmp} [static]

Definition at line 305 of file btree_gin.c.

TypeInfo TypeInfo_float4 = {false, leftmostvalue_float4, btfloat4cmp} [static]

Definition at line 230 of file btree_gin.c.

TypeInfo TypeInfo_float8 = {false, leftmostvalue_float8, btfloat8cmp} [static]

Definition at line 239 of file btree_gin.c.

TypeInfo TypeInfo_inet = {true, leftmostvalue_inet, network_cmp} [static]

Definition at line 342 of file btree_gin.c.

TypeInfo TypeInfo_int2 = {false, leftmostvalue_int2, btint2cmp} [static]

Definition at line 200 of file btree_gin.c.

TypeInfo TypeInfo_int4 = {false, leftmostvalue_int4, btint4cmp} [static]

Definition at line 209 of file btree_gin.c.

TypeInfo TypeInfo_int8 = {false, leftmostvalue_int8, btint8cmp} [static]

Definition at line 221 of file btree_gin.c.

TypeInfo TypeInfo_interval = {false, leftmostvalue_interval, interval_cmp} [static]

Definition at line 319 of file btree_gin.c.

TypeInfo TypeInfo_macaddr = {false, leftmostvalue_macaddr, macaddr_cmp} [static]

Definition at line 330 of file btree_gin.c.

TypeInfo TypeInfo_money = {false, leftmostvalue_money, cash_cmp} [static]

Definition at line 251 of file btree_gin.c.

TypeInfo TypeInfo_numeric = {true, leftmostvalue_numeric, gin_numeric_cmp} [static]

Definition at line 440 of file btree_gin.c.

TypeInfo TypeInfo_oid = {false, leftmostvalue_oid, btoidcmp} [static]

Definition at line 260 of file btree_gin.c.

TypeInfo TypeInfo_text = {true, leftmostvalue_text, bttextcmp} [static]

Definition at line 355 of file btree_gin.c.

TypeInfo TypeInfo_time = {false, leftmostvalue_time, time_cmp} [static]

Definition at line 282 of file btree_gin.c.

TypeInfo TypeInfo_timestamp = {false, leftmostvalue_timestamp, timestamp_cmp} [static]

Definition at line 269 of file btree_gin.c.

TypeInfo TypeInfo_timestamptz = {false, leftmostvalue_timestamp, timestamp_cmp} [static]

Definition at line 273 of file btree_gin.c.

TypeInfo TypeInfo_timetz = {false, leftmostvalue_timetz, timetz_cmp} [static]

Definition at line 296 of file btree_gin.c.

TypeInfo TypeInfo_varbit = {true, leftmostvalue_varbit, bitcmp} [static]

Definition at line 392 of file btree_gin.c.