Re: Adding a pg_get_owned_sequence function?

Поиск
Список
Период
Сортировка
От Dagfinn Ilmari Mannsåker
Тема Re: Adding a pg_get_owned_sequence function?
Дата
Msg-id 877ckimmfm.fsf@wibble.ilmari.org
обсуждение исходный текст
Ответ на Re: Adding a pg_get_owned_sequence function?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Adding a pg_get_owned_sequence function?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> Peter Eisentraut <peter@eisentraut.org> writes:
>> Would it work to change the signature of pg_get_serial_sequence to
>>      pg_get_serial_sequence(table anyelement, column text) -> anyelement
>> and then check inside the function code whether text or regclass was passed?
>
> Probably not very well, because then we'd get no automatic coercion of
> inputs that were not either type.
>
> 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.

> but I wonder if that would create any situations where the parser
> couldn't choose between these candidates.

According to my my earlier testing¹, the parser prefers the text version
for unknown-type arguments, and further testing shows that that's also
the case for other types with implicit casts to text such as varchar and
name.  The regclass version gets chosen for oid and (big)int, because of
the implicit cast from (big)int to oid and oid to regclass.

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?

>             regards, tom lane

- ilmari

[1]: https://postgr.es/m/87v8cfo32v.fsf@wibble.ilmari.org



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

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: Re: verify predefined LWLocks have entries in wait_event_names.txt
Следующее
От: Jelte Fennema-Nio
Дата:
Сообщение: Re: Add BF member koel-like indentation checks to SanityCheck CI