diff options
| author | Peter Eisentraut | 2024-08-01 07:37:44 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2024-08-01 08:09:18 +0000 |
| commit | a292c98d62ddc0ad681f772ab91bf68ee399cb4b (patch) | |
| tree | 331bcd4483c3f0b006b29e1fa094396fc599855a /src/backend/nodes | |
| parent | a67da49e1d983fc7662f7854e9eec5debbd14446 (diff) | |
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
Diffstat (limited to 'src/backend/nodes')
| -rw-r--r-- | src/backend/nodes/README | 9 | ||||
| -rw-r--r-- | src/backend/nodes/read.c | 12 | ||||
| -rw-r--r-- | src/backend/nodes/readfuncs.c | 4 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/backend/nodes/README b/src/backend/nodes/README index 52364470205..f8bbd605386 100644 --- a/src/backend/nodes/README +++ b/src/backend/nodes/README @@ -98,10 +98,11 @@ Suppose you want to define a node Foo: node types to find all the places to touch. (Except for frequently-created nodes, don't bother writing a creator function in makefuncs.c.) -4. Consider testing your new code with COPY_PARSE_PLAN_TREES, - WRITE_READ_PARSE_PLAN_TREES, and RAW_EXPRESSION_COVERAGE_TEST to ensure - support has been added everywhere that it's necessary; see - pg_config_manual.h about these. +4. Consider testing your new code with debug_copy_parse_plan_trees, + debug_write_read_parse_plan_trees, and + debug_raw_expression_coverage_test to ensure support has been added + everywhere that it's necessary (e.g., run the tests with + PG_TEST_INITDB_EXTRA_OPTS='-c debug_...=on'). Adding a new node type moves the numbers associated with existing tags, so you'll need to recompile the whole tree after doing this. diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index 4eb42445c52..190099e5cf3 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -32,7 +32,7 @@ static const char *pg_strtok_ptr = NULL; /* State flag that determines how readfuncs.c should treat location fields */ -#ifdef WRITE_READ_PARSE_PLAN_TREES +#ifdef DEBUG_NODE_TESTS_ENABLED bool restore_location_fields = false; #endif @@ -43,14 +43,14 @@ bool restore_location_fields = false; * * restore_loc_fields instructs readfuncs.c whether to restore location * fields rather than set them to -1. This is currently only supported - * in builds with the WRITE_READ_PARSE_PLAN_TREES debugging flag set. + * in builds with DEBUG_NODE_TESTS_ENABLED defined. */ static void * stringToNodeInternal(const char *str, bool restore_loc_fields) { void *retval; const char *save_strtok; -#ifdef WRITE_READ_PARSE_PLAN_TREES +#ifdef DEBUG_NODE_TESTS_ENABLED bool save_restore_location_fields; #endif @@ -67,7 +67,7 @@ stringToNodeInternal(const char *str, bool restore_loc_fields) /* * If enabled, likewise save/restore the location field handling flag. */ -#ifdef WRITE_READ_PARSE_PLAN_TREES +#ifdef DEBUG_NODE_TESTS_ENABLED save_restore_location_fields = restore_location_fields; restore_location_fields = restore_loc_fields; #endif @@ -76,7 +76,7 @@ stringToNodeInternal(const char *str, bool restore_loc_fields) pg_strtok_ptr = save_strtok; -#ifdef WRITE_READ_PARSE_PLAN_TREES +#ifdef DEBUG_NODE_TESTS_ENABLED restore_location_fields = save_restore_location_fields; #endif @@ -92,7 +92,7 @@ stringToNode(const char *str) return stringToNodeInternal(str, false); } -#ifdef WRITE_READ_PARSE_PLAN_TREES +#ifdef DEBUG_NODE_TESTS_ENABLED void * stringToNodeWithLocations(const char *str) diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index c4d01a441a0..b47950764a4 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -19,7 +19,7 @@ * * However, if restore_location_fields is true, we do restore location * fields from the string. This is currently intended only for use by the - * WRITE_READ_PARSE_PLAN_TREES test code, which doesn't want to cause + * debug_write_read_parse_plan_trees test code, which doesn't want to cause * any change in the node contents. * *------------------------------------------------------------------------- @@ -118,7 +118,7 @@ local_node->fldname = nullable_string(token, length) /* Read a parse location field (and possibly throw away the value) */ -#ifdef WRITE_READ_PARSE_PLAN_TREES +#ifdef DEBUG_NODE_TESTS_ENABLED #define READ_LOCATION_FIELD(fldname) \ token = pg_strtok(&length); /* skip :fldname */ \ token = pg_strtok(&length); /* get field value */ \ |
