Re: Assert for frontend programs?

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: Assert for frontend programs?
Дата
Msg-id 50CB8CD0.8020209@dunslane.net
обсуждение исходный текст
Ответ на Re: Assert for frontend programs?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Assert for frontend programs?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Assert for frontend programs?  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
On 12/14/2012 11:33 AM, Tom Lane wrote:
> Heikki Linnakangas <hlinnakangas@vmware.com> writes:
>> On 14.12.2012 17:54, Tom Lane wrote:
>>> BTW, I think psql already has a "psql_assert".
>> psql_assert looks like this:
>> #ifdef USE_ASSERT_CHECKING
>> #include <assert.h>
>> #define psql_assert(p) assert(p)
>> #else
>> ...
>> On my Linux system, a failure looks like this:
>> ~$ ./a.out
>> a.out: a.c:5: main: Assertion `1==2' failed.
>> Aborted
>> That seems fine to me.
> Works for me.  So just rename that to Assert() and move it into
> postgres-fe.h?
>
>


Here's a patch for that. I changed some of the psql assertions so they
all have explicit boolean expressions - I think that's better style for
use of assert.

I noticed, BTW, that there are one or two places in backend code that
seem to call plain assert unconditionally, notably src/port/open.c,
src/backend/utils/adt/inet_net_pton.c and some contrib modules. That
seems undesirable. Should we need to look at turning these into Assert
calls?

cheers

andrew



Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: MySQL search query is not executing in Postgres DB
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Use gcc built-in atomic inc/dec in lock.c