Re: AllocSetContextCreate changes breake extensions

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: AllocSetContextCreate changes breake extensions
Дата
Msg-id 87ftvf4bzx.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на Re: AllocSetContextCreate changes breake extensions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:

 >> except there IS such a reason: if you need (as I do in pl/lua) to
 >> wrap the call in a catch block, inside a function which takes the
 >> name and so on as a parameter, then you have no option but to do so
 >> (since using the macro errors out on the non-const parameter).

 Tom> I'm kind of unimpressed by your example, because you're
 Tom> deliberately breaking the safety check the macro sets out to
 Tom> provide.

Yes, because in this case the names really _are_ constant strings, but
that fact can't be exposed to AllocSetContextCreate without duplicating
code all over the place.

 Tom> With code structure like this, it's impossible to be sure that
 Tom> what was passed to the wrapper function is actually a constant
 Tom> string.

It's impossible for AllocSetContextCreate to be sure of that, it's not
impossible for _me_ to be sure of that. (I could add my own macro with a
__builtin_constant_p check if I felt the need.)

 Tom> You'd be better off using the workaround the comment suggests,
 Tom> which is to just pass "" to AllocSetContextCreate and then use
 Tom> MemoryContextSetIdentifier to copy the passed string.

Copying the string would be overkill since it really is a constant. (And
I can't copy the string into the context it identifies, because that
would block use of MemoryContextReset. I'd have to copy it somewhere
else - and then freeing it becomes much more tricky.)

-- 
Andrew (irc:RhodiumToad)


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

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: Re: [proposal] Add an option for returning SQLSTATE in psql error message
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Re: idle-in-transaction timeout error does not give a hint