mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +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:
@@ -50,6 +50,7 @@
|
||||
#include "parser/parsetree.h"
|
||||
#include "utils/backend_status.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
@@ -84,7 +85,7 @@ static Query *transformCallStmt(ParseState *pstate,
|
||||
CallStmt *stmt);
|
||||
static void transformLockingClause(ParseState *pstate, Query *qry,
|
||||
LockingClause *lc, bool pushedDown);
|
||||
#ifdef RAW_EXPRESSION_COVERAGE_TEST
|
||||
#ifdef DEBUG_NODE_TESTS_ENABLED
|
||||
static bool test_raw_expression_coverage(Node *node, void *context);
|
||||
#endif
|
||||
|
||||
@@ -312,25 +313,30 @@ transformStmt(ParseState *pstate, Node *parseTree)
|
||||
{
|
||||
Query *result;
|
||||
|
||||
#ifdef DEBUG_NODE_TESTS_ENABLED
|
||||
|
||||
/*
|
||||
* We apply RAW_EXPRESSION_COVERAGE_TEST testing to basic DML statements;
|
||||
* we can't just run it on everything because raw_expression_tree_walker()
|
||||
* doesn't claim to handle utility statements.
|
||||
* We apply debug_raw_expression_coverage_test testing to basic DML
|
||||
* statements; we can't just run it on everything because
|
||||
* raw_expression_tree_walker() doesn't claim to handle utility
|
||||
* statements.
|
||||
*/
|
||||
#ifdef RAW_EXPRESSION_COVERAGE_TEST
|
||||
switch (nodeTag(parseTree))
|
||||
if (Debug_raw_expression_coverage_test)
|
||||
{
|
||||
case T_SelectStmt:
|
||||
case T_InsertStmt:
|
||||
case T_UpdateStmt:
|
||||
case T_DeleteStmt:
|
||||
case T_MergeStmt:
|
||||
(void) test_raw_expression_coverage(parseTree, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (nodeTag(parseTree))
|
||||
{
|
||||
case T_SelectStmt:
|
||||
case T_InsertStmt:
|
||||
case T_UpdateStmt:
|
||||
case T_DeleteStmt:
|
||||
case T_MergeStmt:
|
||||
(void) test_raw_expression_coverage(parseTree, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* RAW_EXPRESSION_COVERAGE_TEST */
|
||||
#endif /* DEBUG_NODE_TESTS_ENABLED */
|
||||
|
||||
/*
|
||||
* Caution: when changing the set of statement types that have non-default
|
||||
@@ -3575,6 +3581,7 @@ applyLockingClause(Query *qry, Index rtindex,
|
||||
qry->rowMarks = lappend(qry->rowMarks, rc);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_NODE_TESTS_ENABLED
|
||||
/*
|
||||
* Coverage testing for raw_expression_tree_walker().
|
||||
*
|
||||
@@ -3583,8 +3590,6 @@ applyLockingClause(Query *qry, Index rtindex,
|
||||
* applied in limited cases involving CTEs, and we don't really want to have
|
||||
* to test everything inside as well as outside a CTE.
|
||||
*/
|
||||
#ifdef RAW_EXPRESSION_COVERAGE_TEST
|
||||
|
||||
static bool
|
||||
test_raw_expression_coverage(Node *node, void *context)
|
||||
{
|
||||
@@ -3594,5 +3599,4 @@ test_raw_expression_coverage(Node *node, void *context)
|
||||
test_raw_expression_coverage,
|
||||
context);
|
||||
}
|
||||
|
||||
#endif /* RAW_EXPRESSION_COVERAGE_TEST */
|
||||
#endif /* DEBUG_NODE_TESTS_ENABLED */
|
||||
|
Reference in New Issue
Block a user