From: Peter Geoghegan Date: Mon, 2 Mar 2020 16:07:16 +0000 (-0800) Subject: Add assertions to _bt_update_posting(). X-Git-Tag: REL_13_BETA1~633 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77b88bd5dc92a46319a3dd4b554f89f634bb9eaa;p=thirdparty%2Fpostgresql.git Add assertions to _bt_update_posting(). Copy some assertions from _bt_form_posting() to its sibling function, _bt_update_posting(). Discussion: https://postgr.es/m/CAH2-WzkPR8KMwkL0ap976kmXwBCeukTeHz6fB-U__wvuP1S9Zg@mail.gmail.com --- diff --git a/src/backend/access/nbtree/nbtdedup.c b/src/backend/access/nbtree/nbtdedup.c index 3175d6fdd1d..2434ce134bf 100644 --- a/src/backend/access/nbtree/nbtdedup.c +++ b/src/backend/access/nbtree/nbtdedup.c @@ -688,6 +688,9 @@ _bt_update_posting(BTVacuumPosting vacposting) else newsize = keysize; + Assert(newsize <= INDEX_SIZE_MASK); + Assert(newsize == MAXALIGN(newsize)); + /* Allocate memory using palloc0() (matches index_form_tuple()) */ itup = palloc0(newsize); memcpy(itup, origtuple, keysize); @@ -721,6 +724,7 @@ _bt_update_posting(BTVacuumPosting vacposting) Assert(ui == nhtids); Assert(d == vacposting->ndeletedtids); Assert(nhtids == 1 || _bt_posting_valid(itup)); + Assert(nhtids > 1 || ItemPointerIsValid(&itup->t_tid)); /* vacposting arg's itup will now point to updated version */ vacposting->itup = itup;