Re: Inverse of pg_get_serial_sequence?

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Inverse of pg_get_serial_sequence?
Date: 2014-08-30 01:03:12
Message-ID: 20140830010312.GD14361@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-08-29 17:55:38 -0700, David G Johnston wrote:
> Andres Freund-3 wrote
> > Hi,
> >
> > We have pg_get_serial_sequence() mapping (relation, colum) to the
> > sequence. What I'm missing right now is the inverse. I.e. given a
> > sequence tell me the owner.
> > describe.c has a query for that, and it's not too hard to write, but it
> > still seems 'unfriendly' not to provide it.
> >
> > Does anybody dislike adding a function for that?
> >
> >
> > I can't really think of a good name (not that pg_get_serial_sequence is
> > well named). pg_get_serial_sequence_owner(serial regclass, OUT rel
> > regclass, OUT colname name) maybe?
>
> On a pure consistency basis: pg_get_sequence_serial(...) [though probably
> plural: _serials(...)]

Yea, but that's just horrid.

> I'd drop the serial part altogether for the more appropriate:
>
> pg_get_sequence_ownedby(...)

My problem is that that possibly be confused with the user owning the
sequence :/

> Reminder: sequences can be unowned.

Don't you say.

> Ownership and usage via default are separate things though: do you have need
> to know all users of a sequence or only the single one that is defined as
> it's owner?

I'd rather know all its users, but that's not really possible in the
general case without guessing. I'll settle for the column that's
declared as owning it. Even if we had a interface for guessing I'd not
want it to be the same as the one returning the declared owner.

Greetings,

Andres Freund

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G Johnston 2014-08-30 01:23:05 Re: Inverse of pg_get_serial_sequence?
Previous Message David G Johnston 2014-08-30 00:55:38 Re: Inverse of pg_get_serial_sequence?