aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execUtils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-01-15 14:06:46 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2023-01-15 14:06:46 -0500
commita8f7687a0b8645697b48cc40fd1a73d455d0c1fc (patch)
treeb7bec95a155ca7207085f0e97a14e65e47c3396c /src/backend/executor/execUtils.c
parent40015cf8ec7a0384a0320c11a31fdeebba4b8e15 (diff)
downloadpostgresql-a8f7687a0b8645697b48cc40fd1a73d455d0c1fc.tar.gz
postgresql-a8f7687a0b8645697b48cc40fd1a73d455d0c1fc.zip
Make new GENERATED-expressions code more bulletproof.
In commit 8bf6ec3ba I assumed that no code path could reach ExecGetExtraUpdatedCols without having gone through ExecInitStoredGenerated. That turns out not to be the case in logical replication: if there's an ON UPDATE trigger on the target table, trigger.c will call this code before anybody has set up its generated columns. Having seen that, I don't have a lot of faith in there not being other such paths. ExecGetExtraUpdatedCols can call ExecInitStoredGenerated for itself, as long as we are willing to assume that it is only called in CMD_UPDATE operations, which on the whole seems like a safer leap of faith. Per report from Vitaly Davydov. Discussion: https://postgr.es/m/d259d69652b8c2ff50e14cda3c236c7f@postgrespro.ru
Diffstat (limited to 'src/backend/executor/execUtils.c')
-rw-r--r--src/backend/executor/execUtils.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 122de068022..7284a23dc9a 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -52,6 +52,7 @@
#include "access/transam.h"
#include "executor/executor.h"
#include "executor/execPartition.h"
+#include "executor/nodeModifyTable.h"
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
@@ -1332,8 +1333,9 @@ ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate)
{
ListCell *lc;
- /* Assert that ExecInitStoredGenerated has been called. */
- Assert(relinfo->ri_GeneratedExprs != NULL);
+ /* In some code paths we can reach here before initializing the info */
+ if (relinfo->ri_GeneratedExprs == NULL)
+ ExecInitStoredGenerated(relinfo, estate, CMD_UPDATE);
foreach(lc, estate->es_resultrelinfo_extra)
{
ResultRelInfoExtra *rextra = (ResultRelInfoExtra *) lfirst(lc);