]> granicus.if.org Git - postgresql/commitdiff
Fix bogus range_table_mutator() logic for RangeTblEntry.tablesample.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Jun 2015 15:41:45 +0000 (11:41 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 19 Jun 2015 15:41:56 +0000 (11:41 -0400)
Must make a copy of the TableSampleClause node; the previous coding
modified the input data structure in-place.

Petr Jelinek

src/backend/nodes/nodeFuncs.c

index a2bcca5b75a06314133044461574c02c6234a95a..b1e3e6e489320086dce3500b1418178095e99714 100644 (file)
@@ -2870,10 +2870,14 @@ range_table_mutator(List *rtable,
                        case RTE_RELATION:
                                if (rte->tablesample)
                                {
-                                       MUTATE(rte->tablesample->args, rte->tablesample->args,
+                                       CHECKFLATCOPY(newrte->tablesample, rte->tablesample,
+                                                                 TableSampleClause);
+                                       MUTATE(newrte->tablesample->args,
+                                                  newrte->tablesample->args,
                                                   List *);
-                                       MUTATE(rte->tablesample->repeatable,
-                                                  rte->tablesample->repeatable, Node *);
+                                       MUTATE(newrte->tablesample->repeatable,
+                                                  newrte->tablesample->repeatable,
+                                                  Node *);
                                }
                                break;
                        case RTE_CTE: