Re: Getting the currently used sequence for a SERIAL column

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Getting the currently used sequence for a SERIAL column
Дата
Msg-id nu591f$5nr$1@blaine.gmane.org
обсуждение исходный текст
Ответ на Re: Getting the currently used sequence for a SERIAL column  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Getting the currently used sequence for a SERIAL column  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Getting the currently used sequence for a SERIAL column
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Getting the currently used sequence for a SERIAL column