Index: command.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.66 diff -c -r1.66 command.c *** command.c 2002/02/25 21:37:42 1.66 --- command.c 2002/02/26 17:26:41 *************** *** 380,385 **** --- 380,389 ---- case 'u': success = describeUsers(name); break; + case 'D': + success = listDomains(name); + break; + default: status = CMD_UNKNOWN; } Index: describe.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.c,v retrieving revision 1.42 diff -c -r1.42 describe.c *** describe.c 2001/11/12 15:57:08 1.42 --- describe.c 2002/02/26 17:26:41 *************** *** 1083,1085 **** --- 1083,1133 ---- 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; + } Index: describe.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.h,v retrieving revision 1.13 diff -c -r1.13 describe.h *** describe.h 2001/11/05 17:46:31 1.13 --- describe.h 2002/02/26 17:26:41 *************** *** 40,43 **** --- 40,46 ---- /* \dt, \di, \ds, \dS, etc. */ bool listTables(const char *infotype, const char *name, bool desc); + /* \dD */ + bool listDomains(const char *name); + #endif /* DESCRIBE_H */ Index: help.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/help.c,v retrieving revision 1.42 diff -c -r1.42 help.c *** help.c 2001/10/25 05:49:54 1.42 --- help.c 2002/02/26 17:26:41 *************** *** 205,210 **** --- 205,211 ---- fprintf(fout, _(" \\df list functions\n")); fprintf(fout, _(" \\do list operators\n")); fprintf(fout, _(" \\dT list data types\n")); + fprintf(fout, _(" \\dD [NAME] list domains\n")); fprintf(fout, _(" \\e FILENAME edit the current query buffer or file with external editor\n")); fprintf(fout, _(" \\echo TEXT write text to standard output\n")); fprintf(fout, _(" \\encoding ENCODING set client encoding\n"));