Re: Getting the currently used sequence for a SERIAL column

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting the currently used sequence for a SERIAL column
Date: 2016-10-18 09:12:10
Message-ID: nu4p17$hl6$1@blaine.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Is this to be regarded as internal API or is it safe to use this to
> find the correct sequence?

I think it's safe to use.

> Furthermore, what's stored in the column seems to be a string of the
> format "nextval('sequencename'::regclass)". Is there a function to
> parse this, to return just the sequence name, or will the sequence
> name always be without for instance a schema name so that a naive
> parser of our own will do? Googling found no candidates.

In my experience, this could also be in the form "nextval('schema.sequencename'::regclass)"
if the sequence is not in the same schema as the table.

Thomas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2016-10-18 10:39:03 Re: pg_upgrade not able to cope with pg_largeobject being in a different tablespace
Previous Message Hanne Moa 2016-10-18 08:45:52 Getting the currently used sequence for a SERIAL column