pg.ddx.io pgsql-hackers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Clarification of nodeToString() use cases 1+ messages / 1 participants [nested] [flat]
Commits from this thread: 2018-09-17 07a3af0ff8 486cfb3b8c a552e3bc50 Fix parsetree representation of XMLTABLE(XMLNAMESPACES(DEFAULT ...)).
* Clarification of nodeToString() use cases @ 2018-09-16 11:43 Andrey Lepikhov <a.lepikhov@postgrespro.ru> 0 siblings, 0 replies; 1+ messages in thread From: Andrey Lepikhov @ 2018-09-16 11:43 UTC (permalink / raw) To: pgsql-hackers Hi, Hackers! In the AQO project (Adaptive Query Optimization) [1] the nodeToString() function is used by the planner to convert an query parse tree into a string to generate a hash value [2]. In PostgreSQL v.11 call nodeToString(parse) segfaulted. The reason is: parse tree node for XMLNAMESPACES clause has null pointer in the case of DEFAULT namespace (the pointer will be initialized at executor on the first call). Function _outValue() uses value->val.str[0] [3] without checking of value->val.str. I want to know, which of next options is correct: 1. Converting a parse tree into string with nodeToString() is illegal operation. We need to add a comment to the description of nodeToString(). 2. We can use nodeToString() for parse tree convertation. In this case we need to check node variable 'value->val.str' to NULL pointer (Now I use this approach, see attachment). [1] https://github.com/postgrespro/aqo [2] hash.c, line 55. [3] outfuncs.c, line 3312. -- Andrey Lepikhov Postgres Professional https://postgrespro.com The Russian Postgres Company Attachments:^ permalink raw reply [nested|flat] 1+ messages in thread0001-XML-Bug-fix.patch (text/x-patch, 824B) download
From 26bfe91a4901b3b342e1b3ed58252ac750773207 Mon Sep 17 00:00:00 2001 From: "Andrey V. Lepikhov" <a.lepikhov@postgrespro.ru> Date: Sun, 16 Sep 2018 08:30:19 +0500 Subject: [PATCH] XML Bug fix --- src/backend/nodes/outfuncs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 744a8b91b8..20eb033eac 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -3310,7 +3310,7 @@ _outValue(StringInfo str, const Value *value) * but we don't want it to do anything with an empty string. */ appendStringInfoChar(str, '"'); - if (value->val.str[0] != '\0') + if ((value->val.str) && (value->val.str[0] != '\0')) outToken(str, value->val.str); appendStringInfoChar(str, '"'); break; -- 2.17.1
only message in thread Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-09-16 11:43 Clarification of nodeToString() use cases Andrey Lepikhov <a.lepikhov@postgrespro.ru>
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