From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Andrew Dunstan" <andrew(at)dunslane(dot)net> |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: [HACKERS] psql commandline conninfo |
Date: | 2006-12-16 04:55:04 |
Message-ID: | 24948.1166244904@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
"Andrew Dunstan" <andrew(at)dunslane(dot)net> writes:
> Here's the patch for what I think is the consensus position. If there's no
> objection I will apply this and document it.
Please do something for the comment for the connectOptions1 call.
As you've coded it, that is doing two completely different things
and the comment is almost completely unhelpful at explaining this
complexity. Oh, and casting away const gets no points for style.
I think you could do worse than to split it into two independent code
paths:
/*
* If the dbName parameter contains '=', assume it's a conninfo
* string.
*/
if (dbName && strchr(dbName,'='))
{
if (!connectOptions1(conn, dbName))
return conn;
}
else
{
/*
* Old-style path: first, parse an empty conninfo string in
* order to set up the same defaults that PQconnectdb() would use.
*/
if (!connectOptions1(conn, ""))
return conn;
/* Insert dbName parameter value into struct */
if (dbName && dbName[0] != '\0')
{
if (conn->dbName)
free(conn->dbName);
conn->dbName = strdup(dbName);
}
}
/*
* Insert remaining parameters into struct, overriding defaults
* (as well as any conflicting data from dbName taken as a conninfo).
*/
(This works because there's no reason the dbName parameter can't be
moved up to process before the rest.)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | tomas | 2006-12-16 05:39:37 | Re: Operator class group proposal |
Previous Message | Andrew Dunstan | 2006-12-16 03:59:58 | Re: [HACKERS] psql commandline conninfo |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2006-12-16 13:11:09 | Re: [HACKERS] psql commandline conninfo |
Previous Message | Andrew Dunstan | 2006-12-16 03:59:58 | Re: [HACKERS] psql commandline conninfo |