aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/spgist
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-12-17 19:08:28 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-12-17 19:08:28 -0500
commitb7a0e8fb4d6fafcd30555e4ddf18e77e138ec3d0 (patch)
treecfa894e8ac9ed24aa9e5ffb683d3d42efb93dceb /src/backend/access/spgist
parent5577ca5bfb33bf7f31a03fc5b42a56de400e464e (diff)
downloadpostgresql-b7a0e8fb4d6fafcd30555e4ddf18e77e138ec3d0.tar.gz
postgresql-b7a0e8fb4d6fafcd30555e4ddf18e77e138ec3d0.zip
Defend against null scankeys in spgist searches.
Should've thought of that one earlier.
Diffstat (limited to 'src/backend/access/spgist')
-rw-r--r--src/backend/access/spgist/spgscan.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c
index 1c6180b2d24..ac309649682 100644
--- a/src/backend/access/spgist/spgscan.c
+++ b/src/backend/access/spgist/spgscan.c
@@ -162,13 +162,22 @@ spgLeafTest(SpGistScanOpaque so, Datum leafDatum,
oldCtx = MemoryContextSwitchTo(so->tempCxt);
for (i = 0; i < so->numberOfKeys; i++)
{
- in.strategy = so->keyData[i].sk_strategy;
- in.query = so->keyData[i].sk_argument;
+ ScanKey skey = &so->keyData[i];
+
+ /* Assume SPGiST-indexable operators are strict */
+ if (skey->sk_flags & SK_ISNULL)
+ {
+ result = false;
+ break;
+ }
+
+ in.strategy = skey->sk_strategy;
+ in.query = skey->sk_argument;
out.recheck = false;
result = DatumGetBool(FunctionCall2Coll(&so->state.leafConsistentFn,
- so->keyData[i].sk_collation,
+ skey->sk_collation,
PointerGetDatum(&in),
PointerGetDatum(&out)));
*recheck |= out.recheck;
@@ -398,13 +407,22 @@ redirect:
for (j = 0; j < so->numberOfKeys; j++)
{
- in.strategy = so->keyData[j].sk_strategy;
- in.query = so->keyData[j].sk_argument;
+ ScanKey skey = &so->keyData[j];
+
+ /* Assume SPGiST-indexable operators are strict */
+ if (skey->sk_flags & SK_ISNULL)
+ {
+ nMatches = 0;
+ break;
+ }
+
+ in.strategy = skey->sk_strategy;
+ in.query = skey->sk_argument;
memset(&out, 0, sizeof(out));
FunctionCall2Coll(&so->state.innerConsistentFn,
- so->keyData[j].sk_collation,
+ skey->sk_collation,
PointerGetDatum(&in),
PointerGetDatum(&out));