Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)
Дата
Msg-id alpine.DEB.2.20.1703270655240.20202@lancre
обсуждение исходный текст
Ответ на Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  ("Daniel Verite" <daniel@manitou-mail.org>)
Ответы Re: \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)  (Corey Huinker <corey.huinker@gmail.com>)
Список pgsql-hackers

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

Hmmm. Indeed some commands do not free, but there is a single use and the 
commands exits afterwards, eg "createuser".

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.

>> 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:
 extern void appendPQExpBufferChar(PQExpBuffer str, char ch); extern void appendPQExpBufferStr(PQExpBuffer str, const
char*data);
 

-- 
Fabien



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andreas Karlsson
Дата:
Сообщение: Re: Refactor handling of database attributes betweenpg_dump and pg_dumpall
Следующее
От: Tom Lane
Дата:
Сообщение: Re: crashes due to setting max_parallel_workers=0