diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 84f783392e6db6a7dea422b6f3776114e0e74481..350128fa7244041d76ca06421785fd3c69eff6bc 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.63 2002/03/11 05:03:52 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.64 2002/03/19 02:32:19 momjian Exp $
 PostgreSQL documentation
 -->
 
@@ -415,6 +415,29 @@ testdb=>
       </varlistentry>
 
 
+      <varlistentry>
+        <term><literal>\dD</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
+        <listitem>
+        <para>
+        Lists all database domains.
+        </para>
+
+        <para>
+        Descriptions for objects can be generated with the <command>COMMENT ON</command>
+        <acronym>SQL</acronym> command.
+	</para>
+
+        <note>
+        <para>
+        <productname>PostgreSQL</productname> stores the object descriptions in the
+        pg_description system table.
+        </para>
+        </note>
+
+        </listitem>
+      </varlistentry>
+
+
       <varlistentry>
         <term><literal>\df [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
 
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index a9ca4b30b96d94db0fc5f5d29fb7191f7d8b6ec1..97f58dc3f616ebd020653b47c3d61b794b32b9f4 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.69 2002/03/07 17:54:39 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.70 2002/03/19 02:32:21 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "command.h"
@@ -380,6 +380,10 @@ exec_command(const char *cmd,
 			case 'u':
 				success = describeUsers(name);
 				break;
+			case 'D':
+				success = listDomains(name);
+				break;
+
 			default:
 				status = CMD_UNKNOWN;
 		}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 8a6eca490d88b62815a4b648a1f927b1ce3afa0c..c45b81c7a8297612ff60ef4111b6b5b3ca5769b5 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.45 2002/03/07 17:54:39 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.46 2002/03/19 02:32:21 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -1036,3 +1036,51 @@ listTables(const char *infotype, const char *name, bool desc)
 	PQclear(res);
 	return true;
 }
+
+/*
+ * \dD [domain]
+ *
+ * Describes domains, possibly based on a simplistic prefix search on the
+ * argument.
+ */
+
+bool
+listDomains(const char *name)
+{
+	char		buf[512 + REGEXP_CUTOFF];
+	PGresult   *res;
+	printQueryOpt myopt = pset.popt;
+
+	snprintf(buf, sizeof(buf),
+		 "SELECT t.typname as \"%s\",\n"
+		 "       format_type( t.typbasetype, t.typmod) as \"%s\",\n"
+		 "       CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault\n"
+		 "            WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n"
+		 "            WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault\n"
+		 "            ELSE ''\n"
+		 "       END as \"%s\"\n"
+		 "FROM pg_type t\n"
+		 "WHERE t.typtype = 'd'\n",
+		 _("Name"),
+		 _("Type"),
+		 _("Modifier"));
+	if (name)
+	{
+		strcat(buf, "AND t.typname ~ '^");
+		strncat(buf, name, REGEXP_CUTOFF);
+		strcat(buf, "'\n");
+	}
+	strcat(buf, "ORDER BY 1;");
+
+	res = PSQLexec(buf);
+	if (!res)
+		return false;
+
+	myopt.nullPrint = NULL;
+	myopt.title = _("List of database domains");
+
+	printQuery(res, &myopt, pset.queryFout);
+
+	PQclear(res);
+	return true;
+}
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index d179ffced5668f785e28d7d92da85bfb774e77bd..4c95733912a389fec3b4365fcb6853281631d3f3 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.15 2002/03/07 17:54:41 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.16 2002/03/19 02:32:21 momjian Exp $
  */
 #ifndef DESCRIBE_H
 #define DESCRIBE_H
@@ -40,4 +40,7 @@ bool		listAllDbs(bool desc);
 /* \dt, \di, \ds, \dS, etc. */
 bool		listTables(const char *infotype, const char *name, bool desc);
 
+/* \dD */
+bool		listDomains(const char *name);
+
 #endif   /* DESCRIBE_H */
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index 3560c261b1950871a036e5c5cd476e0567d00da2..3d71a3150834ae2ccd71645d76b11e553d35a4cf 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.48 2002/03/11 18:26:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.49 2002/03/19 02:32:21 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "help.h"
@@ -202,6 +202,7 @@ slashUsage(void)
 	fprintf(fout, _(" \\d{p|S|l}      list access privileges, system tables, or large objects\n"));
 	fprintf(fout, _(" \\da            list aggregate functions\n"));
 	fprintf(fout, _(" \\dd [NAME]     show comment for table, type, function, or operator\n"));
+	fprintf(fout, _(" \\dD [NAME]     list domains\n"));
 	fprintf(fout, _(" \\df            list functions\n"));
 	fprintf(fout, _(" \\do            list operators\n"));
 	fprintf(fout, _(" \\dT            list data types\n"));