public inbox for [email protected]
help / color / mirror / Atom feedFrom: Dagfinn Ilmari Mannsåker <[email protected]>
To: Tom Lane <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Nathan Bossart <[email protected]>
Cc: vignesh C <[email protected]>
Cc: [email protected]
Subject: Re: Adding a pg_get_owned_sequence function?
Date: Tue, 09 Jan 2024 17:44:13 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<20231024162929.GA871220@nathanxps13>
<CALDaNm0_nn-LXSJCXQ6EYiGKjVO8fVO8AemgEVZFQPPdx0=fkg@mail.gmail.com>
<[email protected]>
<20240108210847.GA2796792@nathanxps13>
<[email protected]>
<[email protected]>
Tom Lane <[email protected]> writes:
> Peter Eisentraut <[email protected]> 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/[email protected]
view thread (8+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Adding a pg_get_owned_sequence function?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox