pgsql: Make ExecGetInsertedCols() and friends more robust and improve c

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make ExecGetInsertedCols() and friends more robust and improve c
Date: 2021-02-15 07:31:46
Message-ID: E1lBYME-00006a-Kt@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make ExecGetInsertedCols() and friends more robust and improve comments.

If ExecGetInsertedCols(), ExecGetUpdatedCols() or ExecGetExtraUpdatedCols()
were called with a ResultRelInfo that's not in the range table and isn't a
partition routing target, the functions would dereference a NULL pointer,
relinfo->ri_RootResultRelInfo. Such ResultRelInfos are created when firing
RI triggers in tables that are not modified directly. None of the current
callers of these functions pass such relations, so this isn't a live bug,
but let's make them more robust.

Also update comment in ResultRelInfo; after commit 6214e2b228,
ri_RangeTableIndex is zero for ResultRelInfos created for partition tuple
routing.

Noted by Coverity. Backpatch down to v11, like commit 6214e2b228.

Reviewed-by: Tom Lane, Amit Langote

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6e437ce5a6b64c443cf7c907db0988bf571e6042

Modified Files
--------------
src/backend/executor/execUtils.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2021-02-15 10:35:59 Re: pgsql: Allow multiple xacts during table sync in logical replication.
Previous Message Fujii Masao 2021-02-15 06:15:58 pgsql: Display the time when the process started waiting for the lock,