pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add a debugging option to stress-test outfuncs.c and readfuncs.c
Date: Tue, 18 Sep 2018 21:12:08 +0000
Message-ID: <E1g2NI0-0007PV-2r@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d0cfc3d6a44af1756ca5be8cb2414da7b8bf20d5

Modified Files
--------------
src/backend/nodes/read.c            | 68 ++++++++++++++++++++++++++++------
src/backend/nodes/readfuncs.c       | 31 +++++++++++-----
src/backend/parser/parse_relation.c |  1 -
src/backend/tcop/postgres.c         | 74 ++++++++++++++++++++++++++++++++++++-
src/include/nodes/nodes.h           |  5 ++-
src/include/nodes/readfuncs.h       | 13 +++++--
src/include/pg_config_manual.h      |  7 ++++
7 files changed, 170 insertions(+), 29 deletions(-)



Message-ID: <E1g2NI0-0007PV-2r@gemulon.postgresql.org>
Permalink:  ../E1g2NI0-0007PV-2r@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1g2NI0-0007PV-2r@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Add a debugging option to stress-test outfuncs.c and readfuncs.c
  In-Reply-To: <E1g2NI0-0007PV-2r@gemulon.postgresql.org>
  References: <E1g2NI0-0007PV-2r@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox