Skip to content

Commit bf4ecb8

Browse files
committed
Fix expression execution in update trigger
1 parent 7e4709f commit bf4ecb8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/partition_creation.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,9 @@ get_part_expression_info(Oid relid, const char *expr_string,
18441844
expr_node = eval_const_expressions(NULL, expr_node);
18451845
validate_part_expression(expr_node, NULL);
18461846
if (contain_mutable_functions(expr_node))
1847-
elog(ERROR, "Expression should not contain mutable functions");
1847+
ereport(ERROR,
1848+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1849+
errmsg("functions in partitioning expression must be marked IMMUTABLE")));
18481850

18491851
out_string = nodeToString(expr_node);
18501852

src/pl_funcs.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,11 +1081,7 @@ change_vars_to_consts(Node *node, struct change_vars_context *ctx)
10811081
if (varattno == 0)
10821082
elog(ERROR, "Couldn't find attribute used in expression in child relation");
10831083

1084-
/*
1085-
* we get atttribute type using tuple description of child relation,
1086-
* because it could be changed earlier, so Var of parent relation
1087-
* will not be valid anymore.
1088-
*/
1084+
/* we suppose that type can be different from parent */
10891085
atttype = ctx->tuple_desc->attrs[varattno - 1]->atttypid;
10901086

10911087
tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(atttype));
@@ -1112,7 +1108,7 @@ change_vars_to_consts(Node *node, struct change_vars_context *ctx)
11121108
&new_const->constisnull);
11131109
return (Node *) new_const;
11141110
}
1115-
return expression_tree_mutator(node, change_vars_to_consts, NULL);
1111+
return expression_tree_mutator(node, change_vars_to_consts, (void *) ctx);
11161112
}
11171113

11181114
static ExprState *

0 commit comments

Comments
 (0)