diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-09-18 17:11:54 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-09-18 17:11:54 -0400 |
commit | d0cfc3d6a44af1756ca5be8cb2414da7b8bf20d5 (patch) | |
tree | 5fdb37364f283c7965c53512d2bd58e6d6699cca /src/backend/parser/parse_relation.c | |
parent | db1071d4ee9f0e348ab646e7c13184d480d40516 (diff) | |
download | postgresql-d0cfc3d6a44af1756ca5be8cb2414da7b8bf20d5.tar.gz postgresql-d0cfc3d6a44af1756ca5be8cb2414da7b8bf20d5.zip |
Add a debugging option to stress-test outfuncs.c and readfuncs.c.
In the normal course of operation, query trees will be serialized only if
they are stored as views or rules; and plan trees will be serialized only
if they get passed to parallel-query workers. This leaves an awful lot of
opportunity for bugs/oversights to not get detected, as indeed we've just
been reminded of the hard way.
To improve matters, this patch adds a new compile option
WRITE_READ_PARSE_PLAN_TREES, which is modeled on the longstanding option
COPY_PARSE_PLAN_TREES; but instead of passing all parse and plan trees
through copyObject, it passes them through nodeToString + stringToNode.
Enabling this option in a buildfarm animal or two will catch problems
at least for cases that are exercised by the regression tests.
A small problem with this idea is that readfuncs.c historically has
discarded location fields, on the reasonable grounds that parse
locations in a retrieved view are not relevant to the current query.
But doing that in WRITE_READ_PARSE_PLAN_TREES breaks pg_stat_statements,
and it could cause problems for future improvements that might try to
report error locations at runtime. To fix that, provide a variant
behavior in readfuncs.c that makes it restore location fields when
told to.
In passing, const-ify the string arguments of stringToNode and its
subsidiary functions, just because it annoyed me that they weren't
const already.
Discussion: https://postgr.es/m/17114.1537138992@sss.pgh.pa.us
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r-- | src/backend/parser/parse_relation.c | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index bf5df26009a..60b8de0f95d 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -1335,7 +1335,6 @@ addRangeTableEntryForSubquery(ParseState *pstate, Assert(pstate != NULL); rte->rtekind = RTE_SUBQUERY; - rte->relid = InvalidOid; rte->subquery = subquery; rte->alias = alias; |