Elementary dependency look-up

From: Josh Williams <joshwilliams(at)ij(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Elementary dependency look-up
Date: 2009-09-04 00:45:51
Message-ID: 1252025151.8686.53.camel@lapdragon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Attached is a patch to add a couple basic dependency look-up capability
functions. They're based off the pg_get_serial_sequence function, and
are kind of the inverse of that function in some respects.

The patch adds two new functions to the backend, pg_get_owner_object and
pg_get_owner_column. These look up the requested object in the
pg_depend table, looking for an 'a' type dependency to another relation,
and resolve either the relation or column names to text.

postgres=# SELECT pg_get_owner_object('tbl_id_seq') AS obj,
postgres-# pg_get_owner_column('tbl_id_seq') AS col,
postgres-# pg_get_serial_sequence(
postgres(# pg_get_owner_object('tbl_id_seq'),
postgres(# pg_get_owner_column('tbl_id_seq')
postgres(# ) AS full_circle;
obj | col | full_circle
public.tbl | id | public.tbl_id_seq
(1 row)

I tried not to be too myopic in the design, but apart from sequence
ownership I can't really think of any other uses for this. 'p'in and
'i'nternal relationships wouldn't make much sense, and 'n'ormal ones are
generally exposed in other ways. Anyone have any input there on how
this could be expanded?

Anyway, as an immediate practical example the patch modifies psql's
describe-verbose on sequences to show the ownership information...

postgres=# \d+ tbl_id_seq
Owner: public.tbl.id

- Josh Williams

Attachment Content-Type Size
get_owner_object_1.0.patch text/x-patch 10.5 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Itagaki Takahiro 2009-09-04 00:53:30 Re: Triggers on columns
Previous Message Stephen Frost 2009-09-04 00:18:21 Re: community decision-making & 8.5