mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Convert node test compile-time settings into run-time parameters
This converts COPY_PARSE_PLAN_TREES WRITE_READ_PARSE_PLAN_TREES RAW_EXPRESSION_COVERAGE_TEST into run-time parameters debug_copy_parse_plan_trees debug_write_read_parse_plan_trees debug_raw_expression_coverage_test They can be activated for tests using PG_TEST_INITDB_EXTRA_OPTS. The compile-time symbols are kept for build farm compatibility, but they now just determine the default value of the run-time settings. Furthermore, support for these settings is not compiled in at all unless assertions are enabled, or the new symbol DEBUG_NODE_TESTS_ENABLED is defined at compile time, or any of the legacy compile-time setting symbols are defined. So there is no run-time overhead in production builds. (This is similar to the handling of DISCARD_CACHES_ENABLED.) Discussion: https://www.postgresql.org/message-id/flat/30747bd8-f51e-4e0c-a310-a6e2c37ec8aa%40eisentraut.org
This commit is contained in:
@ -622,8 +622,10 @@ pg_parse_query(const char *query_string)
|
||||
if (log_parser_stats)
|
||||
ShowUsage("PARSER STATISTICS");
|
||||
|
||||
#ifdef COPY_PARSE_PLAN_TREES
|
||||
#ifdef DEBUG_NODE_TESTS_ENABLED
|
||||
|
||||
/* Optional debugging check: pass raw parsetrees through copyObject() */
|
||||
if (Debug_copy_parse_plan_trees)
|
||||
{
|
||||
List *new_list = copyObject(raw_parsetree_list);
|
||||
|
||||
@ -633,13 +635,12 @@ pg_parse_query(const char *query_string)
|
||||
else
|
||||
raw_parsetree_list = new_list;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optional debugging check: pass raw parsetrees through
|
||||
* outfuncs/readfuncs
|
||||
*/
|
||||
#ifdef WRITE_READ_PARSE_PLAN_TREES
|
||||
if (Debug_write_read_parse_plan_trees)
|
||||
{
|
||||
char *str = nodeToStringWithLocations(raw_parsetree_list);
|
||||
List *new_list = stringToNodeWithLocations(str);
|
||||
@ -651,7 +652,8 @@ pg_parse_query(const char *query_string)
|
||||
else
|
||||
raw_parsetree_list = new_list;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DEBUG_NODE_TESTS_ENABLED */
|
||||
|
||||
TRACE_POSTGRESQL_QUERY_PARSE_DONE(query_string);
|
||||
|
||||
@ -826,8 +828,10 @@ pg_rewrite_query(Query *query)
|
||||
if (log_parser_stats)
|
||||
ShowUsage("REWRITER STATISTICS");
|
||||
|
||||
#ifdef COPY_PARSE_PLAN_TREES
|
||||
#ifdef DEBUG_NODE_TESTS_ENABLED
|
||||
|
||||
/* Optional debugging check: pass querytree through copyObject() */
|
||||
if (Debug_copy_parse_plan_trees)
|
||||
{
|
||||
List *new_list;
|
||||
|
||||
@ -838,10 +842,9 @@ pg_rewrite_query(Query *query)
|
||||
else
|
||||
querytree_list = new_list;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WRITE_READ_PARSE_PLAN_TREES
|
||||
/* Optional debugging check: pass querytree through outfuncs/readfuncs */
|
||||
if (Debug_write_read_parse_plan_trees)
|
||||
{
|
||||
List *new_list = NIL;
|
||||
ListCell *lc;
|
||||
@ -868,7 +871,8 @@ pg_rewrite_query(Query *query)
|
||||
else
|
||||
querytree_list = new_list;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DEBUG_NODE_TESTS_ENABLED */
|
||||
|
||||
if (Debug_print_rewritten)
|
||||
elog_node_display(LOG, "rewritten parse tree", querytree_list,
|
||||
@ -906,8 +910,10 @@ pg_plan_query(Query *querytree, const char *query_string, int cursorOptions,
|
||||
if (log_planner_stats)
|
||||
ShowUsage("PLANNER STATISTICS");
|
||||
|
||||
#ifdef COPY_PARSE_PLAN_TREES
|
||||
#ifdef DEBUG_NODE_TESTS_ENABLED
|
||||
|
||||
/* Optional debugging check: pass plan tree through copyObject() */
|
||||
if (Debug_copy_parse_plan_trees)
|
||||
{
|
||||
PlannedStmt *new_plan = copyObject(plan);
|
||||
|
||||
@ -923,10 +929,9 @@ pg_plan_query(Query *querytree, const char *query_string, int cursorOptions,
|
||||
#endif
|
||||
plan = new_plan;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WRITE_READ_PARSE_PLAN_TREES
|
||||
/* Optional debugging check: pass plan tree through outfuncs/readfuncs */
|
||||
if (Debug_write_read_parse_plan_trees)
|
||||
{
|
||||
char *str;
|
||||
PlannedStmt *new_plan;
|
||||
@ -947,7 +952,8 @@ pg_plan_query(Query *querytree, const char *query_string, int cursorOptions,
|
||||
#endif
|
||||
plan = new_plan;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DEBUG_NODE_TESTS_ENABLED */
|
||||
|
||||
/*
|
||||
* Print plan if debugging.
|
||||
|
Reference in New Issue
Block a user