public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Dagfinn Ilmari Mannsåker <[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 15:51:06 -0500
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]>
<[email protected]>
=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= <[email protected]> writes:
> Tom Lane <[email protected]> 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
view thread (8+ messages)
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