mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/contrib/btree_gin/btree_gin.c,v 1.1 2009/03/25 23:20:01 tgl Exp $
|
||||
* $PostgreSQL: pgsql/contrib/btree_gin/btree_gin.c,v 1.2 2009/06/11 14:48:50 momjian Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
@ -19,20 +19,20 @@ PG_MODULE_MAGIC;
|
||||
|
||||
typedef struct TypeInfo
|
||||
{
|
||||
bool is_varlena;
|
||||
Datum (*leftmostvalue)(void);
|
||||
Datum (*typecmp)(FunctionCallInfo);
|
||||
bool is_varlena;
|
||||
Datum (*leftmostvalue) (void);
|
||||
Datum (*typecmp) (FunctionCallInfo);
|
||||
} TypeInfo;
|
||||
|
||||
typedef struct QueryInfo
|
||||
{
|
||||
StrategyNumber strategy;
|
||||
Datum datum;
|
||||
StrategyNumber strategy;
|
||||
Datum datum;
|
||||
} QueryInfo;
|
||||
|
||||
#define GIN_EXTRACT_VALUE(type) \
|
||||
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 \
|
||||
gin_extract_value_##type(PG_FUNCTION_ARGS) \
|
||||
{ \
|
||||
@ -59,7 +59,7 @@ gin_extract_value_##type(PG_FUNCTION_ARGS) \
|
||||
|
||||
#define GIN_EXTRACT_QUERY(type) \
|
||||
PG_FUNCTION_INFO_V1(gin_extract_query_##type); \
|
||||
Datum gin_extract_query_##type(PG_FUNCTION_ARGS); \
|
||||
Datum gin_extract_query_##type(PG_FUNCTION_ARGS); \
|
||||
Datum \
|
||||
gin_extract_query_##type(PG_FUNCTION_ARGS) \
|
||||
{ \
|
||||
@ -67,7 +67,7 @@ gin_extract_query_##type(PG_FUNCTION_ARGS) \
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1); \
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(2); \
|
||||
bool **partialmatch = (bool **) PG_GETARG_POINTER(3); \
|
||||
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); \
|
||||
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); \
|
||||
Datum *entries = (Datum *) palloc(sizeof(Datum)); \
|
||||
QueryInfo *data = (QueryInfo *) palloc(sizeof(QueryInfo)); \
|
||||
bool *ptr_partialmatch; \
|
||||
@ -109,7 +109,7 @@ gin_extract_query_##type(PG_FUNCTION_ARGS) \
|
||||
*/
|
||||
#define GIN_COMPARE_PREFIX(type) \
|
||||
PG_FUNCTION_INFO_V1(gin_compare_prefix_##type); \
|
||||
Datum gin_compare_prefix_##type(PG_FUNCTION_ARGS); \
|
||||
Datum gin_compare_prefix_##type(PG_FUNCTION_ARGS); \
|
||||
Datum \
|
||||
gin_compare_prefix_##type(PG_FUNCTION_ARGS) \
|
||||
{ \
|
||||
@ -120,10 +120,10 @@ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \
|
||||
cmp; \
|
||||
\
|
||||
cmp = DatumGetInt32(DirectFunctionCall2( \
|
||||
TypeInfo_##type.typecmp, \
|
||||
(data->strategy == BTLessStrategyNumber || \
|
||||
TypeInfo_##type.typecmp, \
|
||||
(data->strategy == BTLessStrategyNumber || \
|
||||
data->strategy == BTLessEqualStrategyNumber) \
|
||||
? data->datum : a, \
|
||||
? data->datum : a, \
|
||||
b)); \
|
||||
\
|
||||
switch (data->strategy) \
|
||||
@ -166,7 +166,7 @@ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \
|
||||
res = 1; \
|
||||
break; \
|
||||
default: \
|
||||
elog(ERROR, "unrecognized strategy number: %d", \
|
||||
elog(ERROR, "unrecognized strategy number: %d", \
|
||||
data->strategy); \
|
||||
res = 0; \
|
||||
} \
|
||||
@ -181,11 +181,11 @@ gin_compare_prefix_##type(PG_FUNCTION_ARGS) \
|
||||
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_btree_consistent);
|
||||
Datum gin_btree_consistent(PG_FUNCTION_ARGS);
|
||||
Datum gin_btree_consistent(PG_FUNCTION_ARGS);
|
||||
Datum
|
||||
gin_btree_consistent(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool *recheck = (bool *) PG_GETARG_POINTER(5);
|
||||
bool *recheck = (bool *) PG_GETARG_POINTER(5);
|
||||
|
||||
*recheck = false;
|
||||
PG_RETURN_BOOL(true);
|
||||
@ -197,6 +197,7 @@ leftmostvalue_int2(void)
|
||||
return Int16GetDatum(SHRT_MIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_int2 = {false, leftmostvalue_int2, btint2cmp};
|
||||
|
||||
GIN_SUPPORT(int2)
|
||||
|
||||
static Datum
|
||||
@ -205,18 +206,20 @@ leftmostvalue_int4(void)
|
||||
return Int32GetDatum(INT_MIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_int4 = {false, leftmostvalue_int4, btint4cmp};
|
||||
|
||||
GIN_SUPPORT(int4)
|
||||
|
||||
static Datum
|
||||
leftmostvalue_int8(void)
|
||||
{
|
||||
/*
|
||||
* Use sequence's definition to keep compatibility.
|
||||
* Another way may make a problem with INT64_IS_BUSTED
|
||||
* Use sequence's definition to keep compatibility. Another way may make a
|
||||
* problem with INT64_IS_BUSTED
|
||||
*/
|
||||
return Int64GetDatum(SEQ_MINVALUE);
|
||||
}
|
||||
static TypeInfo TypeInfo_int8 = {false, leftmostvalue_int8, btint8cmp};
|
||||
|
||||
GIN_SUPPORT(int8)
|
||||
|
||||
static Datum
|
||||
@ -225,6 +228,7 @@ leftmostvalue_float4(void)
|
||||
return Float4GetDatum(-get_float4_infinity());
|
||||
}
|
||||
static TypeInfo TypeInfo_float4 = {false, leftmostvalue_float4, btfloat4cmp};
|
||||
|
||||
GIN_SUPPORT(float4)
|
||||
|
||||
static Datum
|
||||
@ -233,18 +237,20 @@ leftmostvalue_float8(void)
|
||||
return Float8GetDatum(-get_float8_infinity());
|
||||
}
|
||||
static TypeInfo TypeInfo_float8 = {false, leftmostvalue_float8, btfloat8cmp};
|
||||
|
||||
GIN_SUPPORT(float8)
|
||||
|
||||
static Datum
|
||||
leftmostvalue_money(void)
|
||||
{
|
||||
/*
|
||||
* Use sequence's definition to keep compatibility.
|
||||
* Another way may make a problem with INT64_IS_BUSTED
|
||||
* Use sequence's definition to keep compatibility. Another way may make a
|
||||
* problem with INT64_IS_BUSTED
|
||||
*/
|
||||
return Int64GetDatum(SEQ_MINVALUE);
|
||||
}
|
||||
static TypeInfo TypeInfo_money = {false, leftmostvalue_money, cash_cmp};
|
||||
|
||||
GIN_SUPPORT(money)
|
||||
|
||||
static Datum
|
||||
@ -253,6 +259,7 @@ leftmostvalue_oid(void)
|
||||
return ObjectIdGetDatum(0);
|
||||
}
|
||||
static TypeInfo TypeInfo_oid = {false, leftmostvalue_oid, btoidcmp};
|
||||
|
||||
GIN_SUPPORT(oid)
|
||||
|
||||
static Datum
|
||||
@ -261,9 +268,11 @@ leftmostvalue_timestamp(void)
|
||||
return TimestampGetDatum(DT_NOBEGIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_timestamp = {false, leftmostvalue_timestamp, timestamp_cmp};
|
||||
|
||||
GIN_SUPPORT(timestamp)
|
||||
|
||||
static TypeInfo TypeInfo_timestamptz = {false, leftmostvalue_timestamp, timestamp_cmp};
|
||||
|
||||
GIN_SUPPORT(timestamptz)
|
||||
|
||||
static Datum
|
||||
@ -272,19 +281,21 @@ leftmostvalue_time(void)
|
||||
return TimeADTGetDatum(0);
|
||||
}
|
||||
static TypeInfo TypeInfo_time = {false, leftmostvalue_time, time_cmp};
|
||||
|
||||
GIN_SUPPORT(time)
|
||||
|
||||
static Datum
|
||||
leftmostvalue_timetz(void)
|
||||
{
|
||||
TimeTzADT *v = palloc(sizeof(TimeTzADT));
|
||||
TimeTzADT *v = palloc(sizeof(TimeTzADT));
|
||||
|
||||
v->time = 0;
|
||||
v->zone = -24*3600; /* XXX is that true? */
|
||||
v->zone = -24 * 3600; /* XXX is that true? */
|
||||
|
||||
return TimeTzADTPGetDatum(v);
|
||||
}
|
||||
static TypeInfo TypeInfo_timetz = {false, leftmostvalue_timetz, timetz_cmp};
|
||||
|
||||
GIN_SUPPORT(timetz)
|
||||
|
||||
static Datum
|
||||
@ -293,12 +304,13 @@ leftmostvalue_date(void)
|
||||
return DateADTGetDatum(DATEVAL_NOBEGIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_date = {false, leftmostvalue_date, date_cmp};
|
||||
|
||||
GIN_SUPPORT(date)
|
||||
|
||||
static Datum
|
||||
leftmostvalue_interval(void)
|
||||
{
|
||||
Interval *v = palloc(sizeof(Interval));
|
||||
Interval *v = palloc(sizeof(Interval));
|
||||
|
||||
v->time = DT_NOBEGIN;
|
||||
v->day = 0;
|
||||
@ -306,16 +318,18 @@ leftmostvalue_interval(void)
|
||||
return IntervalPGetDatum(v);
|
||||
}
|
||||
static TypeInfo TypeInfo_interval = {false, leftmostvalue_interval, interval_cmp};
|
||||
|
||||
GIN_SUPPORT(interval)
|
||||
|
||||
static Datum
|
||||
leftmostvalue_macaddr(void)
|
||||
{
|
||||
macaddr *v = palloc0(sizeof(macaddr));
|
||||
macaddr *v = palloc0(sizeof(macaddr));
|
||||
|
||||
return MacaddrPGetDatum(v);
|
||||
}
|
||||
static TypeInfo TypeInfo_macaddr = {false, leftmostvalue_macaddr, macaddr_cmp};
|
||||
|
||||
GIN_SUPPORT(macaddr)
|
||||
|
||||
static Datum
|
||||
@ -327,9 +341,11 @@ leftmostvalue_inet(void)
|
||||
Int32GetDatum(-1));
|
||||
}
|
||||
static TypeInfo TypeInfo_inet = {true, leftmostvalue_inet, network_cmp};
|
||||
|
||||
GIN_SUPPORT(inet)
|
||||
|
||||
static TypeInfo TypeInfo_cidr = {true, leftmostvalue_inet, network_cmp};
|
||||
|
||||
GIN_SUPPORT(cidr)
|
||||
|
||||
static Datum
|
||||
@ -338,6 +354,7 @@ leftmostvalue_text(void)
|
||||
return PointerGetDatum(cstring_to_text_with_len("", 0));
|
||||
}
|
||||
static TypeInfo TypeInfo_text = {true, leftmostvalue_text, bttextcmp};
|
||||
|
||||
GIN_SUPPORT(text)
|
||||
|
||||
static Datum
|
||||
@ -346,9 +363,11 @@ leftmostvalue_char(void)
|
||||
return CharGetDatum(SCHAR_MIN);
|
||||
}
|
||||
static TypeInfo TypeInfo_char = {false, leftmostvalue_char, btcharcmp};
|
||||
|
||||
GIN_SUPPORT(char)
|
||||
|
||||
static TypeInfo TypeInfo_bytea = {true, leftmostvalue_text, byteacmp};
|
||||
|
||||
GIN_SUPPORT(bytea)
|
||||
|
||||
static Datum
|
||||
@ -360,6 +379,7 @@ leftmostvalue_bit(void)
|
||||
Int32GetDatum(-1));
|
||||
}
|
||||
static TypeInfo TypeInfo_bit = {true, leftmostvalue_bit, bitcmp};
|
||||
|
||||
GIN_SUPPORT(bit)
|
||||
|
||||
static Datum
|
||||
@ -371,6 +391,7 @@ leftmostvalue_varbit(void)
|
||||
Int32GetDatum(-1));
|
||||
}
|
||||
static TypeInfo TypeInfo_varbit = {true, leftmostvalue_varbit, bitcmp};
|
||||
|
||||
GIN_SUPPORT(varbit)
|
||||
|
||||
/*
|
||||
@ -383,20 +404,20 @@ GIN_SUPPORT(varbit)
|
||||
#define NUMERIC_IS_LEFTMOST(x) ((x) == NULL)
|
||||
|
||||
PG_FUNCTION_INFO_V1(gin_numeric_cmp);
|
||||
Datum gin_numeric_cmp(PG_FUNCTION_ARGS);
|
||||
Datum gin_numeric_cmp(PG_FUNCTION_ARGS);
|
||||
|
||||
Datum
|
||||
gin_numeric_cmp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Numeric a = (Numeric)PG_GETARG_POINTER(0);
|
||||
Numeric b = (Numeric)PG_GETARG_POINTER(1);
|
||||
int res = 0;
|
||||
Numeric a = (Numeric) PG_GETARG_POINTER(0);
|
||||
Numeric b = (Numeric) PG_GETARG_POINTER(1);
|
||||
int res = 0;
|
||||
|
||||
if ( NUMERIC_IS_LEFTMOST(a) )
|
||||
if (NUMERIC_IS_LEFTMOST(a))
|
||||
{
|
||||
res = ( NUMERIC_IS_LEFTMOST(b) ) ? 0 : -1;
|
||||
res = (NUMERIC_IS_LEFTMOST(b)) ? 0 : -1;
|
||||
}
|
||||
else if ( NUMERIC_IS_LEFTMOST(b) )
|
||||
else if (NUMERIC_IS_LEFTMOST(b))
|
||||
{
|
||||
res = 1;
|
||||
}
|
||||
@ -417,4 +438,5 @@ leftmostvalue_numeric(void)
|
||||
}
|
||||
|
||||
static TypeInfo TypeInfo_numeric = {true, leftmostvalue_numeric, gin_numeric_cmp};
|
||||
|
||||
GIN_SUPPORT(numeric)
|
||||
|
Reference in New Issue
Block a user