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:
@ -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,
|
||||
|
Reference in New Issue
Block a user