|
11 | 11 | * Hence these functions are now called at the start of execution of their
|
12 | 12 | * respective utility commands.
|
13 | 13 | *
|
14 |
| - * NOTE: in general we must avoid scribbling on the passed-in raw parse |
15 |
| - * tree, since it might be in a plan cache. The simplest solution is |
16 |
| - * a quick copyObject() call before manipulating the query tree. |
17 |
| - * |
18 | 14 | *
|
19 | 15 | * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
|
20 | 16 | * Portions Copyright (c) 1994, Regents of the University of California
|
@@ -177,12 +173,6 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
177 | 173 | Oid existing_relid;
|
178 | 174 | ParseCallbackState pcbstate;
|
179 | 175 |
|
180 |
| - /* |
181 |
| - * We must not scribble on the passed-in CreateStmt, so copy it. (This is |
182 |
| - * overkill, but easy.) |
183 |
| - */ |
184 |
| - stmt = copyObject(stmt); |
185 |
| - |
186 | 176 | /* Set up pstate */
|
187 | 177 | pstate = make_parsestate(NULL);
|
188 | 178 | pstate->p_sourcetext = queryString;
|
@@ -2824,12 +2814,6 @@ transformIndexStmt(Oid relid, IndexStmt *stmt, const char *queryString)
|
2824 | 2814 | if (stmt->transformed)
|
2825 | 2815 | return stmt;
|
2826 | 2816 |
|
2827 |
| - /* |
2828 |
| - * We must not scribble on the passed-in IndexStmt, so copy it. (This is |
2829 |
| - * overkill, but easy.) |
2830 |
| - */ |
2831 |
| - stmt = copyObject(stmt); |
2832 |
| - |
2833 | 2817 | /* Set up pstate */
|
2834 | 2818 | pstate = make_parsestate(NULL);
|
2835 | 2819 | pstate->p_sourcetext = queryString;
|
@@ -2925,12 +2909,6 @@ transformStatsStmt(Oid relid, CreateStatsStmt *stmt, const char *queryString)
|
2925 | 2909 | if (stmt->transformed)
|
2926 | 2910 | return stmt;
|
2927 | 2911 |
|
2928 |
| - /* |
2929 |
| - * We must not scribble on the passed-in CreateStatsStmt, so copy it. |
2930 |
| - * (This is overkill, but easy.) |
2931 |
| - */ |
2932 |
| - stmt = copyObject(stmt); |
2933 |
| - |
2934 | 2912 | /* Set up pstate */
|
2935 | 2913 | pstate = make_parsestate(NULL);
|
2936 | 2914 | pstate->p_sourcetext = queryString;
|
@@ -2993,9 +2971,6 @@ transformStatsStmt(Oid relid, CreateStatsStmt *stmt, const char *queryString)
|
2993 | 2971 | *
|
2994 | 2972 | * actions and whereClause are output parameters that receive the
|
2995 | 2973 | * transformed results.
|
2996 |
| - * |
2997 |
| - * Note that we must not scribble on the passed-in RuleStmt, so we do |
2998 |
| - * copyObject() on the actions and WHERE clause. |
2999 | 2974 | */
|
3000 | 2975 | void
|
3001 | 2976 | transformRuleStmt(RuleStmt *stmt, const char *queryString,
|
@@ -3070,7 +3045,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString,
|
3070 | 3045 |
|
3071 | 3046 | /* take care of the where clause */
|
3072 | 3047 | *whereClause = transformWhereClause(pstate,
|
3073 |
| - (Node *) copyObject(stmt->whereClause), |
| 3048 | + stmt->whereClause, |
3074 | 3049 | EXPR_KIND_WHERE,
|
3075 | 3050 | "WHERE");
|
3076 | 3051 | /* we have to fix its collations too */
|
@@ -3142,8 +3117,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString,
|
3142 | 3117 | addNSItemToQuery(sub_pstate, newnsitem, false, true, false);
|
3143 | 3118 |
|
3144 | 3119 | /* Transform the rule action statement */
|
3145 |
| - top_subqry = transformStmt(sub_pstate, |
3146 |
| - (Node *) copyObject(action)); |
| 3120 | + top_subqry = transformStmt(sub_pstate, action); |
3147 | 3121 |
|
3148 | 3122 | /*
|
3149 | 3123 | * We cannot support utility-statement actions (eg NOTIFY) with
|
@@ -3325,12 +3299,6 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
3325 | 3299 | AlterTableCmd *newcmd;
|
3326 | 3300 | ParseNamespaceItem *nsitem;
|
3327 | 3301 |
|
3328 |
| - /* |
3329 |
| - * We must not scribble on the passed-in AlterTableStmt, so copy it. (This |
3330 |
| - * is overkill, but easy.) |
3331 |
| - */ |
3332 |
| - stmt = copyObject(stmt); |
3333 |
| - |
3334 | 3302 | /* Caller is responsible for locking the relation */
|
3335 | 3303 | rel = relation_open(relid, NoLock);
|
3336 | 3304 | tupdesc = RelationGetDescr(rel);
|
|
0 commit comments