Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b8b356

Browse files
committed
Avoid scribbling on input node tree in CREATE/ALTER DOMAIN.
This works fine in the "simple Query" code path; but if thestatement is in the plan cache then it's corrupted for futurere-execution. Apply copyObject() to protect the originaltree from modification, as we've done elsewhere.This narrow fix is applied only to the back branches. In HEAD,the problem was fixed more generally by commit7c337b6; butthat changed ProcessUtility's API, so it's infeasible toback-patch.Per bug #17053 from Charles Samborski.Discussion:https://postgr.es/m/931771.1623893989@sss.pgh.pa.usDiscussion:https://postgr.es/m/17053-3ca3f501bbc212b4@postgresql.org
1 parent0d3b69a commit4b8b356

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

‎src/backend/commands/typecmds.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,12 @@ DefineDomain(CreateDomainStmt *stmt)
908908
pstate=make_parsestate(NULL);
909909

910910
/*
911-
* Cook the constr->raw_expr into an expression. Note:
912-
* name is strictly for error message
911+
* Cook the constr->raw_expr into an expression; copy it
912+
* in case the input is in plan cache. Note: name is used
913+
* only for error messages.
913914
*/
914-
defaultExpr=cookDefault(pstate,constr->raw_expr,
915+
defaultExpr=cookDefault(pstate,
916+
copyObject(constr->raw_expr),
915917
basetypeoid,
916918
basetypeMod,
917919
domainName);
@@ -2262,10 +2264,10 @@ AlterDomainDefault(List *names, Node *defaultRaw)
22622264
pstate=make_parsestate(NULL);
22632265

22642266
/*
2265-
* Cook thecolDef->raw_exprinto an expression. Note: Name is
2266-
*strictlyfor errormessage
2267+
* Cook theraw defaultinto an expression; copy it in case the input
2268+
*is in plan cache. Note: name is used onlyfor errormessages.
22672269
*/
2268-
defaultExpr=cookDefault(pstate,defaultRaw,
2270+
defaultExpr=cookDefault(pstate,copyObject(defaultRaw),
22692271
typTup->typbasetype,
22702272
typTup->typtypmod,
22712273
NameStr(typTup->typname));
@@ -3136,7 +3138,12 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
31363138
pstate->p_pre_columnref_hook=replace_domain_constraint_value;
31373139
pstate->p_ref_hook_state= (void*)domVal;
31383140

3139-
expr=transformExpr(pstate,constr->raw_expr,EXPR_KIND_DOMAIN_CHECK);
3141+
/*
3142+
* Transform the expression; first we must copy the input, in case it's in
3143+
* plan cache.
3144+
*/
3145+
expr=transformExpr(pstate,copyObject(constr->raw_expr),
3146+
EXPR_KIND_DOMAIN_CHECK);
31403147

31413148
/*
31423149
* Make sure it yields a boolean result.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp