Skip to content

Commit a5bd1d3

Browse files
committed
Make \d order a table's check constraints by constraint name instead
of the text of the constraint condition. Per Chris K-L, though I didn't use his patch exactly.
1 parent d9cb487 commit a5bd1d3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/bin/psql/describe.c

Lines changed: 5 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.127 2005/10/15 02:49:40 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.128 2005/10/20 05:15:09 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "describe.h"
@@ -1036,9 +1036,8 @@ describeOneTableDetails(const char *schemaname,
10361036
if (tableinfo.checks)
10371037
{
10381038
printfPQExpBuffer(&buf,
1039-
"SELECT "
1040-
"pg_catalog.pg_get_constraintdef(r.oid, true), "
1041-
"conname\n"
1039+
"SELECT r.conname, "
1040+
"pg_catalog.pg_get_constraintdef(r.oid, true)\n"
10421041
"FROM pg_catalog.pg_constraint r\n"
10431042
"WHERE r.conrelid = '%s' AND r.contype = 'c' ORDER BY 1",
10441043
oid);
@@ -1192,8 +1191,8 @@ describeOneTableDetails(const char *schemaname,
11921191
for (i = 0; i < check_count; i++)
11931192
{
11941193
printfPQExpBuffer(&buf, _(" \"%s\" %s"),
1195-
PQgetvalue(result2, i, 1),
1196-
PQgetvalue(result2, i, 0));
1194+
PQgetvalue(result2, i, 0),
1195+
PQgetvalue(result2, i, 1));
11971196

11981197
footers[count_footers++] = pg_strdup(buf.data);
11991198
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy