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
Expand all
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)
...
@@ -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
* ha
s to be done "by ha
nd" 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
*
*
...
...
src/backend/utils/adt/rangetypes.c
View file @
cdaa45fd
This diff is collapsed.
Click to expand it.
src/backend/utils/adt/rangetypes_gist.c
View file @
cdaa45fd
...
@@ -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
)
...
...
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