From 1dee8b709983593f93e54e37df84ad604f6e0c78 Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Thu, 8 Feb 2024 20:24:22 +0100 Subject: [PATCH v8 5/8] nodeToString: omit serializing NULL datums in Const nodes This saves some bytes in certain cases, and aligns its serialization conditions with other field's serialization conditions. --- src/backend/nodes/outfuncs.c | 8 ++++---- src/backend/nodes/readfuncs.c | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 3789e45c53..a6c2b5bfc5 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -503,11 +503,11 @@ _outConst(StringInfo str, const Const *node) WRITE_BOOL_FIELD(constisnull); WRITE_LOCATION_FIELD(location); - appendStringInfoString(str, " :constvalue "); - if (node->constisnull) - appendStringInfoString(str, "<>"); - else + if (!node->constisnull) + { + appendStringInfoString(str, " :constvalue "); outDatum(str, node->constvalue, node->constlen, node->constbyval); + } } static void diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index e56ab5d060..ad13545de4 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -375,11 +375,13 @@ _readConst(void) READ_BOOL_FIELD(constisnull); READ_LOCATION_FIELD(location); - token = pg_strtok(&length); /* skip :constvalue */ - if (local_node->constisnull) - token = pg_strtok(&length); /* skip "<>" */ - else + if ((token = pg_strtok_fieldname(":constvalue", &length))) local_node->constvalue = readDatum(local_node->constbyval); + else + { + /* value was omitted */ + Assert(local_node->constisnull); + } READ_DONE(); } -- 2.40.1