Re: Missing compiled default for channel_binding param from PQconndefaults

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: Missing compiled default for channel_binding param from PQconndefaults
Дата
Msg-id CA+mi_8biWq8rH5W4V9vXKsSAhfGQ4g8EA+2rHJFNoxT9S9ybHQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Missing compiled default for channel_binding param from PQconndefaults  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Missing compiled default for channel_binding param from PQconndefaults  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Mon, 28 Dec 2020 at 01:48, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> > compiled is expected to be "prefer" or "disable" as per docs.
> > Please find a patch attached.
>
> Yeah, that does look inconsistent, and I don't object to fixing
> it.  But it's already the case that not all connection parameters
> have defaults in that struct.

I am testing with a function to report connection info to the user, at
a higher level than this structure and with less noise, but without
omitting meaningful info. As far as I can see, this one and "passfile"
are the only parameters for which PQconndefaults reports something
different from PQconninfo which the user hasn't set explicitly (in the
connection string or with an env var). "passfile" depends on the user
home so it's understandable.


> Isn't there a psycopg3 bug here
> too, that it's not coping with a null default sanely?
>
> I'm a bit suspicious that psycopg3 is expecting that NULL and
> empty-string are equivalent for all parameters.  That is a convention
> we upheld for a long time, but recent parameters have gotten away
> from that --- not only channel_binding, but others such as sslmode.
> If that's the underlying cause here then we need to think about
> whether we want to restore that expectation.

As far as I can see, psycopg3 reports the distinction between nulls
and empty strings ok: see the "compiled" values in this sample. Or
maybe I didn't understand your observation?

    >>> [i for i in psycopg3.pq.Conninfo.get_defaults() if i.keyword
in (b"options", b"application_name")]
    [ConninfoOption(keyword=b'options', envvar=b'PGOPTIONS',
compiled=b'', val=b'', label=b'Backend-Options', dispchar=b'',
dispsize=40),
    ConninfoOption(keyword=b'application_name', envvar=b'PGAPPNAME',
compiled=None, val=b'piro@baloo', label=b'Application-Name',
dispchar=b'', dispsize=64)]

Psycopg itself doesn't do anything actively with these defaults, e.g.
it doesn't use them to build a connection string. When a user creates
a connection string, empty strings are respected as valid parameter
values and not discarded or conflated otherwise with None. If there is
more care to have somewhere else I'm happy to know and adjust
accordingly. It would be good to know an example to keep in the
regression tests.


-- Daniele



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Missing compiled default for channel_binding param from PQconndefaults
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Missing compiled default for channel_binding param from PQconndefaults