Skip site navigation (1) Skip section navigation (2)

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 (view raw, whole thread or download thread mbox)
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

- Josh Williams

Attachment: get_owner_object_1.0.patch
Description: text/x-patch (10.5 KB)


pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group