Search Postgresql Archives

Re: A couple more PostgreSQL C questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron Peterson <ron.peterson@xxxxxxxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux