Skip to content

Commit 737ab85

Browse files
committed
1. Pass GISTENTRYs to giststate->penaltyFn by pointers, not by vals.
2. Re-initialize keys in gistrescan (if gist used in inner scan).
1 parent 4800abc commit 737ab85

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/backend/access/gist/gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
987987
size = IndexTupleSize(datum) - sizeof(IndexTupleData);
988988
datum += sizeof(IndexTupleData);
989989
gistdentryinit(giststate,&entry,datum,r,p,i,size,FALSE);
990-
(giststate->penaltyFn)(entry, identry, &usize);
990+
(giststate->penaltyFn)(&entry, &identry, &usize);
991991
if (which_grow < 0 || usize < which_grow) {
992992
which = i;
993993
which_grow = usize;

src/backend/access/gist/gistscan.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
118118
gistfreestack(p->s_markstk);
119119
p->s_stack = p->s_markstk = (GISTSTACK *) NULL;
120120
p->s_flags = 0x0;
121+
for (i = 0; i < s->numberOfKeys; i++)
122+
{
123+
s->keyData[i].sk_procedure
124+
= RelationGetGISTStrategy(s->relation, s->keyData[i].sk_attno,
125+
s->keyData[i].sk_procedure);
126+
s->keyData[i].sk_func = p->giststate->consistentFn;
127+
}
121128
} else {
122129
/* initialize opaque data */
123130
p = (GISTScanOpaque) palloc(sizeof(GISTScanOpaqueData));

0 commit comments

Comments
 (0)