summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/prep/preptlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/prep/preptlist.c')
-rw-r--r--src/backend/optimizer/prep/preptlist.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index e9434580d6d..e9151c9589a 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -46,7 +46,8 @@
#include "parser/parsetree.h"
#include "utils/rel.h"
-static List *expand_insert_targetlist(List *tlist, Relation rel);
+static List *expand_insert_targetlist(PlannerInfo *root, List *tlist,
+ Relation rel);
/*
@@ -102,7 +103,7 @@ preprocess_targetlist(PlannerInfo *root)
*/
tlist = parse->targetList;
if (command_type == CMD_INSERT)
- tlist = expand_insert_targetlist(tlist, target_relation);
+ tlist = expand_insert_targetlist(root, tlist, target_relation);
else if (command_type == CMD_UPDATE)
root->update_colnos = extract_update_targetlist_colnos(tlist);
@@ -292,7 +293,7 @@ extract_update_targetlist_colnos(List *tlist)
* but now this code is only applied to INSERT targetlists.
*/
static List *
-expand_insert_targetlist(List *tlist, Relation rel)
+expand_insert_targetlist(PlannerInfo *root, List *tlist, Relation rel)
{
List *new_tlist = NIL;
ListCell *tlist_item;
@@ -346,26 +347,18 @@ expand_insert_targetlist(List *tlist, Relation rel)
* confuse code comparing the finished plan to the target
* relation, however.
*/
- Oid atttype = att_tup->atttypid;
- Oid attcollation = att_tup->attcollation;
Node *new_expr;
if (!att_tup->attisdropped)
{
- new_expr = (Node *) makeConst(atttype,
- -1,
- attcollation,
- att_tup->attlen,
- (Datum) 0,
- true, /* isnull */
- att_tup->attbyval);
- new_expr = coerce_to_domain(new_expr,
- InvalidOid, -1,
- atttype,
- COERCION_IMPLICIT,
- COERCE_IMPLICIT_CAST,
- -1,
- false);
+ new_expr = coerce_null_to_domain(att_tup->atttypid,
+ att_tup->atttypmod,
+ att_tup->attcollation,
+ att_tup->attlen,
+ att_tup->attbyval);
+ /* Must run expression preprocessing on any non-const nodes */
+ if (!IsA(new_expr, Const))
+ new_expr = eval_const_expressions(root, new_expr);
}
else
{