1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

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

This commit is contained in:
Bruce Momjian
2011-11-14 12:08:48 -05:00
parent 5b5985e6c0
commit cdaa45fd4b
4 changed files with 669 additions and 604 deletions

View File

@ -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)
/* /*
* 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 &&
@ -2549,6 +2550,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin)
FreeExecutorState(estate); FreeExecutorState(estate);
} }
/* /*
* get_rels_with_domain * get_rels_with_domain
* *

View File

@ -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);
@ -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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
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
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
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
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)
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)
} }
/* /*
* 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);
@ -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));
} }

View File

@ -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)
/* /*
* 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
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
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)
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;
@ -331,9 +338,12 @@ range_gist_same(PG_FUNCTION_ARGS)
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;
@ -371,9 +381,12 @@ range_gist_consistent_int(FunctionCallInfo fcinfo, StrategyNumber strategy,
{ {
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;
@ -451,9 +464,12 @@ range_gist_consistent_leaf(FunctionCallInfo fcinfo, StrategyNumber strategy,
{ {
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);
@ -530,9 +546,12 @@ sort_item_cmp(const void *a, const void *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)
} }
/* /*
* 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)