Avoid treating nonrequired nbtree keys as required. Consistently prevent nbtree array advancement from treating a scankey as required when operating in pstate.forcenonrequired mode. Otherwise, we risk a NULL pointer dereference. This was possible in the path where _bt_check_compare is called to recheck a tuple that advanced all of the scan's arrays to matching values: its continuescan=false handling expects _bt_advance_array_keys to have been called with a valid pstate, but it'll always be NULL during sktrig_required=false calls (which is how _bt_advance_array_keys must be called when pstate.forcenonrequired).
Oversight in commit 8a510275, which optimized nbtree search scan key comparisons. Author: Peter Geoghegan <p...@bowt.ie> Reported-By: Mark Dilger <mark.dil...@enterprisedb.com> Discussion: https://postgr.es/m/CAHgHdKsn2W=gpbmj7p6mjqfvxb+zzdbkwtsg0o3f5hh8rkr...@mail.gmail.com Discussion: https://postgr.es/m/cah2-wzmodse+gptd1crgu9ez8ytyyds+kns2r9nzgup1s56...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/0f08df406822bfa697dbcabef55728a8cb3e7fdb Modified Files -------------- src/backend/access/nbtree/nbtutils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)