Re: Adding a pg_get_owned_sequence function?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Adding a pg_get_owned_sequence function?
Дата
Msg-id 2223239.1704833466@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Adding a pg_get_owned_sequence function?  (Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>)
Список pgsql-hackers
=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= <ilmari@ilmari.org> writes:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>> Maybe it would work to have both
>> pg_get_serial_sequence(table text, column text) -> text
>> pg_get_serial_sequence(table regclass, column text) -> regclass

> I think it would be more correct to use name for the column argument
> type, rather than text.

In a green field perhaps, but we're not in a green field:
    pg_get_serial_sequence(text, text)
already exists.  That being the case, I'd strongly recommend that if
we overload this function name then we stick to text for the column
argument.  If you add
    pg_get_serial_sequence(regclass, name)
then you will be presenting the parser with situations where one
alternative is "more desirable" for one argument and "less desirable"
for the other, so that it's unclear which it will choose or whether
it will throw up its hands and refuse to choose.

> The only case I could foresee failing would be types that have implicit
> casts to both text and regtype.  It turns out that varchar does have
> both, but the parser still picks the text version without copmlaint.
> Does it prefer the binary-coercible cast over the one that requires
> calling a conversion function?

Without having checked the code, I don't recall that there's any
preference for binary-coercible casts.  But there definitely is
a preference for casting to "preferred" types, which text is
and these other types are not.  That's why I'm afraid of your
use-name-not-text proposal: it puts the regclass alternative at an
even greater disadvantage in terms of the cast-choice heuristics.

            regards, tom lane



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

Предыдущее
От: Pavel Luzanov
Дата:
Сообщение: Re: Things I don't like about \du's "Attributes" column
Следующее
От: "Tristan Partin"
Дата:
Сообщение: Re: Add BF member koel-like indentation checks to SanityCheck CI