Commit b7a0e8fb authored by Tom Lane's avatar Tom Lane

Defend against null scankeys in spgist searches.

Should've thought of that one earlier.
parent 5577ca5b
...@@ -162,13 +162,22 @@ spgLeafTest(SpGistScanOpaque so, Datum leafDatum, ...@@ -162,13 +162,22 @@ spgLeafTest(SpGistScanOpaque so, Datum leafDatum,
oldCtx = MemoryContextSwitchTo(so->tempCxt); oldCtx = MemoryContextSwitchTo(so->tempCxt);
for (i = 0; i < so->numberOfKeys; i++) for (i = 0; i < so->numberOfKeys; i++)
{ {
in.strategy = so->keyData[i].sk_strategy; ScanKey skey = &so->keyData[i];
in.query = so->keyData[i].sk_argument;
/* 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; out.recheck = false;
result = DatumGetBool(FunctionCall2Coll(&so->state.leafConsistentFn, result = DatumGetBool(FunctionCall2Coll(&so->state.leafConsistentFn,
so->keyData[i].sk_collation, skey->sk_collation,
PointerGetDatum(&in), PointerGetDatum(&in),
PointerGetDatum(&out))); PointerGetDatum(&out)));
*recheck |= out.recheck; *recheck |= out.recheck;
...@@ -398,13 +407,22 @@ redirect: ...@@ -398,13 +407,22 @@ redirect:
for (j = 0; j < so->numberOfKeys; j++) for (j = 0; j < so->numberOfKeys; j++)
{ {
in.strategy = so->keyData[j].sk_strategy; ScanKey skey = &so->keyData[j];
in.query = so->keyData[j].sk_argument;
/* 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)); memset(&out, 0, sizeof(out));
FunctionCall2Coll(&so->state.innerConsistentFn, FunctionCall2Coll(&so->state.innerConsistentFn,
so->keyData[j].sk_collation, skey->sk_collation,
PointerGetDatum(&in), PointerGetDatum(&in),
PointerGetDatum(&out)); PointerGetDatum(&out));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment