Re: BUG #5304: psql using conninfo fails in connecting to the server

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5304: psql using conninfo fails in connecting to the server
Date: 2010-02-03 02:40:29
Message-ID: 14810.1265164829@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Joe Conway <mail(at)joeconway(dot)com> writes:
> On 02/02/2010 06:10 PM, Tom Lane wrote:
>> We should also give more than zero thought to how values coming from the
>> expanded dbname should interact with values from other arguments to
>> PQconnectdbParams --- which should override which? And should there be
>> an order dependency?

> My first thought was to duplicate the logic used by PQsetdbLogin(). It
> uses the conninfo string, fills in the defaults using connectOptions1(),
> applies the supplied other arguments overriding the defaults, and then
> finally computes derived options with connectOptions2(). It is
> essentially the same as PQconnectdb() except the supplied parameters are
> used before setting the derived options.

The difference with PQconnectdbParams is that the dbname might not be
the first thing in the parameter array. I think that a straightforward
implementation would have the effect of the expanded dbname overriding
parameters given before it, but not those given after it. Consider

keyword[0] = "port";
values[0] = "5678";
keyword[1] = "dbname";
values[1] = "dbname = db user = foo port = 9999";
keyword[2] = "user";
values[2] = "uu";

What I'm imagining is that this would end up equivalent to
dbname = db user = uu port = 9999. That's probably reasonable,
and maybe even useful, as long as it's documented.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Chris Travers 2010-02-03 03:21:13 Re: BUG #5308: How to disable Case sensitivity on naming identifiers
Previous Message Joe Conway 2010-02-03 02:25:27 Re: BUG #5304: psql using conninfo fails in connecting to the server

Browse pgsql-hackers by date

  From Date Subject
Next Message Alex Hunsaker 2010-02-03 03:42:21 Re: Add on_trusted_init and on_untrusted_init to plperl UPDATED [PATCH]
Previous Message Joe Conway 2010-02-03 02:25:27 Re: BUG #5304: psql using conninfo fails in connecting to the server