How to enumerate foreign key constraints after migrating from 7.1.3?

From: Forest Wilkinson <lyris-pg(at)tibit(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to enumerate foreign key constraints after migrating from 7.1.3?
Date: 2003-06-10 21:45:07
Message-ID: 32icevsv6cr0fks8julguj0au2hor1r5eg@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

I'm porting a postgres client app (along with all the users'
databases) from postgres 7.1.3 to 7.3.x. The new version of the app
needs a way of enumerating foreign key constraints on a table,
including the constraint names and the constrained columns.
Unfortunately, postgres 7.1.3 didn't have a pg_constraint table, and
the dump/restore process doesn't create the appropriate pg_constraint
rows for foreign keys when migrating. With that in mind, how can I
enumerate foreign key constraints in any database, whether it was
originally created with postgres 7.1.3 or 7.3.x?

It looks like I can get a list of constraint names from the pg_trigger
table, but each foreign key constraint corresponds to several triggers
on either of the two tables involved. How can I distinguish the
referenced table from the referencing one? Is pg_trigger even the
correct place to look?

Once I find a migrated foreign key constraint, since it won't have an
entry in pg_constraint, will I be able to drop it?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Smith 2003-06-10 21:45:34 Re: increment_by@
Previous Message Tom Lane 2003-06-10 21:35:04 Re: [HACKERS] [GENERAL] Postgresql & AMD x86-64

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2003-06-10 21:45:13 Re: Re-ordering .CONF params ... questions for this list
Previous Message Rod Taylor 2003-06-10 21:39:48 Re: Proposal to Re-Order Postgresql.Conf, part II