1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Fix SIGSEGV in pruning for ScalarArrayOp with constant-null array.

Not much to be said here: commit 9fdb675fc should have checked
constisnull, didn't.

Per report from Piotr Włodarczyk.  Back-patch to v11 where
bug was introduced.

Discussion: https://postgr.es/m/CAP-dhMr+vRpwizEYjUjsiZ1vwqpohTm+3Pbdt6Pr7FEgPq9R0Q@mail.gmail.com
This commit is contained in:
Tom Lane
2019-08-09 13:20:28 -04:00
parent 1661a40505
commit 0662eb6219
3 changed files with 82 additions and 1 deletions

View File

@ -2059,7 +2059,7 @@ match_clause_to_partition_key(GeneratePruningStepsContext *context,
* nodes, one for each array element (excepting nulls).
*/
Const *arr = (Const *) rightop;
ArrayType *arrval = DatumGetArrayTypeP(arr->constvalue);
ArrayType *arrval;
int16 elemlen;
bool elembyval;
char elemalign;
@ -2068,6 +2068,11 @@ match_clause_to_partition_key(GeneratePruningStepsContext *context,
int num_elems,
i;
/* If the array itself is null, the saop returns null */
if (arr->constisnull)
return PARTCLAUSE_MATCH_CONTRADICT;
arrval = DatumGetArrayTypeP(arr->constvalue);
get_typlenbyvalalign(ARR_ELEMTYPE(arrval),
&elemlen, &elembyval, &elemalign);
deconstruct_array(arrval,