Re: Using the new libpq connection functions in PostgreSQL binaries - Mailing list pgsql-hackers

From Guillaume Lelarge
Subject Re: Using the new libpq connection functions in PostgreSQL binaries
Date
Msg-id 4B65C11A.7010405@lelarge.info
Whole thread Raw
In response to Re: Using the new libpq connection functions in PostgreSQL binaries  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Using the new libpq connection functions in PostgreSQL binaries  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
Le 31/01/2010 17:35, Tom Lane a écrit :
> Guillaume Lelarge <guillaume@lelarge.info> writes:
> 
>>        */
>>       do
>>       {
>> +         const char *values[] = {
>> +                   my_opts->hostname,
>> +                   my_opts->port,
>> +                   my_opts->dbname,
>> +                   my_opts->username,
>> +                   password,
>> +                   "oid2name",
>> +                   NULL
>> +               };
>> +         
>>           new_pass = false;
> 
> Is that really legal C89 syntax?

I don't really know. gcc (4.4.1 release) didn't complain about it,
whereas it complained with a warning for not-legal-syntax when I had the
"new_pass = false;" statement before the array declaration.

> I seem to recall that array
> constructors can only be used for static assignments with older
> compilers.
> 
> Also, as a matter of style, I find it pretty horrid that this isn't
> immediately adjacent to the keywords array that it MUST match.
> 

I don't find that horrid. AFAICT, that's the only advantage of the
two-arrays method. By the way, it's that kind of code (keywords
declaration separated from values declaration) that got commited in the
previous patch
(http://archives.postgresql.org/pgsql-committers/2010-01/msg00398.php).
I merely used the same code for the other binaries.


-- 
Guillaume.http://www.postgresqlfr.orghttp://dalibo.com


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: odd output in initdb
Next
From: Joe Conway
Date:
Subject: Re: Using the new libpq connection functions in PostgreSQL binaries