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
87545f54
Commit
87545f54
authored
Mar 30, 2016
by
Teodor Sigaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use traversalValue in SP-GiST range opclass.
Author: Alexander Lebedev
parent
ccd6eb49
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
9 deletions
+25
-9
src/backend/utils/adt/rangetypes_spgist.c
src/backend/utils/adt/rangetypes_spgist.c
+25
-9
No files found.
src/backend/utils/adt/rangetypes_spgist.c
View file @
87545f54
...
...
@@ -310,14 +310,12 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
spgInnerConsistentOut
*
out
=
(
spgInnerConsistentOut
*
)
PG_GETARG_POINTER
(
1
);
int
which
;
int
i
;
MemoryContext
oldCtx
;
/*
* For adjacent search we need also previous centroid (if any) to improve
* the precision of the consistent check. In this case needPrevious flag
* is set and centroid is passed into reconstructedValues. This is not the
* intended purpose of reconstructedValues (because we already have the
* full value available at the leaf), but it's a convenient place to store
* state while traversing the tree.
* is set and centroid is passed into traversalValue.
*/
bool
needPrevious
=
false
;
...
...
@@ -565,9 +563,9 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
* for lower or upper bounds to be adjacent. Deserialize
* previous centroid range if present for checking this.
*/
if
(
in
->
reconstructed
Value
!=
(
Datum
)
0
)
if
(
in
->
traversal
Value
!=
(
Datum
)
0
)
{
prevCentroid
=
DatumGetRangeType
(
in
->
reconstructed
Value
);
prevCentroid
=
DatumGetRangeType
(
in
->
traversal
Value
);
range_deserialize
(
typcache
,
prevCentroid
,
&
prevLower
,
&
prevUpper
,
&
prevEmpty
);
}
...
...
@@ -746,18 +744,36 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
/* We must descend into the quadrant(s) identified by 'which' */
out
->
nodeNumbers
=
(
int
*
)
palloc
(
sizeof
(
int
)
*
in
->
nNodes
);
if
(
needPrevious
)
out
->
reconstructedValues
=
(
Datum
*
)
palloc
(
sizeof
(
Datum
)
*
in
->
nNodes
);
out
->
traversalValues
=
(
void
**
)
palloc
(
sizeof
(
void
*
)
*
in
->
nNodes
);
out
->
nNodes
=
0
;
/*
* Elements of traversalValues should be allocated in
* traversalMemoryContext
*/
oldCtx
=
MemoryContextSwitchTo
(
in
->
traversalMemoryContext
);
for
(
i
=
1
;
i
<=
in
->
nNodes
;
i
++
)
{
if
(
which
&
(
1
<<
i
))
{
/* Save previous prefix if needed */
if
(
needPrevious
)
out
->
reconstructedValues
[
out
->
nNodes
]
=
in
->
prefixDatum
;
out
->
nodeNumbers
[
out
->
nNodes
++
]
=
i
-
1
;
{
Datum
previousCentroid
;
/* We know, that in->prefixDatum in this place is varlena,
* because it's range
*/
previousCentroid
=
datumCopy
(
in
->
prefixDatum
,
false
,
-
1
);
out
->
traversalValues
[
out
->
nNodes
]
=
(
void
*
)
previousCentroid
;
}
out
->
nodeNumbers
[
out
->
nNodes
]
=
i
-
1
;
out
->
nNodes
++
;
}
}
MemoryContextSwitchTo
(
oldCtx
);
PG_RETURN_VOID
();
}
...
...
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