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-27T14:11:18Z
Lists: pgsql-hackers
Attachments
- 0002-simpler-append.patch (text/x-patch) patch 0002
> > > I think that you could use another pattern where you init the > PQExpBufferData structure instead of create it, so that only the string is > malloced. In v26, I have the functions return PQExpBuffer. The two calling functions then free it, which should solve any leak. > > > 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. >> > > These prototypes are from "pqexpbuffer.h", and do not seem to rely on a > format: > > Here's an addendum that does that. I can combine them in v27, but figured this was quicker.
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