Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cdaa45fd
Commit
cdaa45fd
authored
Nov 14, 2011
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run pgindent on range type files, per request from Tom.
parent
5b5985e6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
679 additions
and
614 deletions
+679
-614
src/backend/catalog/pg_range.c
src/backend/catalog/pg_range.c
+22
-22
src/backend/commands/typecmds.c
src/backend/commands/typecmds.c
+86
-84
src/backend/utils/adt/rangetypes.c
src/backend/utils/adt/rangetypes.c
+438
-393
src/backend/utils/adt/rangetypes_gist.c
src/backend/utils/adt/rangetypes_gist.c
+133
-115
No files found.
src/backend/catalog/pg_range.c
View file @
cdaa45fd
src/backend/commands/typecmds.c
View file @
cdaa45fd
...
...
@@ -654,9 +654,9 @@ RemoveTypeById(Oid typeOid)
EnumValuesDelete
(
typeOid
);
/*
* If it is a range type, delete the pg_range entries too; we
*
don't bother with making dependency entries for those, so it
* ha
s to be done "by ha
nd" here.
* If it is a range type, delete the pg_range entries too; we
don't bother
*
with making dependency entries for those, so it has to be done "by
* hand" here.
*/
if
(((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typtype
==
TYPTYPE_RANGE
)
RangeDelete
(
typeOid
);
...
...
@@ -744,7 +744,8 @@ DefineDomain(CreateDomainStmt *stmt)
/*
* 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
* 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
;
if
(
typtype
!=
TYPTYPE_BASE
&&
...
...
@@ -1158,7 +1159,7 @@ DefineEnum(CreateEnumStmt *stmt)
* Registers a new range type.
*/
void
DefineRange
(
CreateRangeStmt
*
stmt
)
DefineRange
(
CreateRangeStmt
*
stmt
)
{
char
*
typeName
;
char
*
rangeArrayName
;
...
...
@@ -1432,7 +1433,7 @@ makeRangeConstructor(char *name, Oid namespace, Oid rangeOid, Oid subtype)
oidvector
*
constructorArgTypesVector
;
ObjectAddress
myself
;
Oid
procOid
;
char
*
prosrc
[
4
]
=
{
"range_constructor0"
,
char
*
prosrc
[
4
]
=
{
"range_constructor0"
,
"range_constructor1"
,
"range_constructor2"
,
"range_constructor3"
};
...
...
@@ -2549,6 +2550,7 @@ validateDomainConstraint(Oid domainoid, char *ccbin)
FreeExecutorState
(
estate
);
}
/*
* get_rels_with_domain
*
...
...
src/backend/utils/adt/rangetypes.c
View file @
cdaa45fd
...
...
@@ -59,8 +59,8 @@ static char *range_parse_bound(char *string, char *ptr, char **bound_str,
bool
*
infinite
);
static
char
*
range_deparse
(
char
flags
,
char
*
lbound_str
,
char
*
ubound_str
);
static
char
*
range_bound_escape
(
char
*
in_str
);
static
bool
range_contains_internal
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
);
static
bool
range_contains_internal
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
);
static
Size
datum_compute_size
(
Size
sz
,
Datum
datum
,
bool
typbyval
,
char
typalign
,
int16
typlen
,
char
typstorage
);
static
Pointer
datum_write
(
Pointer
ptr
,
Datum
datum
,
bool
typbyval
,
...
...
@@ -259,8 +259,8 @@ range_recv(PG_FUNCTION_ARGS)
range
=
make_range
(
fcinfo
,
&
lower
,
&
upper
,
flags
&
RANGE_EMPTY
);
/*
* XXX if the subtype is pass-by-val, we should pfree the upper and
*
lower
bounds here.
* XXX if the subtype is pass-by-val, we should pfree the upper and
lower
* bounds here.
*/
PG_RETURN_RANGE
(
range
);
...
...
@@ -401,13 +401,13 @@ range_constructor2(PG_FUNCTION_ARGS)
flags
=
range_parse_flags
(
RANGE_DEFAULT_FLAGS
);
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
.
infinite
=
PG_ARGISNULL
(
0
);
lower
.
lower
=
true
;
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
.
infinite
=
PG_ARGISNULL
(
1
);
upper
.
lower
=
false
;
...
...
@@ -435,13 +435,13 @@ range_constructor3(PG_FUNCTION_ARGS)
flags
=
range_parse_flags
(
text_to_cstring
(
PG_GETARG_TEXT_P
(
2
)));
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
.
infinite
=
PG_ARGISNULL
(
0
);
lower
.
lower
=
true
;
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
.
infinite
=
PG_ARGISNULL
(
1
);
upper
.
lower
=
false
;
...
...
@@ -571,9 +571,12 @@ range_eq(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -612,8 +615,10 @@ range_contains_elem(PG_FUNCTION_ARGS)
RangeType
*
r2
;
Datum
val
=
PG_GETARG_DATUM
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
...
...
@@ -651,8 +656,10 @@ elem_contained_by_range(PG_FUNCTION_ARGS)
RangeType
*
r2
;
Datum
val
=
PG_GETARG_DATUM
(
0
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
...
...
@@ -689,9 +696,12 @@ range_before(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -718,9 +728,12 @@ range_after(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -741,16 +754,20 @@ range_after(PG_FUNCTION_ARGS)
PG_RETURN_BOOL
(
false
);
}
Datum
range_adjacent
(
PG_FUNCTION_ARGS
)
Datum
range_adjacent
(
PG_FUNCTION_ARGS
)
{
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeTypeInfo
rngtypinfo
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -766,12 +783,12 @@ Datum range_adjacent(PG_FUNCTION_ARGS)
errmsg
(
"undefined for empty ranges"
)));
/*
* For two ranges to be adjacent, the lower boundary of one range
*
has to match the upper boundary of the other. However, the
*
inclusivity of
those two boundaries must also be different.
* For two ranges to be adjacent, the lower boundary of one range
has to
*
match the upper boundary of the other. However, the inclusivity of
* those two boundaries must also be different.
*
* The semantics for range_cmp_bounds aren't quite what we need
*
here, so
we do the comparison more directly.
* The semantics for range_cmp_bounds aren't quite what we need
here, so
* we do the comparison more directly.
*/
range_gettypinfo
(
fcinfo
,
lower1
.
rngtypid
,
&
rngtypinfo
);
...
...
@@ -801,9 +818,12 @@ range_overlaps(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -833,9 +853,12 @@ range_overleft(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -860,9 +883,12 @@ range_overright(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
r1
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -889,11 +915,17 @@ range_minus(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
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
,
r2
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -946,9 +978,12 @@ range_union(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
*
result_lower
;
RangeBound
*
result_upper
;
...
...
@@ -985,9 +1020,12 @@ range_intersect(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
*
result_lower
;
RangeBound
*
result_upper
;
...
...
@@ -1018,9 +1056,12 @@ range_cmp(PG_FUNCTION_ARGS)
RangeType
*
r1
=
PG_GETARG_RANGE
(
0
);
RangeType
*
r2
=
PG_GETARG_RANGE
(
1
);
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
int
cmp
;
...
...
@@ -1049,6 +1090,7 @@ Datum
range_lt
(
PG_FUNCTION_ARGS
)
{
int
cmp
=
range_cmp
(
fcinfo
);
PG_RETURN_BOOL
(
cmp
<
0
);
}
...
...
@@ -1056,6 +1098,7 @@ Datum
range_le
(
PG_FUNCTION_ARGS
)
{
int
cmp
=
range_cmp
(
fcinfo
);
PG_RETURN_BOOL
(
cmp
<=
0
);
}
...
...
@@ -1063,6 +1106,7 @@ Datum
range_ge
(
PG_FUNCTION_ARGS
)
{
int
cmp
=
range_cmp
(
fcinfo
);
PG_RETURN_BOOL
(
cmp
>=
0
);
}
...
...
@@ -1070,6 +1114,7 @@ Datum
range_gt
(
PG_FUNCTION_ARGS
)
{
int
cmp
=
range_cmp
(
fcinfo
);
PG_RETURN_BOOL
(
cmp
>
0
);
}
...
...
@@ -1110,10 +1155,10 @@ hash_range(PG_FUNCTION_ARGS)
subtype
=
rngtypinfo
.
subtype
;
/*
* We arrange to look up the hash function only once per series of
*
calls, assuming the subtype doesn't change underneath us. The
*
typcache is used so that we have no memory leakage when being
*
used as an index
support function.
* We arrange to look up the hash function only once per series of
calls,
*
assuming the subtype doesn't change underneath us. The typcache is
*
used so that we have no memory leakage when being used as an index
* support function.
*/
typentry
=
(
TypeCacheEntry
*
)
fcinfo
->
flinfo
->
fn_extra
;
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
*
care
about the collation).
* Apply the hash function to each bound (the hash function shouldn't
care
* about the collation).
*/
InitFunctionCallInfoData
(
locfcinfo
,
&
typentry
->
hash_proc_finfo
,
1
,
InvalidOid
,
NULL
,
NULL
);
...
...
@@ -1266,7 +1311,7 @@ int4range_subdiff(PG_FUNCTION_ARGS)
int32
v1
=
PG_GETARG_INT32
(
0
);
int32
v2
=
PG_GETARG_INT32
(
1
);
PG_RETURN_FLOAT8
((
float8
)
(
v1
-
v2
));
PG_RETURN_FLOAT8
((
float8
)
(
v1
-
v2
));
}
Datum
...
...
@@ -1275,7 +1320,7 @@ int8range_subdiff(PG_FUNCTION_ARGS)
int64
v1
=
PG_GETARG_INT64
(
0
);
int64
v2
=
PG_GETARG_INT64
(
1
);
PG_RETURN_FLOAT8
((
float8
)
(
v1
-
v2
));
PG_RETURN_FLOAT8
((
float8
)
(
v1
-
v2
));
}
Datum
...
...
@@ -1284,7 +1329,7 @@ daterange_subdiff(PG_FUNCTION_ARGS)
int32
v1
=
PG_GETARG_INT32
(
0
);
int32
v2
=
PG_GETARG_INT32
(
1
);
PG_RETURN_FLOAT8
((
float8
)
(
v1
-
v2
));
PG_RETURN_FLOAT8
((
float8
)
(
v1
-
v2
));
}
Datum
...
...
@@ -1311,7 +1356,7 @@ tsrange_subdiff(PG_FUNCTION_ARGS)
float8
result
;
#ifdef HAVE_INT64_TIMESTAMP
result
=
((
float8
)
(
v1
-
v2
))
/
USECS_PER_SEC
;
result
=
((
float8
)
(
v1
-
v2
))
/
USECS_PER_SEC
;
#else
result
=
v1
-
v2
;
#endif
...
...
@@ -1327,7 +1372,7 @@ tstzrange_subdiff(PG_FUNCTION_ARGS)
float8
result
;
#ifdef HAVE_INT64_TIMESTAMP
result
=
((
float8
)
(
v1
-
v2
))
/
USECS_PER_SEC
;
result
=
((
float8
)
(
v1
-
v2
))
/
USECS_PER_SEC
;
#else
result
=
v1
-
v2
;
#endif
...
...
@@ -1369,7 +1414,7 @@ tstzrange_subdiff(PG_FUNCTION_ARGS)
* only be called by a canonicalization function.
*/
Datum
range_serialize
(
FunctionCallInfo
fcinfo
,
RangeBound
*
lower
,
RangeBound
*
upper
,
range_serialize
(
FunctionCallInfo
fcinfo
,
RangeBound
*
lower
,
RangeBound
*
upper
,
bool
empty
)
{
Datum
range
;
...
...
@@ -1452,8 +1497,8 @@ range_serialize(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper,
}
void
range_deserialize
(
FunctionCallInfo
fcinfo
,
RangeType
*
range
,
RangeBound
*
lower
,
RangeBound
*
upper
,
bool
*
empty
)
range_deserialize
(
FunctionCallInfo
fcinfo
,
RangeType
*
range
,
RangeBound
*
lower
,
RangeBound
*
upper
,
bool
*
empty
)
{
Pointer
ptr
=
VARDATA
(
range
);
char
typalign
;
...
...
@@ -1530,7 +1575,7 @@ range_deserialize(FunctionCallInfo fcinfo, RangeType *range, RangeBound *lower,
* range. This should be used by most callers.
*/
Datum
make_range
(
FunctionCallInfo
fcinfo
,
RangeBound
*
lower
,
RangeBound
*
upper
,
make_range
(
FunctionCallInfo
fcinfo
,
RangeBound
*
lower
,
RangeBound
*
upper
,
bool
empty
)
{
Datum
range
;
...
...
@@ -1551,7 +1596,7 @@ make_range(FunctionCallInfo fcinfo, RangeBound *lower, RangeBound *upper,
}
int
range_cmp_bounds
(
FunctionCallInfo
fcinfo
,
RangeBound
*
b1
,
RangeBound
*
b2
)
range_cmp_bounds
(
FunctionCallInfo
fcinfo
,
RangeBound
*
b1
,
RangeBound
*
b2
)
{
int
result
;
...
...
@@ -1607,7 +1652,7 @@ make_empty_range(FunctionCallInfo fcinfo, Oid rngtypid)
*/
void
range_gettypinfo
(
FunctionCallInfo
fcinfo
,
Oid
rngtypid
,
RangeTypeInfo
*
rngtypinfo
)
RangeTypeInfo
*
rngtypinfo
)
{
RangeTypeInfo
*
cached
=
(
RangeTypeInfo
*
)
fcinfo
->
flinfo
->
fn_extra
;
...
...
@@ -2023,7 +2068,7 @@ range_bound_escape(char *value)
}
static
bool
range_contains_internal
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
)
range_contains_internal
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
)
{
RangeBound
lower1
;
RangeBound
upper1
;
...
...
@@ -2066,8 +2111,8 @@ datum_compute_size(Size data_length, Datum val, bool typbyval, char typalign,
VARATT_CAN_MAKE_SHORT
(
DatumGetPointer
(
val
)))
{
/*
* we're anticipating converting to a short varlena header, so
*
adjust
length and don't count any alignment
* we're anticipating converting to a short varlena header, so
adjust
* length and don't count any alignment
*/
data_length
+=
VARATT_CONVERTED_SHORT_SIZE
(
DatumGetPointer
(
val
));
}
...
...
src/backend/utils/adt/rangetypes_gist.c
View file @
cdaa45fd
...
...
@@ -33,14 +33,14 @@
#define RANGESTRAT_OVERRIGHT 11
#define RANGESTRAT_ADJACENT 12
static
RangeType
*
range_super_union
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
);
static
RangeType
*
range_super_union
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
);
static
bool
range_gist_consistent_int
(
FunctionCallInfo
fcinfo
,
StrategyNumber
strategy
,
RangeType
*
key
,
RangeType
*
query
);
StrategyNumber
strategy
,
RangeType
*
key
,
RangeType
*
query
);
static
bool
range_gist_consistent_leaf
(
FunctionCallInfo
fcinfo
,
StrategyNumber
strategy
,
RangeType
*
key
,
RangeType
*
query
);
StrategyNumber
strategy
,
RangeType
*
key
,
RangeType
*
query
);
static
int
sort_item_cmp
(
const
void
*
a
,
const
void
*
b
);
/*
...
...
@@ -60,6 +60,7 @@ range_gist_consistent(PG_FUNCTION_ARGS)
GISTENTRY
*
entry
=
(
GISTENTRY
*
)
PG_GETARG_POINTER
(
0
);
Datum
dquery
=
PG_GETARG_DATUM
(
1
);
StrategyNumber
strategy
=
(
StrategyNumber
)
PG_GETARG_UINT16
(
2
);
/* Oid subtype = PG_GETARG_OID(3); */
bool
*
recheck
=
(
bool
*
)
PG_GETARG_POINTER
(
4
);
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
* "point" of the subtype. Construct a singleton range containing just
*
that value.
* "point" of the subtype. Construct a singleton range containing
* just
that value.
*/
case
RANGESTRAT_CONTAINS_ELEM
:
case
RANGESTRAT_ELEM_CONTAINED_BY
:
...
...
@@ -136,6 +137,7 @@ Datum
range_gist_compress
(
PG_FUNCTION_ARGS
)
{
GISTENTRY
*
entry
=
(
GISTENTRY
*
)
PG_GETARG_POINTER
(
0
);
PG_RETURN_POINTER
(
entry
);
}
...
...
@@ -143,6 +145,7 @@ Datum
range_gist_decompress
(
PG_FUNCTION_ARGS
)
{
GISTENTRY
*
entry
=
(
GISTENTRY
*
)
PG_GETARG_POINTER
(
0
);
PG_RETURN_POINTER
(
entry
);
}
...
...
@@ -158,11 +161,15 @@ range_gist_penalty(PG_FUNCTION_ARGS)
FmgrInfo
*
subtype_diff
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
float
lower_diff
,
upper_diff
;
float
lower_diff
,
upper_diff
;
RangeTypeInfo
rngtypinfo
;
...
...
@@ -329,11 +336,14 @@ range_gist_same(PG_FUNCTION_ARGS)
/* return the smallest range that contains r1 and r2 */
static
RangeType
*
range_super_union
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
)
range_super_union
(
FunctionCallInfo
fcinfo
,
RangeType
*
r1
,
RangeType
*
r2
)
{
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
*
result_lower
;
RangeBound
*
result_upper
;
...
...
@@ -367,13 +377,16 @@ range_super_union(FunctionCallInfo fcinfo, RangeType *r1, RangeType *r2)
static
bool
range_gist_consistent_int
(
FunctionCallInfo
fcinfo
,
StrategyNumber
strategy
,
RangeType
*
key
,
RangeType
*
query
)
RangeType
*
key
,
RangeType
*
query
)
{
Oid
proc
=
InvalidOid
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
bool
retval
;
bool
negate
=
false
;
...
...
@@ -447,13 +460,16 @@ range_gist_consistent_int(FunctionCallInfo fcinfo, StrategyNumber strategy,
static
bool
range_gist_consistent_leaf
(
FunctionCallInfo
fcinfo
,
StrategyNumber
strategy
,
RangeType
*
key
,
RangeType
*
query
)
RangeType
*
key
,
RangeType
*
query
)
{
Oid
proc
=
InvalidOid
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
range_deserialize
(
fcinfo
,
key
,
&
lower1
,
&
upper1
,
&
empty1
);
range_deserialize
(
fcinfo
,
query
,
&
lower2
,
&
upper2
,
&
empty2
);
...
...
@@ -525,14 +541,17 @@ range_gist_consistent_leaf(FunctionCallInfo fcinfo, StrategyNumber strategy,
static
int
sort_item_cmp
(
const
void
*
a
,
const
void
*
b
)
{
PickSplitSortItem
*
i1
=
(
PickSplitSortItem
*
)
a
;
PickSplitSortItem
*
i2
=
(
PickSplitSortItem
*
)
b
;
PickSplitSortItem
*
i1
=
(
PickSplitSortItem
*
)
a
;
PickSplitSortItem
*
i2
=
(
PickSplitSortItem
*
)
b
;
RangeType
*
r1
=
i1
->
data
;
RangeType
*
r2
=
i2
->
data
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
RangeBound
lower1
,
lower2
;
RangeBound
upper1
,
upper2
;
bool
empty1
,
empty2
;
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
* ascending range size. That means that if both upper bounds are
* infinite, we sort by the lower bound _descending_. That creates
* a slightly odd total order, but keeps the pages with very
* unselective predicates grouped more closely together on the
* right.
* If both lower or both upper bounds are infinite, we sort by ascending
* range size. That means that if both upper bounds are infinite, we sort
* by the lower bound _descending_. That creates a slightly odd total
* order, but keeps the pages with very unselective predicates grouped
* more closely together on the right.
*/
if
(
lower1
.
infinite
||
upper1
.
infinite
||
lower2
.
infinite
||
upper2
.
infinite
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment