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

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема psql: show which tables contraints are for with a \d
Дата
Msg-id 20020815205828.DC945475DEA@postgresql.org
обсуждение исходный текст
Ответы Re: psql: show which tables contraints are for with a \d  (Rod Taylor <rbt@zort.ca>)
Список 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@turnstep.com
PGP Key: 0x14964AC8 200208151547
-----BEGIN PGP SIGNATURE-----
Comment: For info see http://www.gnupg.org

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



В списке pgsql-patches по дате отправления:

Предыдущее
От: "Ulrich Neumann"
Дата:
Сообщение: Re: Antw: Re: File for /src/backend/port/netware
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: psql: show which tables contraints are for with a \d