diff options
Diffstat (limited to 'src/backend/executor/nodeValuesscan.c')
-rw-r--r-- | src/backend/executor/nodeValuesscan.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/executor/nodeValuesscan.c b/src/backend/executor/nodeValuesscan.c index a39695a0c5f..0e9cb11cf3e 100644 --- a/src/backend/executor/nodeValuesscan.c +++ b/src/backend/executor/nodeValuesscan.c @@ -25,6 +25,7 @@ #include "executor/executor.h" #include "executor/nodeValuesscan.h" +#include "utils/expandeddatum.h" static TupleTableSlot *ValuesNext(ValuesScanState *node); @@ -94,6 +95,7 @@ ValuesNext(ValuesScanState *node) List *exprstatelist; Datum *values; bool *isnull; + Form_pg_attribute *att; ListCell *lc; int resind; @@ -129,6 +131,7 @@ ValuesNext(ValuesScanState *node) */ values = slot->tts_values; isnull = slot->tts_isnull; + att = slot->tts_tupleDescriptor->attrs; resind = 0; foreach(lc, exprstatelist) @@ -139,6 +142,17 @@ ValuesNext(ValuesScanState *node) econtext, &isnull[resind], NULL); + + /* + * We must force any R/W expanded datums to read-only state, in + * case they are multiply referenced in the plan node's output + * expressions, or in case we skip the output projection and the + * output column is multiply referenced in higher plan nodes. + */ + values[resind] = MakeExpandedObjectReadOnly(values[resind], + isnull[resind], + att[resind]->attlen); + resind++; } |