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

Commit102f31a

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 parent5b6b5e5 commit102f31a

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
@@ -846,10 +846,12 @@ DefineDomain(CreateDomainStmt *stmt)
846846
pstate=make_parsestate(NULL);
847847

848848
/*
849-
* Cook the constr->raw_expr into an expression. Note:
850-
* name is strictly for error message
849+
* Cook the constr->raw_expr into an expression; copy it
850+
* in case the input is in plan cache. Note: name is used
851+
* only for error messages.
851852
*/
852-
defaultExpr=cookDefault(pstate,constr->raw_expr,
853+
defaultExpr=cookDefault(pstate,
854+
copyObject(constr->raw_expr),
853855
basetypeoid,
854856
basetypeMod,
855857
domainName,
@@ -2184,10 +2186,10 @@ AlterDomainDefault(List *names, Node *defaultRaw)
21842186
pstate=make_parsestate(NULL);
21852187

21862188
/*
2187-
* Cook thecolDef->raw_exprinto an expression. Note: Name is
2188-
*strictlyfor errormessage
2189+
* Cook theraw defaultinto an expression; copy it in case the input
2190+
*is in plan cache. Note: name is used onlyfor errormessages.
21892191
*/
2190-
defaultExpr=cookDefault(pstate,defaultRaw,
2192+
defaultExpr=cookDefault(pstate,copyObject(defaultRaw),
21912193
typTup->typbasetype,
21922194
typTup->typtypmod,
21932195
NameStr(typTup->typname),
@@ -3069,7 +3071,12 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
30693071
pstate->p_pre_columnref_hook=replace_domain_constraint_value;
30703072
pstate->p_ref_hook_state= (void*)domVal;
30713073

3072-
expr=transformExpr(pstate,constr->raw_expr,EXPR_KIND_DOMAIN_CHECK);
3074+
/*
3075+
* Transform the expression; first we must copy the input, in case it's in
3076+
* plan cache.
3077+
*/
3078+
expr=transformExpr(pstate,copyObject(constr->raw_expr),
3079+
EXPR_KIND_DOMAIN_CHECK);
30733080

30743081
/*
30753082
* Make sure it yields a boolean result.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp