Skip to content

Commit c12f214

Browse files
committed
CTEs with side effects
1 parent a8aedd4 commit c12f214

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/nodes/modify_hypertable.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,16 @@ modify_hypertable_begin(CustomScanState *node, EState *estate, int eflags)
118118
node->custom_ps = NIL;
119119

120120
/*
121-
* With plain EXPLAIN, the node is not actually executed, so we have to
122-
* finish the child plan state initialization now.
121+
* In some cases, we have to initialize the child plan states now w/o
122+
* deferral.
123+
*
124+
* 1) With plain EXPLAIN, when the node is not actually executed.
125+
*
126+
* 2) For data-modifying CTEs that are not used by the main query. These are
127+
* only executed as ExecPostprocessPlan step, after the main query finishes,
128+
* and need to be initialized before that.
123129
*/
124-
if (eflags & EXEC_FLAG_EXPLAIN_ONLY)
130+
if ((eflags & EXEC_FLAG_EXPLAIN_ONLY) || !mt->canSetTag)
125131
{
126132
modify_hypertable_init_child_plan_states(node);
127133
}

0 commit comments

Comments
 (0)