Skip to content

Commit d663d3b

Browse files
author
Neil Conway
committed
This patch makes \d on tables and views sort fk constraints, triggers
and rules alphabetically in the output. This makes it the same as for indexes and stops the irritating random or reverse ordering it currently has. Chris KL
1 parent f402125 commit d663d3b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/bin/psql/describe.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.112 2005/02/22 04:40:55 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.113 2005/03/16 23:52:18 neilc Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "describe.h"
@@ -959,7 +959,7 @@ describeOneTableDetails(const char *schemaname,
959959
printfPQExpBuffer(&buf,
960960
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))\n"
961961
"FROM pg_catalog.pg_rewrite r\n"
962-
"WHERE r.ev_class = '%s' AND r.rulename != '_RETURN'",
962+
"WHERE r.ev_class = '%s' AND r.rulename != '_RETURN' ORDER BY 1",
963963
oid);
964964
result = PSQLexec(buf.data, false);
965965
if (!result)
@@ -1040,7 +1040,7 @@ describeOneTableDetails(const char *schemaname,
10401040
"pg_catalog.pg_get_constraintdef(r.oid, true), "
10411041
"conname\n"
10421042
"FROM pg_catalog.pg_constraint r\n"
1043-
"WHERE r.conrelid = '%s' AND r.contype = 'c'",
1043+
"WHERE r.conrelid = '%s' AND r.contype = 'c' ORDER BY 1",
10441044
oid);
10451045
result2 = PSQLexec(buf.data, false);
10461046
if (!result2)
@@ -1058,7 +1058,7 @@ describeOneTableDetails(const char *schemaname,
10581058
printfPQExpBuffer(&buf,
10591059
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))\n"
10601060
"FROM pg_catalog.pg_rewrite r\n"
1061-
"WHERE r.ev_class = '%s'",
1061+
"WHERE r.ev_class = '%s' ORDER BY 1",
10621062
oid);
10631063
result3 = PSQLexec(buf.data, false);
10641064
if (!result3)
@@ -1082,7 +1082,8 @@ describeOneTableDetails(const char *schemaname,
10821082
" OR NOT EXISTS"
10831083
" (SELECT 1 FROM pg_catalog.pg_depend d "
10841084
" JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) "
1085-
" WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))",
1085+
" WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))"
1086+
" ORDER BY 1",
10861087
oid);
10871088
result4 = PSQLexec(buf.data, false);
10881089
if (!result4)
@@ -1103,7 +1104,7 @@ describeOneTableDetails(const char *schemaname,
11031104
"SELECT conname,\n"
11041105
" pg_catalog.pg_get_constraintdef(oid, true) as condef\n"
11051106
"FROM pg_catalog.pg_constraint r\n"
1106-
"WHERE r.conrelid = '%s' AND r.contype = 'f'",
1107+
"WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1",
11071108
oid);
11081109
result5 = PSQLexec(buf.data, false);
11091110
if (!result5)

0 commit comments

Comments
 (0)