Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless) - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)
Date
Msg-id CADkLM=fbEGfea0idN_XsKUG70JmCaMjdejo35q-B5tpC11NTuA@mail.gmail.com
Whole thread Raw
In response to Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers

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.
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Time to drop old-style (V0) functions?
Next
From: Tom Lane
Date:
Subject: Re: Crash on promotion when recovery.conf is renamed