Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7a0e8f

Browse files
committed
Defend against null scankeys in spgist searches.
Should've thought of that one earlier.
1 parent5577ca5 commitb7a0e8f

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

‎src/backend/access/spgist/spgscan.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,22 @@ spgLeafTest(SpGistScanOpaque so, Datum leafDatum,
162162
oldCtx=MemoryContextSwitchTo(so->tempCxt);
163163
for (i=0;i<so->numberOfKeys;i++)
164164
{
165-
in.strategy=so->keyData[i].sk_strategy;
166-
in.query=so->keyData[i].sk_argument;
165+
ScanKeyskey=&so->keyData[i];
166+
167+
/* Assume SPGiST-indexable operators are strict */
168+
if (skey->sk_flags&SK_ISNULL)
169+
{
170+
result= false;
171+
break;
172+
}
173+
174+
in.strategy=skey->sk_strategy;
175+
in.query=skey->sk_argument;
167176

168177
out.recheck= false;
169178

170179
result=DatumGetBool(FunctionCall2Coll(&so->state.leafConsistentFn,
171-
so->keyData[i].sk_collation,
180+
skey->sk_collation,
172181
PointerGetDatum(&in),
173182
PointerGetDatum(&out)));
174183
*recheck |=out.recheck;
@@ -398,13 +407,22 @@ spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex,
398407

399408
for (j=0;j<so->numberOfKeys;j++)
400409
{
401-
in.strategy=so->keyData[j].sk_strategy;
402-
in.query=so->keyData[j].sk_argument;
410+
ScanKeyskey=&so->keyData[j];
411+
412+
/* Assume SPGiST-indexable operators are strict */
413+
if (skey->sk_flags&SK_ISNULL)
414+
{
415+
nMatches=0;
416+
break;
417+
}
418+
419+
in.strategy=skey->sk_strategy;
420+
in.query=skey->sk_argument;
403421

404422
memset(&out,0,sizeof(out));
405423

406424
FunctionCall2Coll(&so->state.innerConsistentFn,
407-
so->keyData[j].sk_collation,
425+
skey->sk_collation,
408426
PointerGetDatum(&in),
409427
PointerGetDatum(&out));
410428

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp