Commit cdaa45fd authored by Bruce Momjian's avatar Bruce Momjian

Run pgindent on range type files, per request from Tom.

parent 5b5985e6
...@@ -654,9 +654,9 @@ RemoveTypeById(Oid typeOid) ...@@ -654,9 +654,9 @@ RemoveTypeById(Oid typeOid)
EnumValuesDelete(typeOid); EnumValuesDelete(typeOid);
/* /*
* If it is a range type, delete the pg_range entries too; we * If it is a range type, delete the pg_range entries too; we don't bother
* don't bother with making dependency entries for those, so it * with making dependency entries for those, so it has to be done "by
* has to be done "by hand" here. * hand" here.
*/ */
if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_RANGE) if (((Form_pg_type) GETSTRUCT(tup))->typtype == TYPTYPE_RANGE)
RangeDelete(typeOid); RangeDelete(typeOid);
...@@ -744,7 +744,8 @@ DefineDomain(CreateDomainStmt *stmt) ...@@ -744,7 +744,8 @@ DefineDomain(CreateDomainStmt *stmt)
/* /*
* Base type must be a plain base type, another domain, an enum or a range * Base type must be a plain base type, another domain, an enum or a range
* type. Domains over pseudotypes would create a security hole. Domains * type. Domains over pseudotypes would create a security hole. Domains
* over composite types might be made to work in the future, but not today. * over composite types might be made to work in the future, but not
* today.
*/ */
typtype = baseType->typtype; typtype = baseType->typtype;
if (typtype != TYPTYPE_BASE && if (typtype != TYPTYPE_BASE &&
...@@ -1158,7 +1159,7 @@ DefineEnum(CreateEnumStmt *stmt) ...@@ -1158,7 +1159,7 @@ DefineEnum(CreateEnumStmt *stmt)
* Registers a new range type. * Registers a new range type.
*/ */
void void
DefineRange(CreateRangeStmt *stmt) DefineRange(CreateRangeStmt * stmt)
{ {
char *typeName; char *typeName;
char *rangeArrayName; char *rangeArrayName;
...@@ -1432,7 +1433,7 @@ makeRangeConstructor(char *name, Oid namespace, Oid rangeOid, Oid subtype) ...@@ -1432,7 +1433,7 @@ makeRangeConstructor(char *name, Oid namespace, Oid rangeOid, Oid subtype)
oidvector *constructorArgTypesVector; oidvector *constructorArgTypesVector;
ObjectAddress myself; ObjectAddress myself;
Oid procOid; Oid procOid;
char *prosrc[4] = { "range_constructor0", char *prosrc[4] = {"range_constructor0",
"range_constructor1", "range_constructor1",
"range_constructor2", "range_constructor2",
"range_constructor3"}; "range_constructor3"};
...@@ -2549,6 +2550,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin) ...@@ -2549,6 +2550,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin)
FreeExecutorState(estate); FreeExecutorState(estate);
} }
/* /*
* get_rels_with_domain * get_rels_with_domain
* *
......
...@@ -59,8 +59,8 @@ static char *range_parse_bound(char *string, char *ptr, char **bound_str, ...@@ -59,8 +59,8 @@ static char *range_parse_bound(char *string, char *ptr, char **bound_str,
bool *infinite); bool *infinite);
static char *range_deparse(char flags, char *lbound_str, char *ubound_str); static char *range_deparse(char flags, char *lbound_str, char *ubound_str);
static char *range_bound_escape(char *in_str); static char *range_bound_escape(char *in_str);
static bool range_contains_internal(FunctionCallInfo fcinfo, RangeType *r1, static bool range_contains_internal(FunctionCallInfo fcinfo, RangeType * r1,
RangeType *r2); RangeType * r2);
static Size datum_compute_size(Size sz, Datum datum, bool typbyval, static Size datum_compute_size(Size sz, Datum datum, bool typbyval,
char typalign, int16 typlen, char typstorage); char typalign, int16 typlen, char typstorage);
static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval, static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval,
...@@ -259,8 +259,8 @@ range_recv(PG_FUNCTION_ARGS) ...@@ -259,8 +259,8 @@ range_recv(PG_FUNCTION_ARGS)
range = make_range(fcinfo, &lower, &upper, flags & RANGE_EMPTY); range = make_range(fcinfo, &lower, &upper, flags & RANGE_EMPTY);
/* /*
* XXX if the subtype is pass-by-val, we should pfree the upper and * XXX if the subtype is pass-by-val, we should pfree the upper and lower
* lower bounds here. * bounds here.
*/ */
PG_RETURN_RANGE(range); PG_RETURN_RANGE(range);
...@@ -401,13 +401,13 @@ range_constructor2(PG_FUNCTION_ARGS) ...@@ -401,13 +401,13 @@ range_constructor2(PG_FUNCTION_ARGS)
flags = range_parse_flags(RANGE_DEFAULT_FLAGS); flags = range_parse_flags(RANGE_DEFAULT_FLAGS);
lower.rngtypid = rngtypid; lower.rngtypid = rngtypid;
lower.val = PG_ARGISNULL(0) ? (Datum)0 : arg1; lower.val = PG_ARGISNULL(0) ? (Datum) 0 : arg1;
lower.inclusive = flags & RANGE_LB_INC; lower.inclusive = flags & RANGE_LB_INC;
lower.infinite = PG_ARGISNULL(0); lower.infinite = PG_ARGISNULL(0);
lower.lower = true; lower.lower = true;
upper.rngtypid = rngtypid; upper.rngtypid = rngtypid;
upper.val = PG_ARGISNULL(1) ? (Datum)0 : arg2; upper.val = PG_ARGISNULL(1) ? (Datum) 0 : arg2;
upper.inclusive = flags & RANGE_UB_INC; upper.inclusive = flags & RANGE_UB_INC;
upper.infinite = PG_ARGISNULL(1); upper.infinite = PG_ARGISNULL(1);
upper.lower = false; upper.lower = false;
...@@ -435,13 +435,13 @@ range_constructor3(PG_FUNCTION_ARGS) ...@@ -435,13 +435,13 @@ range_constructor3(PG_FUNCTION_ARGS)
flags = range_parse_flags(text_to_cstring(PG_GETARG_TEXT_P(2))); flags = range_parse_flags(text_to_cstring(PG_GETARG_TEXT_P(2)));
lower.rngtypid = rngtypid; lower.rngtypid = rngtypid;
lower.val = PG_ARGISNULL(0) ? (Datum)0 : arg1; lower.val = PG_ARGISNULL(0) ? (Datum) 0 : arg1;
lower.inclusive = flags & RANGE_LB_INC; lower.inclusive = flags & RANGE_LB_INC;
lower.infinite = PG_ARGISNULL(0); lower.infinite = PG_ARGISNULL(0);
lower.lower = true; lower.lower = true;
upper.rngtypid = rngtypid; upper.rngtypid = rngtypid;
upper.val = PG_ARGISNULL(1) ? (Datum)0 : arg2; upper.val = PG_ARGISNULL(1) ? (Datum) 0 : arg2;
upper.inclusive = flags & RANGE_UB_INC; upper.inclusive = flags & RANGE_UB_INC;
upper.infinite = PG_ARGISNULL(1); upper.infinite = PG_ARGISNULL(1);
upper.lower = false; upper.lower = false;
...@@ -571,9 +571,12 @@ range_eq(PG_FUNCTION_ARGS) ...@@ -571,9 +571,12 @@ range_eq(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -612,8 +615,10 @@ range_contains_elem(PG_FUNCTION_ARGS) ...@@ -612,8 +615,10 @@ range_contains_elem(PG_FUNCTION_ARGS)
RangeType *r2; RangeType *r2;
Datum val = PG_GETARG_DATUM(1); Datum val = PG_GETARG_DATUM(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
RangeBound upper1,
upper2;
bool empty1; bool empty1;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
...@@ -651,8 +656,10 @@ elem_contained_by_range(PG_FUNCTION_ARGS) ...@@ -651,8 +656,10 @@ elem_contained_by_range(PG_FUNCTION_ARGS)
RangeType *r2; RangeType *r2;
Datum val = PG_GETARG_DATUM(0); Datum val = PG_GETARG_DATUM(0);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
RangeBound upper1,
upper2;
bool empty1; bool empty1;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
...@@ -689,9 +696,12 @@ range_before(PG_FUNCTION_ARGS) ...@@ -689,9 +696,12 @@ range_before(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -718,9 +728,12 @@ range_after(PG_FUNCTION_ARGS) ...@@ -718,9 +728,12 @@ range_after(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -741,16 +754,20 @@ range_after(PG_FUNCTION_ARGS) ...@@ -741,16 +754,20 @@ range_after(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
} }
Datum range_adjacent(PG_FUNCTION_ARGS) Datum
range_adjacent(PG_FUNCTION_ARGS)
{ {
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeTypeInfo rngtypinfo; RangeTypeInfo rngtypinfo;
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -766,12 +783,12 @@ Datum range_adjacent(PG_FUNCTION_ARGS) ...@@ -766,12 +783,12 @@ Datum range_adjacent(PG_FUNCTION_ARGS)
errmsg("undefined for empty ranges"))); errmsg("undefined for empty ranges")));
/* /*
* For two ranges to be adjacent, the lower boundary of one range * For two ranges to be adjacent, the lower boundary of one range has to
* has to match the upper boundary of the other. However, the * match the upper boundary of the other. However, the inclusivity of
* inclusivity of those two boundaries must also be different. * those two boundaries must also be different.
* *
* The semantics for range_cmp_bounds aren't quite what we need * The semantics for range_cmp_bounds aren't quite what we need here, so
* here, so we do the comparison more directly. * we do the comparison more directly.
*/ */
range_gettypinfo(fcinfo, lower1.rngtypid, &rngtypinfo); range_gettypinfo(fcinfo, lower1.rngtypid, &rngtypinfo);
...@@ -801,9 +818,12 @@ range_overlaps(PG_FUNCTION_ARGS) ...@@ -801,9 +818,12 @@ range_overlaps(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -833,9 +853,12 @@ range_overleft(PG_FUNCTION_ARGS) ...@@ -833,9 +853,12 @@ range_overleft(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -860,9 +883,12 @@ range_overright(PG_FUNCTION_ARGS) ...@@ -860,9 +883,12 @@ range_overright(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -889,11 +915,17 @@ range_minus(PG_FUNCTION_ARGS) ...@@ -889,11 +915,17 @@ range_minus(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
int cmp_l1l2, cmp_l1u2, cmp_u1l2, cmp_u1u2; int cmp_l1l2,
cmp_l1u2,
cmp_u1l2,
cmp_u1u2;
range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1); range_deserialize(fcinfo, r1, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2); range_deserialize(fcinfo, r2, &lower2, &upper2, &empty2);
...@@ -946,9 +978,12 @@ range_union(PG_FUNCTION_ARGS) ...@@ -946,9 +978,12 @@ range_union(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
RangeBound *result_lower; RangeBound *result_lower;
RangeBound *result_upper; RangeBound *result_upper;
...@@ -985,9 +1020,12 @@ range_intersect(PG_FUNCTION_ARGS) ...@@ -985,9 +1020,12 @@ range_intersect(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
RangeBound *result_lower; RangeBound *result_lower;
RangeBound *result_upper; RangeBound *result_upper;
...@@ -1018,9 +1056,12 @@ range_cmp(PG_FUNCTION_ARGS) ...@@ -1018,9 +1056,12 @@ range_cmp(PG_FUNCTION_ARGS)
RangeType *r1 = PG_GETARG_RANGE(0); RangeType *r1 = PG_GETARG_RANGE(0);
RangeType *r2 = PG_GETARG_RANGE(1); RangeType *r2 = PG_GETARG_RANGE(1);
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
int cmp; int cmp;
...@@ -1049,6 +1090,7 @@ Datum ...@@ -1049,6 +1090,7 @@ Datum
range_lt(PG_FUNCTION_ARGS) range_lt(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = range_cmp(fcinfo);
PG_RETURN_BOOL(cmp < 0); PG_RETURN_BOOL(cmp < 0);
} }
...@@ -1056,6 +1098,7 @@ Datum ...@@ -1056,6 +1098,7 @@ Datum
range_le(PG_FUNCTION_ARGS) range_le(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = range_cmp(fcinfo);
PG_RETURN_BOOL(cmp <= 0); PG_RETURN_BOOL(cmp <= 0);
} }
...@@ -1063,6 +1106,7 @@ Datum ...@@ -1063,6 +1106,7 @@ Datum
range_ge(PG_FUNCTION_ARGS) range_ge(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = range_cmp(fcinfo);
PG_RETURN_BOOL(cmp >= 0); PG_RETURN_BOOL(cmp >= 0);
} }
...@@ -1070,6 +1114,7 @@ Datum ...@@ -1070,6 +1114,7 @@ Datum
range_gt(PG_FUNCTION_ARGS) range_gt(PG_FUNCTION_ARGS)
{ {
int cmp = range_cmp(fcinfo); int cmp = range_cmp(fcinfo);
PG_RETURN_BOOL(cmp > 0); PG_RETURN_BOOL(cmp > 0);
} }
...@@ -1110,10 +1155,10 @@ hash_range(PG_FUNCTION_ARGS) ...@@ -1110,10 +1155,10 @@ hash_range(PG_FUNCTION_ARGS)
subtype = rngtypinfo.subtype; subtype = rngtypinfo.subtype;
/* /*
* We arrange to look up the hash function only once per series of * We arrange to look up the hash function only once per series of calls,
* calls, assuming the subtype doesn't change underneath us. The * assuming the subtype doesn't change underneath us. The typcache is
* typcache is used so that we have no memory leakage when being * used so that we have no memory leakage when being used as an index
* used as an index support function. * support function.
*/ */
typentry = (TypeCacheEntry *) fcinfo->flinfo->fn_extra; typentry = (TypeCacheEntry *) fcinfo->flinfo->fn_extra;
if (typentry == NULL || typentry->type_id != subtype) if (typentry == NULL || typentry->type_id != subtype)
...@@ -1128,8 +1173,8 @@ hash_range(PG_FUNCTION_ARGS) ...@@ -1128,8 +1173,8 @@ hash_range(PG_FUNCTION_ARGS)
} }
/* /*
* Apply the hash function to each bound (the hash function shouldn't * Apply the hash function to each bound (the hash function shouldn't care
* care about the collation). * about the collation).
*/ */
InitFunctionCallInfoData(locfcinfo, &typentry->hash_proc_finfo, 1, InitFunctionCallInfoData(locfcinfo, &typentry->hash_proc_finfo, 1,
InvalidOid, NULL, NULL); InvalidOid, NULL, NULL);
...@@ -1266,7 +1311,7 @@ int4range_subdiff(PG_FUNCTION_ARGS) ...@@ -1266,7 +1311,7 @@ int4range_subdiff(PG_FUNCTION_ARGS)
int32 v1 = PG_GETARG_INT32(0); int32 v1 = PG_GETARG_INT32(0);
int32 v2 = PG_GETARG_INT32(1); int32 v2 = PG_GETARG_INT32(1);
PG_RETURN_FLOAT8((float8)(v1-v2)); PG_RETURN_FLOAT8((float8) (v1 - v2));
} }
Datum Datum
...@@ -1275,7 +1320,7 @@ int8range_subdiff(PG_FUNCTION_ARGS) ...@@ -1275,7 +1320,7 @@ int8range_subdiff(PG_FUNCTION_ARGS)
int64 v1 = PG_GETARG_INT64(0); int64 v1 = PG_GETARG_INT64(0);
int64 v2 = PG_GETARG_INT64(1); int64 v2 = PG_GETARG_INT64(1);
PG_RETURN_FLOAT8((float8)(v1-v2)); PG_RETURN_FLOAT8((float8) (v1 - v2));
} }
Datum Datum
...@@ -1284,7 +1329,7 @@ daterange_subdiff(PG_FUNCTION_ARGS) ...@@ -1284,7 +1329,7 @@ daterange_subdiff(PG_FUNCTION_ARGS)
int32 v1 = PG_GETARG_INT32(0); int32 v1 = PG_GETARG_INT32(0);
int32 v2 = PG_GETARG_INT32(1); int32 v2 = PG_GETARG_INT32(1);
PG_RETURN_FLOAT8((float8)(v1-v2)); PG_RETURN_FLOAT8((float8) (v1 - v2));
} }
Datum Datum
...@@ -1311,7 +1356,7 @@ tsrange_subdiff(PG_FUNCTION_ARGS) ...@@ -1311,7 +1356,7 @@ tsrange_subdiff(PG_FUNCTION_ARGS)
float8 result; float8 result;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
result = ((float8)(v1-v2)) / USECS_PER_SEC; result = ((float8) (v1 - v2)) / USECS_PER_SEC;
#else #else
result = v1 - v2; result = v1 - v2;
#endif #endif
...@@ -1327,7 +1372,7 @@ tstzrange_subdiff(PG_FUNCTION_ARGS) ...@@ -1327,7 +1372,7 @@ tstzrange_subdiff(PG_FUNCTION_ARGS)
float8 result; float8 result;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
result = ((float8)(v1-v2)) / USECS_PER_SEC; result = ((float8) (v1 - v2)) / USECS_PER_SEC;
#else #else
result = v1 - v2; result = v1 - v2;
#endif #endif
...@@ -1369,7 +1414,7 @@ tstzrange_subdiff(PG_FUNCTION_ARGS) ...@@ -1369,7 +1414,7 @@ tstzrange_subdiff(PG_FUNCTION_ARGS)
* only be called by a canonicalization function. * only be called by a canonicalization function.
*/ */
Datum Datum
range_serialize(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper, range_serialize(FunctionCallInfo fcinfo, RangeBound * lower, RangeBound * upper,
bool empty) bool empty)
{ {
Datum range; Datum range;
...@@ -1452,8 +1497,8 @@ range_serialize(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper, ...@@ -1452,8 +1497,8 @@ range_serialize(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper,
} }
void void
range_deserialize(FunctionCallInfo fcinfo, RangeType *range, RangeBound *lower, range_deserialize(FunctionCallInfo fcinfo, RangeType * range, RangeBound * lower,
RangeBound *upper, bool *empty) RangeBound * upper, bool *empty)
{ {
Pointer ptr = VARDATA(range); Pointer ptr = VARDATA(range);
char typalign; char typalign;
...@@ -1530,7 +1575,7 @@ range_deserialize(FunctionCallInfo fcinfo, RangeType *range, RangeBound *lower, ...@@ -1530,7 +1575,7 @@ range_deserialize(FunctionCallInfo fcinfo, RangeType *range, RangeBound *lower,
* range. This should be used by most callers. * range. This should be used by most callers.
*/ */
Datum Datum
make_range(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper, make_range(FunctionCallInfo fcinfo, RangeBound * lower, RangeBound * upper,
bool empty) bool empty)
{ {
Datum range; Datum range;
...@@ -1551,7 +1596,7 @@ make_range(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper, ...@@ -1551,7 +1596,7 @@ make_range(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper,
} }
int int
range_cmp_bounds(FunctionCallInfo fcinfo, RangeBound *b1, RangeBound *b2) range_cmp_bounds(FunctionCallInfo fcinfo, RangeBound * b1, RangeBound * b2)
{ {
int result; int result;
...@@ -1607,7 +1652,7 @@ make_empty_range(FunctionCallInfo fcinfo, Oid rngtypid) ...@@ -1607,7 +1652,7 @@ make_empty_range(FunctionCallInfo fcinfo, Oid rngtypid)
*/ */
void void
range_gettypinfo(FunctionCallInfo fcinfo, Oid rngtypid, range_gettypinfo(FunctionCallInfo fcinfo, Oid rngtypid,
RangeTypeInfo *rngtypinfo) RangeTypeInfo * rngtypinfo)
{ {
RangeTypeInfo *cached = (RangeTypeInfo *) fcinfo->flinfo->fn_extra; RangeTypeInfo *cached = (RangeTypeInfo *) fcinfo->flinfo->fn_extra;
...@@ -2023,7 +2068,7 @@ range_bound_escape(char *value) ...@@ -2023,7 +2068,7 @@ range_bound_escape(char *value)
} }
static bool static bool
range_contains_internal(FunctionCallInfo fcinfo, RangeType *r1, RangeType *r2) range_contains_internal(FunctionCallInfo fcinfo, RangeType * r1, RangeType * r2)
{ {
RangeBound lower1; RangeBound lower1;
RangeBound upper1; RangeBound upper1;
...@@ -2066,8 +2111,8 @@ datum_compute_size(Size data_length, Datum val, bool typbyval, char typalign, ...@@ -2066,8 +2111,8 @@ datum_compute_size(Size data_length, Datum val, bool typbyval, char typalign,
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val))) VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
{ {
/* /*
* we're anticipating converting to a short varlena header, so * we're anticipating converting to a short varlena header, so adjust
* adjust length and don't count any alignment * length and don't count any alignment
*/ */
data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val)); data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
} }
......
...@@ -33,14 +33,14 @@ ...@@ -33,14 +33,14 @@
#define RANGESTRAT_OVERRIGHT 11 #define RANGESTRAT_OVERRIGHT 11
#define RANGESTRAT_ADJACENT 12 #define RANGESTRAT_ADJACENT 12
static RangeType *range_super_union(FunctionCallInfo fcinfo, RangeType *r1, static RangeType *range_super_union(FunctionCallInfo fcinfo, RangeType * r1,
RangeType *r2); RangeType * r2);
static bool range_gist_consistent_int(FunctionCallInfo fcinfo, static bool range_gist_consistent_int(FunctionCallInfo fcinfo,
StrategyNumber strategy, RangeType *key, StrategyNumber strategy, RangeType * key,
RangeType *query); RangeType * query);
static bool range_gist_consistent_leaf(FunctionCallInfo fcinfo, static bool range_gist_consistent_leaf(FunctionCallInfo fcinfo,
StrategyNumber strategy, RangeType *key, StrategyNumber strategy, RangeType * key,
RangeType *query); RangeType * query);
static int sort_item_cmp(const void *a, const void *b); static int sort_item_cmp(const void *a, const void *b);
/* /*
...@@ -60,6 +60,7 @@ range_gist_consistent(PG_FUNCTION_ARGS) ...@@ -60,6 +60,7 @@ range_gist_consistent(PG_FUNCTION_ARGS)
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
Datum dquery = PG_GETARG_DATUM(1); Datum dquery = PG_GETARG_DATUM(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */ /* Oid subtype = PG_GETARG_OID(3); */
bool *recheck = (bool *) PG_GETARG_POINTER(4); bool *recheck = (bool *) PG_GETARG_POINTER(4);
RangeType *key = DatumGetRangeType(entry->key); RangeType *key = DatumGetRangeType(entry->key);
...@@ -81,8 +82,8 @@ range_gist_consistent(PG_FUNCTION_ARGS) ...@@ -81,8 +82,8 @@ range_gist_consistent(PG_FUNCTION_ARGS)
/* /*
* For contains and contained by operators, the other operand is a * For contains and contained by operators, the other operand is a
* "point" of the subtype. Construct a singleton range containing just * "point" of the subtype. Construct a singleton range containing
* that value. * just that value.
*/ */
case RANGESTRAT_CONTAINS_ELEM: case RANGESTRAT_CONTAINS_ELEM:
case RANGESTRAT_ELEM_CONTAINED_BY: case RANGESTRAT_ELEM_CONTAINED_BY:
...@@ -136,6 +137,7 @@ Datum ...@@ -136,6 +137,7 @@ Datum
range_gist_compress(PG_FUNCTION_ARGS) range_gist_compress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
PG_RETURN_POINTER(entry); PG_RETURN_POINTER(entry);
} }
...@@ -143,6 +145,7 @@ Datum ...@@ -143,6 +145,7 @@ Datum
range_gist_decompress(PG_FUNCTION_ARGS) range_gist_decompress(PG_FUNCTION_ARGS)
{ {
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
PG_RETURN_POINTER(entry); PG_RETURN_POINTER(entry);
} }
...@@ -158,11 +161,15 @@ range_gist_penalty(PG_FUNCTION_ARGS) ...@@ -158,11 +161,15 @@ range_gist_penalty(PG_FUNCTION_ARGS)
FmgrInfo *subtype_diff; FmgrInfo *subtype_diff;
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
float lower_diff, upper_diff; float lower_diff,
upper_diff;
RangeTypeInfo rngtypinfo; RangeTypeInfo rngtypinfo;
...@@ -329,11 +336,14 @@ range_gist_same(PG_FUNCTION_ARGS) ...@@ -329,11 +336,14 @@ range_gist_same(PG_FUNCTION_ARGS)
/* return the smallest range that contains r1 and r2 */ /* return the smallest range that contains r1 and r2 */
static RangeType * static RangeType *
range_super_union(FunctionCallInfo fcinfo, RangeType *r1, RangeType *r2) range_super_union(FunctionCallInfo fcinfo, RangeType * r1, RangeType * r2)
{ {
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
RangeBound *result_lower; RangeBound *result_lower;
RangeBound *result_upper; RangeBound *result_upper;
...@@ -367,13 +377,16 @@ range_super_union(FunctionCallInfo fcinfo, RangeType *r1, RangeType *r2) ...@@ -367,13 +377,16 @@ range_super_union(FunctionCallInfo fcinfo, RangeType *r1, RangeType *r2)
static bool static bool
range_gist_consistent_int(FunctionCallInfo fcinfo, StrategyNumber strategy, range_gist_consistent_int(FunctionCallInfo fcinfo, StrategyNumber strategy,
RangeType *key, RangeType *query) RangeType * key, RangeType * query)
{ {
Oid proc = InvalidOid; Oid proc = InvalidOid;
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
bool retval; bool retval;
bool negate = false; bool negate = false;
...@@ -447,13 +460,16 @@ range_gist_consistent_int(FunctionCallInfo fcinfo, StrategyNumber strategy, ...@@ -447,13 +460,16 @@ range_gist_consistent_int(FunctionCallInfo fcinfo, StrategyNumber strategy,
static bool static bool
range_gist_consistent_leaf(FunctionCallInfo fcinfo, StrategyNumber strategy, range_gist_consistent_leaf(FunctionCallInfo fcinfo, StrategyNumber strategy,
RangeType *key, RangeType *query) RangeType * key, RangeType * query)
{ {
Oid proc = InvalidOid; Oid proc = InvalidOid;
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
range_deserialize(fcinfo, key, &lower1, &upper1, &empty1); range_deserialize(fcinfo, key, &lower1, &upper1, &empty1);
range_deserialize(fcinfo, query, &lower2, &upper2, &empty2); range_deserialize(fcinfo, query, &lower2, &upper2, &empty2);
...@@ -525,14 +541,17 @@ range_gist_consistent_leaf(FunctionCallInfo fcinfo, StrategyNumber strategy, ...@@ -525,14 +541,17 @@ range_gist_consistent_leaf(FunctionCallInfo fcinfo, StrategyNumber strategy,
static int static int
sort_item_cmp(const void *a, const void *b) sort_item_cmp(const void *a, const void *b)
{ {
PickSplitSortItem *i1 = (PickSplitSortItem *)a; PickSplitSortItem *i1 = (PickSplitSortItem *) a;
PickSplitSortItem *i2 = (PickSplitSortItem *)b; PickSplitSortItem *i2 = (PickSplitSortItem *) b;
RangeType *r1 = i1->data; RangeType *r1 = i1->data;
RangeType *r2 = i2->data; RangeType *r2 = i2->data;
RangeBound lower1, lower2; RangeBound lower1,
RangeBound upper1, upper2; lower2;
bool empty1, empty2; RangeBound upper1,
upper2;
bool empty1,
empty2;
FunctionCallInfo fcinfo = i1->fcinfo; FunctionCallInfo fcinfo = i1->fcinfo;
...@@ -554,12 +573,11 @@ sort_item_cmp(const void *a, const void *b) ...@@ -554,12 +573,11 @@ sort_item_cmp(const void *a, const void *b)
} }
/* /*
* If both lower or both upper bounds are infinite, we sort by * If both lower or both upper bounds are infinite, we sort by ascending
* ascending range size. That means that if both upper bounds are * range size. That means that if both upper bounds are infinite, we sort
* infinite, we sort by the lower bound _descending_. That creates * by the lower bound _descending_. That creates a slightly odd total
* a slightly odd total order, but keeps the pages with very * order, but keeps the pages with very unselective predicates grouped
* unselective predicates grouped more closely together on the * more closely together on the right.
* right.
*/ */
if (lower1.infinite || upper1.infinite || if (lower1.infinite || upper1.infinite ||
lower2.infinite || upper2.infinite) lower2.infinite || upper2.infinite)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment