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