Re: Definitional questions for pg_sequences view

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Definitional questions for pg_sequences view
Date: 2017-07-21 02:09:56
Message-ID: CAMsr+YFpt0V-8tSRM=dtsALZj-ZhdpHEoCatx3qBGEDgwGDpXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 20 July 2017 at 22:36, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

>
> This could be fixed if it were possible to translate to
> select * from pg_sequences where seqoid = 'my_seq'::regclass;
> but the view isn't exposing the sequence OID. Should it?
>

It probably should. It's not part of information_schema, it's in
pg_catalog, and it's entirely reasonable to join on oids.

The relfilenode for the sequence can change, but the sequence oid won't
unless we actually drop and re-create it, so the weird issues with alter
sequence operations being partly transactional and partly not shouldn't be
a concern.

If it's to be a convenience view, it should possibly also expose the OWNED
BY relation oid IMO, if any. You have the sequence oid you can join on
pg_class and grab the relowner, so it's not a great hassle if it's missing,
but if it's a view to help users out exposing that would seem sensible.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2017-07-21 02:11:05 Re: xlogfilename
Previous Message Craig Ringer 2017-07-21 02:01:31 Re: More optimization effort?