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(# ) AS full_circle;
obj | col | full_circle
public.tbl | id | public.tbl_id_seq
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
pgsql-hackers by date
|Next:||From: Itagaki Takahiro||Date: 2009-09-04 00:53:30|
|Subject: Re: Triggers on columns|
|Previous:||From: Stephen Frost||Date: 2009-09-04 00:18:21|
|Subject: Re: community decision-making & 8.5|