Re: [HACKERS] psql commandline conninfo

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] psql commandline conninfo
Дата
Msg-id 24948.1166244904@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] psql commandline conninfo  ("Andrew Dunstan" <andrew@dunslane.net>)
Ответы Re: [HACKERS] psql commandline conninfo  ("Andrew Dunstan" <andrew@dunslane.net>)
Список pgsql-patches
"Andrew Dunstan" <andrew@dunslane.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

В списке pgsql-patches по дате отправления:

Предыдущее
От: "Andrew Dunstan"
Дата:
Сообщение: Re: [HACKERS] psql commandline conninfo
Следующее
От: "Andrew Dunstan"
Дата:
Сообщение: Re: [HACKERS] psql commandline conninfo