diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2021-02-15 09:28:08 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2021-02-15 09:28:08 +0200 |
commit | 54e51dcde03e5c746e8de6243c69fafdc8d0ec7a (patch) | |
tree | 527e7c66032792e3936b8637dd2e6a903a27b407 /src/include/nodes/execnodes.h | |
parent | 46d6e5f567906389c31c4fb3a2653da1885c18ee (diff) |
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
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r-- | src/include/nodes/execnodes.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index b6a88ff76b8..943931f65d0 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -394,12 +394,15 @@ typedef struct OnConflictSetState * relation, and perhaps also fire triggers. ResultRelInfo holds all the * information needed about a result relation, including indexes. * - * Normally, a ResultRelInfo refers to a table that is in the query's - * range table; then ri_RangeTableIndex is the RT index and ri_RelationDesc - * is just a copy of the relevant es_relations[] entry. But sometimes, - * in ResultRelInfos used only for triggers, ri_RangeTableIndex is zero - * and ri_RelationDesc is a separately-opened relcache pointer that needs - * to be separately closed. See ExecGetTriggerResultRel. + * Normally, a ResultRelInfo refers to a table that is in the query's range + * table; then ri_RangeTableIndex is the RT index and ri_RelationDesc is + * just a copy of the relevant es_relations[] entry. However, in some + * situations we create ResultRelInfos for relations that are not in the + * range table, namely for targets of tuple routing in a partitioned table, + * and when firing triggers in tables other than the target tables (See + * ExecGetTriggerResultRel). In these situations, ri_RangeTableIndex is 0 + * and ri_RelationDesc is a separately-opened relcache pointer that needs to + * be separately closed. */ typedef struct ResultRelInfo { |