Add code so that when COPY_PARSE_PLAN_TREES is defined, the copy and
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 17 Feb 2007 19:33:32 +0000 (19:33 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 17 Feb 2007 19:33:32 +0000 (19:33 +0000)
equal functions are checked for raw parse trees as well as post-analysis
trees.  This was never very important before, but the upcoming plan cache
control module will need to be able to do copyObject() on raw parse trees.

src/backend/tcop/postgres.c

index f38b0c223fbec329b5a444b65f3d6ff3654eda7f..eac934f27cfed4e90b729178d69f12e0d813ffa5 100644 (file)
@@ -540,6 +540,19 @@ pg_parse_query(const char *query_string)
        if (log_parser_stats)
                ShowUsage("PARSER STATISTICS");
 
+#ifdef COPY_PARSE_PLAN_TREES
+       /* Optional debugging check: pass raw parsetrees through copyObject() */
+       {
+               List       *new_list = (List *) copyObject(raw_parsetree_list);
+
+               /* This checks both copyObject() and the equal() routines... */
+               if (!equal(new_list, raw_parsetree_list))
+                       elog(WARNING, "copyObject() failed to produce an equal raw parse tree");
+               else
+                       raw_parsetree_list = new_list;
+       }
+#endif
+
        return raw_parsetree_list;
 }