Re: pg_get_serial_sequence not working for manually set seq - Mailing list pgsql-general

From Tom Lane
Subject Re: pg_get_serial_sequence not working for manually set seq
Date
Msg-id 878366.1745285626@sss.pgh.pa.us
Whole thread Raw
In response to pg_get_serial_sequence not working for manually set seq  (Marcelo Fernandes <marcefern7@gmail.com>)
List pgsql-general
Marcelo Fernandes <marcefern7@gmail.com> 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



pgsql-general by date:

Previous
From: Marcelo Fernandes
Date:
Subject: pg_get_serial_sequence not working for manually set seq
Next
From: senor
Date:
Subject: sequence on daily log partitioned table