Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7de7876

Browse files
committed
Fix psql's \dD to show only one row per domain, even when the domain has
multiple check constraints.
1 parent 3e96ed4 commit 7de7876

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/bin/psql/describe.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
1010
*
11-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.199 2009/02/11 19:12:04 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.200 2009/02/23 15:59:55 tgl Exp $
1212
*/
1313
#include "postgres_fe.h"
1414

@@ -2077,10 +2077,11 @@ listDomains(const char *pattern, bool showSystem)
20772077
" WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault\n"
20782078
" ELSE ''\n"
20792079
" END as \"%s\",\n"
2080-
" pg_catalog.pg_get_constraintdef(r.oid, true) as \"%s\"\n"
2080+
" pg_catalog.array_to_string(ARRAY(\n"
2081+
" SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM pg_catalog.pg_constraint r WHERE t.oid = r.contypid\n"
2082+
" ), ' ') as \"%s\"\n"
20812083
"FROM pg_catalog.pg_type t\n"
20822084
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n"
2083-
" LEFT JOIN pg_catalog.pg_constraint r ON t.oid = r.contypid\n"
20842085
"WHERE t.typtype = 'd'\n",
20852086
gettext_noop("Schema"),
20862087
gettext_noop("Name"),
@@ -2089,7 +2090,7 @@ listDomains(const char *pattern, bool showSystem)
20892090
gettext_noop("Check"));
20902091

20912092
if (!showSystem)
2092-
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n");
2093+
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n");
20932094

20942095
processSQLNamePattern(pset.db, &buf, pattern, true, false,
20952096
"n.nspname", "t.typname", NULL,

0 commit comments

Comments
 (0)