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: Make serialization of Nodes' scalar-array fields more robust.
Date: Wed, 20 Jul 2022 17:05:26 +0000
Message-ID: <E1oED8X-000S56-Om@gemulon.postgresql.org> (raw)

Make serialization of Nodes' scalar-array fields more robust.

When the ability to print variable-length-array fields was first
added to outfuncs.c, there was no corresponding read capability,
as it was used only for debug dumps of planner-internal Nodes.
Not a lot of thought seems to have been put into the output format:
it's just the space-separated array elements and nothing else.
Later such fields appeared in Plan nodes, and still later we grew
read support so that Plans could be transferred to parallel workers,
but the original text format wasn't rethought.  It seems inadequate
to me because (a) no cross-check is possible that we got the right
number of array entries, (b) we can't tell the difference between
a NULL pointer and a zero-length array, and (c) except for
WRITE_INDEX_ARRAY, we'd crash if a non-zero length is specified
when the pointer is NULL, a situation that can arise in some fields
that we currently conveniently avoid printing.

Since we're currently in a campaign to make the Node infrastructure
generally more it-just-works-without-thinking-about-it, now seems
like a good time to improve this.

Let's adopt a format similar to that used for Lists, that is "<>"
for a NULL pointer or "(item item item)" otherwise.  Also retool
the code to not have so many copies of the identical logic.

I bumped catversion out of an abundance of caution, although I think
that we don't use any such array fields in Nodes that can get into
the catalogs.

Discussion: https://postgr.es/m/1528424.1658272135@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2d04277121f2f8e18b65190f0dfa8ca97e9c29cb

Modified Files
--------------
src/backend/nodes/outfuncs.c     |  81 +++++++++++++++----------
src/backend/nodes/readfuncs.c    | 128 ++++++++++++---------------------------
src/include/catalog/catversion.h |   2 +-
3 files changed, 88 insertions(+), 123 deletions(-)



Message-ID: <E1oED8X-000S56-Om@gemulon.postgresql.org>
Permalink:  ../E1oED8X-000S56-Om@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oED8X-000S56-Om@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: Make serialization of Nodes' scalar-array fields more robust.
  In-Reply-To: <E1oED8X-000S56-Om@gemulon.postgresql.org>
  References: <E1oED8X-000S56-Om@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