From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: A couple more PostgreSQL C questions |
Date: | 2006-11-08 04:18:00 |
Message-ID: | 16156.1162959480@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com> writes:
> Datum
> y_somefunc ( PG_FUNCTION_ARGS )
> {
> if( PG_ARGISNULL(0) ||
> PG_ARGISNULL(1) ||
> PG_ARGISNULL(2) )
> {
> PG_RETURN_NULL();
> }
> text* rand_dev = PG_GETARG_TEXT_P(0);
> ...
> Should I be concerned by this? What's the proper way to code this?
The proper way to code that is either
{
text* rand_dev;
if( PG_ARGISNULL(0) ||
PG_ARGISNULL(1) ||
PG_ARGISNULL(2) )
{
PG_RETURN_NULL();
}
rand_dev = PG_GETARG_TEXT_P(0);
...
or probably better, declare the function STRICT and drop the runtime
ARGISNULL tests entirely.
> I'm thinking the correct answer is "just live with
> it until your version of gcc uses c99 as the default standard".
Declarations in the middle of a code block are C++, not C; if you
try to hold your breath until your C compiler accepts it, you will die.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Gurjeet Singh | 2006-11-08 04:55:30 | Re: Per-row security |
Previous Message | Ron Peterson | 2006-11-08 03:04:52 | Re: A couple more PostgreSQL C questions |