mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Standard pgindent run for 8.1.
This commit is contained in:
@ -125,10 +125,10 @@ Datum
|
||||
gbt_cash_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
cashKEY *origentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
|
||||
cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
@ -138,8 +138,8 @@ Datum
|
||||
gbt_cash_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -148,15 +148,15 @@ gbt_date_penalty(PG_FUNCTION_ARGS)
|
||||
|
||||
diff = DatumGetInt32(DirectFunctionCall2(
|
||||
date_mi,
|
||||
DateADTGetDatum(newentry->upper),
|
||||
DateADTGetDatum(origentry->upper)));
|
||||
DateADTGetDatum(newentry->upper),
|
||||
DateADTGetDatum(origentry->upper)));
|
||||
|
||||
res = Max(diff, 0);
|
||||
|
||||
diff = DatumGetInt32(DirectFunctionCall2(
|
||||
date_mi,
|
||||
DateADTGetDatum(origentry->lower),
|
||||
DateADTGetDatum(newentry->lower)));
|
||||
DateADTGetDatum(origentry->lower),
|
||||
DateADTGetDatum(newentry->lower)));
|
||||
|
||||
res += Max(diff, 0);
|
||||
|
||||
@ -166,8 +166,8 @@ gbt_date_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
diff = DatumGetInt32(DirectFunctionCall2(
|
||||
date_mi,
|
||||
DateADTGetDatum(origentry->upper),
|
||||
DateADTGetDatum(origentry->lower)));
|
||||
DateADTGetDatum(origentry->upper),
|
||||
DateADTGetDatum(origentry->lower)));
|
||||
*result += FLT_MIN;
|
||||
*result += (float) (res / ((double) (res + diff)));
|
||||
*result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
|
||||
@ -181,8 +181,8 @@ Datum
|
||||
gbt_date_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ gbt_float4_penalty(PG_FUNCTION_ARGS)
|
||||
float4KEY *newentry = (float4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
@ -137,8 +137,8 @@ Datum
|
||||
gbt_float4_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ gbt_float8_penalty(PG_FUNCTION_ARGS)
|
||||
float8KEY *newentry = (float8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
@ -139,8 +139,8 @@ Datum
|
||||
gbt_float8_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -194,8 +194,8 @@ gbt_inet_penalty(PG_FUNCTION_ARGS)
|
||||
inetKEY *newentry = (inetKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
}
|
||||
@ -204,8 +204,8 @@ Datum
|
||||
gbt_inet_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -128,10 +128,10 @@ Datum
|
||||
gbt_int2_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int16KEY *origentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
|
||||
int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
@ -140,8 +140,8 @@ Datum
|
||||
gbt_int2_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -126,10 +126,10 @@ Datum
|
||||
gbt_int4_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int32KEY *origentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
|
||||
int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
@ -138,8 +138,8 @@ Datum
|
||||
gbt_int4_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -125,11 +125,11 @@ Datum
|
||||
gbt_int8_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int64KEY *origentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
|
||||
int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
@ -137,8 +137,8 @@ Datum
|
||||
gbt_int8_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ gbt_intvkey_cmp(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetInt32(
|
||||
DirectFunctionCall2(interval_cmp,
|
||||
IntervalPGetDatum(((Nsrt *) a)->t),
|
||||
IntervalPGetDatum(((Nsrt *) b)->t)
|
||||
IntervalPGetDatum(((Nsrt *) a)->t),
|
||||
IntervalPGetDatum(((Nsrt *) b)->t)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -78,7 +78,7 @@ intr2num(const Interval *i)
|
||||
|
||||
/*
|
||||
* INTERVALSIZE should be the actual size-on-disk of an Interval, as shown
|
||||
* in pg_type. This might be less than sizeof(Interval) if the compiler
|
||||
* in pg_type. This might be less than sizeof(Interval) if the compiler
|
||||
* insists on adding alignment padding at the end of the struct.
|
||||
*/
|
||||
#define INTERVALSIZE 16
|
||||
@ -202,7 +202,7 @@ gbt_intv_penalty(PG_FUNCTION_ARGS)
|
||||
inew[0] = intr2num(&newentry->lower);
|
||||
inew[1] = intr2num(&newentry->upper);
|
||||
|
||||
penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
|
||||
penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
@ -212,8 +212,8 @@ Datum
|
||||
gbt_intv_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ gbt_macadkey_cmp(const void *a, const void *b)
|
||||
return DatumGetInt32(
|
||||
DirectFunctionCall2(
|
||||
macaddr_cmp,
|
||||
PointerGetDatum(&((Nsrt *) a)->t[0]),
|
||||
PointerGetDatum(&((Nsrt *) b)->t[0])
|
||||
PointerGetDatum(&((Nsrt *) a)->t[0]),
|
||||
PointerGetDatum(&((Nsrt *) b)->t[0])
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -157,7 +157,7 @@ gbt_macad_penalty(PG_FUNCTION_ARGS)
|
||||
inew[0] = mac_2_uint64(&newentry->lower);
|
||||
inew[1] = mac_2_uint64(&newentry->upper);
|
||||
|
||||
penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
|
||||
penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
@ -167,8 +167,8 @@ Datum
|
||||
gbt_macad_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ gbt_oid_penalty(PG_FUNCTION_ARGS)
|
||||
oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
|
||||
penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
@ -138,8 +138,8 @@ Datum
|
||||
gbt_oid_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ gbt_text_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
||||
|
||||
if ( tinfo.eml == 0 )
|
||||
if (tinfo.eml == 0)
|
||||
{
|
||||
tinfo.eml = pg_database_encoding_max_length();
|
||||
}
|
||||
@ -102,7 +102,7 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS)
|
||||
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
||||
GISTENTRY *retval;
|
||||
|
||||
if ( tinfo.eml == 0 )
|
||||
if (tinfo.eml == 0)
|
||||
{
|
||||
tinfo.eml = pg_database_encoding_max_length();
|
||||
}
|
||||
@ -111,7 +111,7 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
||||
Datum d = DirectFunctionCall1(rtrim1, entry->key);
|
||||
GISTENTRY trim;
|
||||
GISTENTRY trim;
|
||||
|
||||
gistentryinit(trim, d,
|
||||
entry->rel, entry->page,
|
||||
@ -136,7 +136,7 @@ gbt_text_consistent(PG_FUNCTION_ARGS)
|
||||
bool retval = FALSE;
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(key);
|
||||
|
||||
if ( tinfo.eml == 0 )
|
||||
if (tinfo.eml == 0)
|
||||
{
|
||||
tinfo.eml = pg_database_encoding_max_length();
|
||||
}
|
||||
@ -158,7 +158,7 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS)
|
||||
bool retval;
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(key);
|
||||
|
||||
if ( tinfo.eml == 0 )
|
||||
if (tinfo.eml == 0)
|
||||
{
|
||||
tinfo.eml = pg_database_encoding_max_length();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ static bool
|
||||
gbt_timegt(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(time_gt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(time_gt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ static bool
|
||||
gbt_timege(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(time_ge, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(time_ge, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ static bool
|
||||
gbt_timeeq(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(time_eq, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(time_eq, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ static bool
|
||||
gbt_timele(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(time_le, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(time_le, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ static bool
|
||||
gbt_timelt(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(time_lt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(time_lt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -212,15 +212,15 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
|
||||
|
||||
intr = DatumGetIntervalP(DirectFunctionCall2(
|
||||
time_mi_time,
|
||||
P_TimeADTGetDatum(newentry->upper),
|
||||
P_TimeADTGetDatum(origentry->upper)));
|
||||
P_TimeADTGetDatum(newentry->upper),
|
||||
P_TimeADTGetDatum(origentry->upper)));
|
||||
res = INTERVAL_TO_SEC(intr);
|
||||
res = Max(res, 0);
|
||||
|
||||
intr = DatumGetIntervalP(DirectFunctionCall2(
|
||||
time_mi_time,
|
||||
P_TimeADTGetDatum(origentry->lower),
|
||||
P_TimeADTGetDatum(newentry->lower)));
|
||||
P_TimeADTGetDatum(origentry->lower),
|
||||
P_TimeADTGetDatum(newentry->lower)));
|
||||
res2 = INTERVAL_TO_SEC(intr);
|
||||
res2 = Max(res2, 0);
|
||||
|
||||
@ -232,8 +232,8 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
|
||||
{
|
||||
intr = DatumGetIntervalP(DirectFunctionCall2(
|
||||
time_mi_time,
|
||||
P_TimeADTGetDatum(origentry->upper),
|
||||
P_TimeADTGetDatum(origentry->lower)));
|
||||
P_TimeADTGetDatum(origentry->upper),
|
||||
P_TimeADTGetDatum(origentry->lower)));
|
||||
*result += FLT_MIN;
|
||||
*result += (float) (res / (res + INTERVAL_TO_SEC(intr)));
|
||||
*result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1));
|
||||
@ -247,8 +247,8 @@ Datum
|
||||
gbt_time_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ Datum gbt_ts_penalty(PG_FUNCTION_ARGS);
|
||||
Datum gbt_ts_same(PG_FUNCTION_ARGS);
|
||||
|
||||
|
||||
#define P_TimestampGetDatum(x) PointerGetDatum( &(x) )
|
||||
#define P_TimestampGetDatum(x) PointerGetDatum( &(x) )
|
||||
|
||||
static bool
|
||||
gbt_tsgt(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(timestamp_gt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(timestamp_gt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ static bool
|
||||
gbt_tsge(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(timestamp_ge, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(timestamp_ge, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ static bool
|
||||
gbt_tseq(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(timestamp_eq, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(timestamp_eq, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ static bool
|
||||
gbt_tsle(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(timestamp_le, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(timestamp_le, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ static bool
|
||||
gbt_tslt(const void *a, const void *b)
|
||||
{
|
||||
return DatumGetBool(
|
||||
DirectFunctionCall2(timestamp_lt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
DirectFunctionCall2(timestamp_lt, PointerGetDatum(a), PointerGetDatum(b))
|
||||
);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ tstz_to_ts_gmt(Timestamp *gmt, TimestampTz *ts)
|
||||
*gmt = *ts;
|
||||
DecodeSpecial(0, "gmt", &val);
|
||||
|
||||
if ( *ts < DT_NOEND && *ts > DT_NOBEGIN )
|
||||
if (*ts < DT_NOEND && *ts > DT_NOBEGIN)
|
||||
{
|
||||
tz = val * 60;
|
||||
|
||||
@ -217,10 +217,10 @@ gbt_ts_union(PG_FUNCTION_ARGS)
|
||||
|
||||
|
||||
#define penalty_check_max_float(val) do { \
|
||||
if ( val > FLT_MAX ) \
|
||||
val = FLT_MAX; \
|
||||
if ( val < -FLT_MAX ) \
|
||||
val = -FLT_MAX; \
|
||||
if ( val > FLT_MAX ) \
|
||||
val = FLT_MAX; \
|
||||
if ( val < -FLT_MAX ) \
|
||||
val = -FLT_MAX; \
|
||||
} while(false);
|
||||
|
||||
|
||||
@ -232,24 +232,24 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
|
||||
tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *result = (float *) PG_GETARG_POINTER(2);
|
||||
|
||||
double orgdbl[2],
|
||||
newdbl[2];
|
||||
double orgdbl[2],
|
||||
newdbl[2];
|
||||
|
||||
/*
|
||||
We are allways using "double" timestamps here.
|
||||
Precision should be good enough.
|
||||
*/
|
||||
orgdbl[0] = ( (double) origentry->lower ) ;
|
||||
orgdbl[1] = ( (double) origentry->upper ) ;
|
||||
newdbl[0] = ( (double) newentry->lower ) ;
|
||||
newdbl[1] = ( (double) newentry->upper ) ;
|
||||
* We are allways using "double" timestamps here. Precision should be good
|
||||
* enough.
|
||||
*/
|
||||
orgdbl[0] = ((double) origentry->lower);
|
||||
orgdbl[1] = ((double) origentry->upper);
|
||||
newdbl[0] = ((double) newentry->lower);
|
||||
newdbl[1] = ((double) newentry->upper);
|
||||
|
||||
penalty_check_max_float( orgdbl[0] );
|
||||
penalty_check_max_float( orgdbl[1] );
|
||||
penalty_check_max_float( newdbl[0] );
|
||||
penalty_check_max_float( newdbl[1] );
|
||||
penalty_check_max_float(orgdbl[0]);
|
||||
penalty_check_max_float(orgdbl[1]);
|
||||
penalty_check_max_float(newdbl[0]);
|
||||
penalty_check_max_float(newdbl[1]);
|
||||
|
||||
penalty_num(result,orgdbl[0],orgdbl[1],newdbl[0],newdbl[1]);
|
||||
penalty_num(result, orgdbl[0], orgdbl[1], newdbl[0], newdbl[1]);
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
|
||||
@ -260,8 +260,8 @@ Datum
|
||||
gbt_ts_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_POINTER(gbt_num_picksplit(
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
(GistEntryVector *) PG_GETARG_POINTER(0),
|
||||
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
|
||||
&tinfo
|
||||
));
|
||||
}
|
||||
|
@ -48,17 +48,17 @@ typedef struct
|
||||
* Note: The factor 0.49 in following macro avoids floating point overflows
|
||||
*/
|
||||
#define penalty_num(result,olower,oupper,nlower,nupper) do { \
|
||||
double tmp = 0.0F; \
|
||||
(*(result)) = 0.0F; \
|
||||
double tmp = 0.0F; \
|
||||
(*(result)) = 0.0F; \
|
||||
if ( (nupper) > (oupper) ) \
|
||||
tmp += ( ((double)nupper)*0.49F - ((double)oupper)*0.49F ); \
|
||||
if ( (olower) > (nlower) ) \
|
||||
tmp += ( ((double)olower)*0.49F - ((double)nlower)*0.49F ); \
|
||||
if (tmp > 0.0F) \
|
||||
{ \
|
||||
(*(result)) += FLT_MIN; \
|
||||
(*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \
|
||||
(*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \
|
||||
(*(result)) += FLT_MIN; \
|
||||
(*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \
|
||||
(*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include "utils/builtins.h"
|
||||
|
||||
PG_FUNCTION_INFO_V1(gbt_var_decompress);
|
||||
Datum gbt_var_decompress(PG_FUNCTION_ARGS);
|
||||
Datum gbt_var_decompress(PG_FUNCTION_ARGS);
|
||||
|
||||
|
||||
Datum
|
||||
gbt_var_decompress(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
||||
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
|
||||
GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
|
||||
|
||||
if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
|
||||
{
|
||||
@ -92,45 +92,47 @@ static int32
|
||||
gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo)
|
||||
{
|
||||
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(node);
|
||||
int32 i = 0;
|
||||
int32 l = 0;
|
||||
int32 t1len = VARSIZE(r.lower) - VARHDRSZ ;
|
||||
int32 t2len = VARSIZE(r.upper) - VARHDRSZ ;
|
||||
int32 ml = Min(t1len, t2len);
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(node);
|
||||
int32 i = 0;
|
||||
int32 l = 0;
|
||||
int32 t1len = VARSIZE(r.lower) - VARHDRSZ;
|
||||
int32 t2len = VARSIZE(r.upper) - VARHDRSZ;
|
||||
int32 ml = Min(t1len, t2len);
|
||||
|
||||
char *p1 = VARDATA(r.lower);
|
||||
char *p2 = VARDATA(r.upper);
|
||||
char *p1 = VARDATA(r.lower);
|
||||
char *p2 = VARDATA(r.upper);
|
||||
|
||||
if ( ml == 0 )
|
||||
return 0;
|
||||
if (ml == 0)
|
||||
return 0;
|
||||
|
||||
while ( i < ml )
|
||||
while (i < ml)
|
||||
{
|
||||
if ( tinfo->eml > 1 && l == 0 )
|
||||
{
|
||||
if (tinfo->eml > 1 && l == 0)
|
||||
{
|
||||
|
||||
if ( ( l = pg_mblen(p1) ) != pg_mblen(p2) )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (*p1 != *p2)
|
||||
{
|
||||
if( tinfo->eml > 1 )
|
||||
{
|
||||
return (i-l+1);
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if ((l = pg_mblen(p1)) != pg_mblen(p2))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (*p1 != *p2)
|
||||
{
|
||||
if (tinfo->eml > 1)
|
||||
{
|
||||
return (i - l + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
p1++;
|
||||
p2++;
|
||||
l--;
|
||||
i++;
|
||||
p1++;
|
||||
p2++;
|
||||
l--;
|
||||
i++;
|
||||
}
|
||||
return (ml); /* lower == upper */
|
||||
return (ml); /* lower == upper */
|
||||
}
|
||||
|
||||
|
||||
@ -141,35 +143,37 @@ static bool
|
||||
gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tinfo)
|
||||
{
|
||||
|
||||
bool out = FALSE;
|
||||
int32 k = 0;
|
||||
int32 qlen = VARSIZE(query) - VARHDRSZ ;
|
||||
int32 nlen = VARSIZE(pf) - VARHDRSZ ;
|
||||
bool out = FALSE;
|
||||
int32 k = 0;
|
||||
int32 qlen = VARSIZE(query) - VARHDRSZ;
|
||||
int32 nlen = VARSIZE(pf) - VARHDRSZ;
|
||||
|
||||
if (nlen <= qlen)
|
||||
{
|
||||
char *q = VARDATA(query);
|
||||
char *n = VARDATA(pf);
|
||||
char *q = VARDATA(query);
|
||||
char *n = VARDATA(pf);
|
||||
|
||||
if ( tinfo->eml > 1 )
|
||||
{
|
||||
out = ( varstr_cmp(q, nlen, n, nlen) == 0 );
|
||||
} else {
|
||||
out = TRUE;
|
||||
for (k = 0; k < nlen; k++)
|
||||
{
|
||||
if (*n != *q)
|
||||
{
|
||||
out = FALSE;
|
||||
break;
|
||||
}
|
||||
if (k < (nlen - 1))
|
||||
{
|
||||
q++;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tinfo->eml > 1)
|
||||
{
|
||||
out = (varstr_cmp(q, nlen, n, nlen) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
out = TRUE;
|
||||
for (k = 0; k < nlen; k++)
|
||||
{
|
||||
if (*n != *q)
|
||||
{
|
||||
out = FALSE;
|
||||
break;
|
||||
}
|
||||
if (k < (nlen - 1))
|
||||
{
|
||||
q++;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
@ -184,10 +188,10 @@ static bool
|
||||
gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtree_vinfo * tinfo)
|
||||
{
|
||||
|
||||
return ( tinfo->trnc && (
|
||||
gbt_bytea_pf_match(node->lower, query, tinfo) ||
|
||||
gbt_bytea_pf_match(node->upper, query, tinfo)
|
||||
) );
|
||||
return (tinfo->trnc && (
|
||||
gbt_bytea_pf_match(node->lower, query, tinfo) ||
|
||||
gbt_bytea_pf_match(node->upper, query, tinfo)
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
@ -201,18 +205,18 @@ gbt_var_node_truncate(const GBT_VARKEY * node, int32 cpf_length, const gbtree_vi
|
||||
{
|
||||
GBT_VARKEY *out = NULL;
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(node);
|
||||
int32 len1 = VARSIZE(r.lower) - VARHDRSZ;
|
||||
int32 len2 = VARSIZE(r.upper) - VARHDRSZ;
|
||||
int32 si = 0;
|
||||
int32 len1 = VARSIZE(r.lower) - VARHDRSZ;
|
||||
int32 len2 = VARSIZE(r.upper) - VARHDRSZ;
|
||||
int32 si = 0;
|
||||
|
||||
len1 = Min(len1,(cpf_length + 1));
|
||||
len2 = Min(len2,(cpf_length + 1));
|
||||
len1 = Min(len1, (cpf_length + 1));
|
||||
len2 = Min(len2, (cpf_length + 1));
|
||||
|
||||
si = 2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2;
|
||||
out = (GBT_VARKEY *) palloc(si);
|
||||
out->vl_len = si;
|
||||
memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ );
|
||||
memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ );
|
||||
memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ);
|
||||
memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ);
|
||||
|
||||
*((int32 *) &(((char *) out)[VARHDRSZ])) = len1 + VARHDRSZ;
|
||||
*((int32 *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)])) = len2 + VARHDRSZ;
|
||||
@ -568,8 +572,8 @@ gbt_var_consistent(
|
||||
else
|
||||
retval = (
|
||||
(
|
||||
(*tinfo->f_cmp) (key->lower, (bytea *) query) <= 0 &&
|
||||
(*tinfo->f_cmp) ((bytea *) query, (void *) key->upper) <= 0
|
||||
(*tinfo->f_cmp) (key->lower, (bytea *) query) <= 0 &&
|
||||
(*tinfo->f_cmp) ((bytea *) query, (void *) key->upper) <= 0
|
||||
) || gbt_var_node_pf_match(key, query, tinfo)
|
||||
);
|
||||
break;
|
||||
|
@ -28,7 +28,8 @@ typedef struct
|
||||
/* Attribs */
|
||||
|
||||
enum gbtree_type t; /* data type */
|
||||
int32 eml; /* cached pg_database_encoding_max_length (0: undefined) */
|
||||
int32 eml; /* cached pg_database_encoding_max_length (0:
|
||||
* undefined) */
|
||||
bool trnc; /* truncate (=compress) key */
|
||||
|
||||
/* Methods */
|
||||
|
Reference in New Issue
Block a user