Re: Assert for frontend programs? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Assert for frontend programs?
Date
Msg-id 6295.1355518109@sss.pgh.pa.us
Whole thread Raw
In response to Re: Assert for frontend programs?  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> 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?

Yeah, possibly.  The inet_net_pton.c case is surely because it was that
way in the BIND code we borrowed; perhaps the others are the same story.
I don't object to changing them, since we don't seem to be actively
adopting any new upstream versions; but again I can't get too excited.

> -            psql_assert(!*text);
> +            Assert(*text != '\0');

I think you got that one backwards.
>  #include "c.h"
> +#ifdef USE_ASSERT_CHECKING
> +#include <assert.h>
> +#define Assert(p) assert(p)
> +#else
> +#define Assert(p)
> +#endif

Perhaps a comment would be in order here?  Specifically something
about providing Assert() so that it can be used in both backend
and frontend code?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Dimitri Fontaine
Date:
Subject: Re: Use of systable_beginscan_ordered in event trigger patch
Next
From: Robert Haas
Date:
Subject: Re: Use of systable_beginscan_ordered in event trigger patch