public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Marcelo Fernandes <[email protected]>
Cc: [email protected]
Subject: Re: pg_get_serial_sequence not working for manually set seq
Date: Mon, 21 Apr 2025 21:33:46 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAM2F1VPo-mknp3DOy7cr3SsN3vw-W7M_vq4GK8yqw9ux=T7c3A@mail.gmail.com>
References: <CAM2F1VPo-mknp3DOy7cr3SsN3vw-W7M_vq4GK8yqw9ux=T7c3A@mail.gmail.com>
Marcelo Fernandes <[email protected]> writes:
> I've been testing the pg_get_serial_sequence function and noticed that I can
> only get reliable results when using a SERIAL or IDENTITY column.
> However, shouldn't it work for manually set sequences too?
pg_get_serial_sequence looks for pg_depend entries that make sequences
depend on columns, so no you won't get it to work that way.
You could use ALTER SEQUENCE OWNED BY to establish the dependency link,
if you are intent on reimplementing SERIAL by hand. See the
documentation about what SERIAL does:
https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL
regards, tom lane
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]
Subject: Re: pg_get_serial_sequence not working for manually set seq
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