diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-03-22 09:13:35 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-03-22 09:49:12 +0100 |
commit | d20d8fbd3e4d327dd0778a02d5661b51f4f6423a (patch) | |
tree | 41e1a5fd7d7c8ee46aa356c8afde9da51c264a95 /src/backend/tcop/postgres.c | |
parent | 6ae701b4378db2284c77314560e95a93d0ba9484 (diff) | |
download | postgresql-d20d8fbd3e4d327dd0778a02d5661b51f4f6423a.tar.gz postgresql-d20d8fbd3e4d327dd0778a02d5661b51f4f6423a.zip |
Do not output actual value of location fields in node serialization by default
This changes nodeToString() to not output the actual value of location
fields in nodes, but instead it writes -1. This mirrors the fact that
stringToNode() also does not read location field values but always
stores -1.
For most uses of nodeToString(), which is to store nodes in catalog
fields, this is more useful. We don't store original query texts in
catalogs, so any lingering query location values are not meaningful.
For debugging purposes, there is a new nodeToStringWithLocations(),
which mirrors the existing stringToNodeWithLocations(). This is used
for WRITE_READ_PARSE_PLAN_TREES and nodes/print.c functions, which
covers all the debugging uses.
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAEze2WgrCiR3JZmWyB0YTc8HV7ewRdx13j0CqD6mVkYAW+SFGQ@mail.gmail.com
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index fd4199a0983..76f48b13d20 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -641,7 +641,7 @@ pg_parse_query(const char *query_string) */ #ifdef WRITE_READ_PARSE_PLAN_TREES { - char *str = nodeToString(raw_parsetree_list); + char *str = nodeToStringWithLocations(raw_parsetree_list); List *new_list = stringToNodeWithLocations(str); pfree(str); @@ -849,7 +849,7 @@ pg_rewrite_query(Query *query) foreach(lc, querytree_list) { Query *curr_query = lfirst_node(Query, lc); - char *str = nodeToString(curr_query); + char *str = nodeToStringWithLocations(curr_query); Query *new_query = stringToNodeWithLocations(str); /* @@ -931,7 +931,7 @@ pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, char *str; PlannedStmt *new_plan; - str = nodeToString(plan); + str = nodeToStringWithLocations(plan); new_plan = stringToNodeWithLocations(str); pfree(str); |