Re: new version of PQconnectdb was:(Re: [HACKERS] Determining client_encoding from client locale)

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: new version of PQconnectdb was:(Re: [HACKERS] Determining client_encoding from client locale)
Date: 2009-09-14 19:20:14
Message-ID: 4AAE976E.8090706@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jaime Casanova wrote:
> On Mon, Sep 14, 2009 at 1:34 PM, Andrew Chernow <ac(at)esilo(dot)com> wrote:
>> Jaime Casanova wrote:
>>> i extracted the functions to connect that Heikki put on psql in his
>>> patch for determining client_encoding from client locale and put it in
>>> libpq so i follow the PQconnectdbParams(* params[]) approach.
> [...]
>> The below posts agreed on a two argument version of parallel arrays
>> (keywords, values):
>>
>> http://archives.postgresql.org/pgsql-hackers/2009-09/msg00533.php
>> http://archives.postgresql.org/pgsql-hackers/2009-09/msg00559.php
>>
>
> actually, Tom said: "it's hard to be sure which way is
> actually more convenient without having tried coding some likely
> calling scenarios both ways."
>

Aahhh, correct you are Daniel son :)

> personally, i think it will cause more problems than solve because you
> have to be sure your arrays have relationship between them...
>

A strict relationship exists either way.

>> There is also the idea of passing an array of structs floating around, NULL
>> terminated list or include an additional argument specifying element count.
>>
>
> one more variable to the equation, more innecesary complexity and
> another source of errors, IMO...

one more variable or one more element, both of which cause problems if
omitted/incorrect.

const char *params[] =
{"host", "blah.com", "port", "6262", NULL, NULL};

// compiler enforces relationship
const PGopotion opts[] =
{{"host", "blah.com"}, {"port", "6262"}, {NULL, NULL}};

IMHO, the struct approach seems like a cleaner solution.

Any chance of using a term other than "params"? Maybe "options" or
"props"?

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Emmanuel Cecchet 2009-09-14 19:25:29 Re: generic copy options
Previous Message Robert Haas 2009-09-14 19:18:53 Re: generic copy options