Re: Getting the currently used sequence for a SERIAL column - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Getting the currently used sequence for a SERIAL column
Date
Msg-id nu591f$5nr$1@blaine.gmane.org
Whole thread Raw
In response to Re: Getting the currently used sequence for a SERIAL column  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Getting the currently used sequence for a SERIAL column
List pgsql-general
Tom Lane schrieb am 18.10.2016 um 15:20:
>> 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.
>
> Personally, I'd try looking in pg_depend to see if the column's default
> expression has a dependency on a relation of type sequence.  That avoids
> all the fun of parsing the expression and turns it into a simple SQL
> join problem.


I thought pg_depend only stores the dependency if the the sequence was assigned
an owning column (through OWNED BY).

I don't see any entries in pg_depend for a simple "default nextval('some_sequence')" expression
but maybe I am just missing something.

Thomas

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Getting the currently used sequence for a SERIAL column
Next
From: Tom Lane
Date:
Subject: Re: Getting the currently used sequence for a SERIAL column