pgsql: Add nkeys parameter to recheck_matched_pk_tuple()

From: Amit Langote <amitlan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add nkeys parameter to recheck_matched_pk_tuple()
Date: 2026-04-09 07:36:32
Message-ID: E1wAjwG-0006rq-0y@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add nkeys parameter to recheck_matched_pk_tuple()

The function looped over ii_NumIndexKeyAttrs elements of the skeys
array, but one caller (ri_FastPathFlushArray) passes a one-element
array since it only handles single-column FKs. The function
signature did not communicate this constraint, which static analysis
flags as a potential out-of-bounds read.

Add an nkeys parameter and assert that it matches
ii_NumIndexKeyAttrs, then use it in the loop. The call sites
already know the key count.

Reported-by: Evan Montgomery-Recht <montge(at)mianetworks(dot)net>
Discussion: https://postgr.es/m/CAEg7pwcKf01FmDqFAf-Hzu_pYnMYScY_Otid-pe9uw3BJ6gq9g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e1cc57fabd6c32fcb740d62da90443f8c708951e

Modified Files
--------------
src/backend/utils/adt/ri_triggers.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Richard Guo 2026-04-09 07:45:00 pgsql: Strip PlaceHolderVars from partition pruning operands
Previous Message Fujii Masao 2026-04-09 06:32:01 pgsql: Fix ABI break by moving PROCSIG_SLOTSYNC_MESSAGE in ProcSignalRe