Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Corey Huinker <corey.huinker@gmail.com>
From: Corey Huinker <corey.huinker@gmail.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Daniel Verite <daniel@manitou-mail.org>, "David G. Johnston" <david.g.johnston@gmail.com>, Greg Stark <stark@mit.edu>,
Erik Rijkers <er@xs4all.nl>, Robert Haas <robertmhaas@gmail.com>, Jim Nasby <Jim.Nasby@bluetreble.com>, PostgreSQL <pgsql-hackers@postgresql.org>, pgsql-hackers-owner@postgresql.org
Date: 2017-03-26T21:42:10Z
Lists: pgsql-hackers
Attachments
- 0001-psql-if-v26.patch (text/x-patch) patch v26-0001
> > Patches do not apply cleanly. > Part 1 gets: > error: patch failed: src/test/regress/parallel_schedule:89 > error: src/test/regress/parallel_schedule: patch does not apply > > There is still the useless file, ok it is removed by part2. Could have > been just one patch... > parallel_schedule failed because I hadn't rebased recently enough. git format-patch did us no favors there. New patch is redone as one commit. ISTM that PQExpBuffer is partially a memory leak. Something should need to > be freed? > I copied that pattern from somewhere else, so yeah, I duplicated whatever leak was there. Fixed. > I think that you should use appendPQExpBufferChar and Str instead of > relying on the format variant which is probably expensive. Something like: > > if (num_options > 0) > append...Char(buf, ' '); > append...Str(buf, ...); > All flavors of appendPQExpBuffer*() I can find have a const *char format string, so no way to append a naked string. If you know differently, I'm listening. Not fixed. > > is_true_boolean_expression: "return (success) ? tf : false;" > Is this simply: "return success && tf;"? > Neat. Done. > > Some functions have opt1, opt2, but some start at opt0. This does not look > too consistent, although the inconsistency may be preexisting from your > patch. Basically, there is a need for some more restructuring in > "command.c". It is pre-existing. Maybe this patch will inspire someone else to make the other more consistent. v26 attached
Commits
-
Support \if ... \elif ... \else ... \endif in psql scripting.
- e984ef5861df 10.0 landed
-
Add a "void *" passthrough pointer for psqlscan.l's callback functions.
- 895e36bb3f36 10.0 landed