Re: Extending outfuncs support to utility statements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Extending outfuncs support to utility statements
Date: 2022-09-22 20:57:14
Message-ID: 1944074.1663880234@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> On 2022-09-22 12:48:47 -0400, Tom Lane wrote:
>> After staring at the code a bit, I think we don't need to touch
>> pg_strtok() per se. I propose that this can be resolved with changes
>> at the next higher level. Let's make outToken print NULL as <> as
>> it always has, but print an empty string as "" (two double quotes).
>> If the raw input string is two double quotes, print it as \"" to
>> disambiguate. This'd require a catversion bump when committed,
>> but I don't think there are any showstopper problems otherwise.

> Makes sense to me.

Here is a version of all-but-the-last patch in Peter's series.
I left off the last one because it fails check-world: we now
get through the core regression tests okay, but then the pg_dump
tests fail on the new SQL function. To fix that, we would have
to extend ruleutils.c's get_utility_query_def() to be able to
fully reconstruct any legal utility query ... which seems like
a pretty dauntingly large amount of tedious manual effort to
start with, and then also a nontrivial additional requirement
on any future patch that adds new utility syntax. Are we sure
it's worth going there?

But I think it's probably worth committing what we have here
just on testability grounds.

Some notes:

0001, 0002 not changed.

I tweaked 0003 a bit, mainly because I think it's probably not very
safe to apply strncmp to a string we don't know the length of.
It might be difficult to fall off the end of memory that way, but
I wouldn't bet it's impossible. Also, adding the length checks gets
rid of the need for a grotty order dependency in _readA_Expr().

0004 fixes the empty-string problem as per above.

I did not like what you'd done about imprecise floats one bit.
I think we ought to do it as in 0005 instead: drop all the
hard-wired precision assumptions and just print per Ryu.

0006, 0007, 0008 are basically the same as your previous 0004,
0005, 0006, except for getting rid of the float hacking in 0005.

If you're good with this approach to the float issue, I think
this set is committable (minus 0006 of course, and don't forget
the catversion bump).

regards, tom lane

Attachment Content-Type Size
v2-0001-Fix-reading-of-most-negative-integer-value-nodes.patch text/x-diff 1.5 KB
v2-0002-Fix-reading-of-BitString-nodes.patch text/x-diff 1.5 KB
v2-0003-Add-read-support-for-some-missing-raw-parse-nodes.patch text/x-diff 10.2 KB
v2-0004-Fix-empty-strings.patch text/x-diff 3.2 KB
v2-0005-Fix-float-precision.patch text/x-diff 3.7 KB
v2-0006-XXX-Turn-on-WRITE_READ_PARSE_PLAN_TREES-for-testi.patch text/x-diff 829 bytes
v2-0007-Implement-WRITE_READ_PARSE_PLAN_TREES-for-raw-par.patch text/x-diff 1.2 KB
v2-0008-Enable-WRITE_READ_PARSE_PLAN_TREES-of-rewritten-u.patch text/x-diff 2.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-09-22 21:07:02 Re: CI and test improvements
Previous Message Andres Freund 2022-09-22 20:28:09 Re: [RFC] building postgres with meson - v13