Re: Extending outfuncs support to utility statements - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Extending outfuncs support to utility statements
Date
Msg-id 2e7adbce-2ff5-866e-8753-9969b0ce332b@enterprisedb.com
Whole thread Raw
In response to Re: Extending outfuncs support to utility statements  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Extending outfuncs support to utility statements
List pgsql-hackers
On 13.07.22 00:38, Tom Lane wrote:
> Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
>> This is also needed to be able to store utility statements in (unquoted)
>> SQL function bodies.  I have some in-progress code for that that I need
>> to dust off.  IIRC, there are still some nontrivial issues to work
>> through on the reading side.  I don't have a problem with enabling the
>> outfuncs side in the meantime.
> 
> BTW, I experimented with trying to enable WRITE_READ_PARSE_PLAN_TREES
> for utility statements, and found that the immediate problem is that
> Constraint and a couple of other node types lack read functions
> (they're the ones marked "custom_read_write, no_read" in parsenodes.h).
> They have out functions, so writing the inverses seems like it's just
> something nobody ever got around to.  Perhaps there are deeper problems
> lurking behind that one, though.

Here are patches for that.

v1-0001-Fix-reading-of-most-negative-integer-value-nodes.patch
v1-0002-Fix-reading-of-BitString-nodes.patch

These are some of those lurking problems.

v1-0003-Add-read-support-for-some-missing-raw-parse-nodes.patch

This adds the read support for the missing nodes.

The above patches are candidates for committing.

At this point we have one structural problem left: char * node fields 
output with WRITE_STRING_FIELD() (ultimately outToken()) don't 
distinguish between empty strings and NULL values.  A write/read 
roundtrip ends up as NULL for an empty string.  This shows up in the 
regression tests for commands such as

CREATE TABLESPACE regress_tblspace LOCATION '';
CREATE SUBSCRIPTION regress_addr_sub CONNECTION '' ...

This will need some expansion of the output format to handle this.

v1-0004-XXX-Turn-on-WRITE_READ_PARSE_PLAN_TREES-for-testi.patch
v1-0005-Implement-WRITE_READ_PARSE_PLAN_TREES-for-raw-par.patch
v1-0006-Enable-WRITE_READ_PARSE_PLAN_TREES-of-rewritten-u.patch

This is for testing the above.  Note that in 0005 we need some special 
handling for float values to preserve the full precision across 
write/read.  I suppose this could be unified with the code the preserves 
the location fields when doing write/read checking.

v1-0007-Enable-utility-statements-in-unquoted-SQL-functio.patch

This demonstrates what the ultimate goal is.  A few more tests should be 
added eventually.
Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: ecpg assertion on windows
Next
From: Andres Freund
Date:
Subject: Re: [RFC] building postgres with meson - v11