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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Make serialization of Nodes' scalar-array fields more robust.
Дата
Msg-id E1oED8X-000S56-Om@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Document the ability to specify TableAM for pgbench
Следующее
От: Jeff Davis
Дата:
Сообщение: pgsql: Process shared_preload_libraries in single-user mode.