psql: show which tables contraints are for with a \d

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: psql: show which tables contraints are for with a \d
Date: 2002-08-15 20:53:59
Message-ID: 20020815205828.DC945475DEA@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

This (inline) patch makes the display of trigggers a little less
hideous when you have many foreign keys, which causese the
creation of many RI_ConstraintTrigger_XXXXX triggers. If the
trigger is actually a constraint, it will show table the
constraint is for. Not much, but a little better than seeing
row after row of auto-generated trigger names.

Old way:

greg=# \d alphabet
Table "public.alphabet"
Column | Type | Modifiers
--------+---------+-----------
aa | integer | not null
bb | integer |
cc | integer |
Indexes: alphabet_pkey primary key btree (aa),
alphabet_bb_key unique btree (bb),
alphabet_cc_key unique btree (cc)
Triggers: RI_ConstraintTrigger_16880,
RI_ConstraintTrigger_16881,
RI_ConstraintTrigger_16884,
RI_ConstraintTrigger_16885,
RI_ConstraintTrigger_16888,
my_little_trigger,
another_custom_trigger

greg=# \d alphabet
Table "public.alphabet"
Column | Type | Modifiers
--------+---------+-----------
aa | integer | not null
bb | integer |
cc | integer |
Indexes: alphabet_pkey primary key btree (aa),
alphabet_bb_key unique btree (bb),
alphabet_cc_key unique btree (cc)
Triggers: RI_ConstraintTrigger_16880 (Constraint on public.foobar),
RI_ConstraintTrigger_16881 (Constraint on public.foobar),
RI_ConstraintTrigger_16884 (Constraint on public.mikey),
RI_ConstraintTrigger_16885 (Constraint on greg.watson),
RI_ConstraintTrigger_16888 (Constraint on greg.crick),
my_little_trigger,
another_custom_trigger

Index: describe.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/describe.c,v
retrieving revision 1.60
diff -r1.60 describe.c
972c972,975
< "SELECT t.tgname\n"
---
> "SELECT t.tgname || \n"
> " COALESCE((SELECT ' (' || '%s ' || n.nspname || '.' || c.relname || ')'\n"
> " FROM pg_class c, pg_namespace n\n"
> " WHERE c.relnamespace = n.oid AND c.oid = t.tgconstrrelid), '')\n"
975c978
< oid);
---
> _("Constraint on"), oid);

Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200208151547
-----BEGIN PGP SIGNATURE-----
Comment: For info see http://www.gnupg.org

iD8DBQE9XBZKvJuQZxSWSsgRAvVEAKCkZ+XXSsdRa0c4aAtThFo9A5So8gCg8ONH
WFL0VcOxndDiRcIUezggao8=
=U/NJ
-----END PGP SIGNATURE-----

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Rod Taylor 2002-08-15 21:34:55 Re: psql: show which tables contraints are for with a \d
Previous Message Zhenbang Wei 2002-08-15 18:06:08 [UPDATE]errors_zh_TW.properties