Attached is a patch to add verbose \describe commands to compliment our
existing but slightly cryptic family of \d commands.

The goals of this are:
- aid user discovery of \d-commands via tab completion
- make scripts and snippets slightly more self-documenting and
understandable
- save experienced users that 0.22 seconds where they try to remember what
\dFpS+ means or which command lists user mappings.

DESIGN CHOICES:

Every new command is of the form
\describe-some-system-object-type[-system][-verbose]. The -system suffix
stands in for the 'S' suffix and -verbose stands in for '+'.

New commands used the singular form, not plural.

Every new command has a direct analog \d-command, but the reverse is not
always true, especially when it comes to the commands that can specify
multiple object types. In those cases, there are multiple long versions
that correspond to several singular parameters (\describe-view,
\describe-materialized-view, \describe-index, etc) but no combinatorics
(i.e. no \describe-view-and-foreign-table).

There is a \describe-schema and \describe-namespace, both of which perform
\dn.

There is a \describe-role but no \describe-user or \describe-database-role.

I chose \describe-privilege for \dp

I chose \describe-type for \dT instead of \describe-data-type.

The command \describe-aggregate-function is \dfa, whereas
\describe-aggregate is \da.

NOTES:

There is currently nothing stopping you from using the short form suffixes
on long form commands, but the reverse isn't true. For example, you can
type \describe-functionS+ and it'll work, but \df-verbose will not. I allow
this mostly because it would take work to prevent it.

Documentation XML was updated but not formatted to make the diff easier to
read.

No regression cases were added. Currently our coverage of \d commands in
psql ifself is quite minimal:

~/src/postgres$ grep '\\d' src/test/regress/sql/psql.sql | sort | uniq
\copyright \dt arg1 \e arg1 arg2
\df exp
\d psql_serial_tab_id_seq


but perhaps we could test it indirectly in these other areas:

~/src/postgres/src/test/regress/sql$ grep '\\d' * | sed -e 's/^.*\\d/\\d/g'
-e 's/ .*//g' | sort | uniq -c
    156 \d
      2 \d'
      1 \d*',
    157 \d+
      1 \d{4})',
      1 \da
      2 \d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)',
      4 \des
      8 \des+
      1 \det+
      4 \deu
      6 \deu+
      1 \dew
     14 \dew+
     21 \df
      1 \dfn
      1 \dfp
      4 \dp
      4 \dRp
      6 \dRp+
      2 \dRs
      3 \dRs+
      2 \dt



On Mon, Jan 29, 2018 at 9:56 AM David Fetter <da...@fetter.org> wrote:

> On Mon, Jan 29, 2018 at 02:51:53PM +0000, Ryan Murphy wrote:
> > >
> > > >What I propose is in fact a server command, >which at least three of
> > > >the other popular RDBMSs already have.
> > >
> > Well to actually implement it, it would probably be a client command,
> > because that's what \d* are.
>
> Why should this command be silo'ed off to the psql client?  If it's a
> server command, it's available to all clients, not just psql.
>
> > We would most likely want them implemented the same, to avoid
> > needless complexity.
>
> We could certainly have \d call DESCRIBE for later versions of the
> server.  \ commands which call different SQL depending on server
> version have long been a standard practice.
>
> > I think people are more ok with \describe (with the backslash), which
> seems
> > like what you're suggesting anyway.  I read Vik's "hard pass" as being on
> > having DESCRIBE which looks like an SQL command but would actually be
> > implemented on the client.  This seems simpler at first but could cause
> > deep confusion later.
>
> If we implement \d as DESCRIBE for server versions as of when DESCRIBE
> is actually implemented, we've got wins all around.
>
> Best,
> David.
> --
> David Fetter <david(at)fetter(dot)org> http://fetter.org/
> Phone: +1 415 235 3778
>
> Remember to vote!
> Consider donating to Postgres: http://www.postgresql.org/about/donate
>
From e67e61ae789b09c98fe03378c819224d838c2f65 Mon Sep 17 00:00:00 2001
From: Corey Huinker <corey.huin...@gmail.com>
Date: Fri, 25 Jan 2019 00:57:23 +0000
Subject: [PATCH] Add \describe commands to compliment \d commands

---
 doc/src/sgml/ref/psql-ref.sgml | 175 ++++++++++++++++++++++++---------
 src/bin/psql/command.c         | 132 ++++++++++++++++++++++++-
 src/bin/psql/describe.c        |  13 ++-
 src/bin/psql/describe.h        |   3 +
 src/bin/psql/tab-complete.c    | 135 ++++++++++++++++++++-----
 5 files changed, 381 insertions(+), 77 deletions(-)

diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 6c76cf2f00..363d6d9678 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -871,6 +871,17 @@ testdb=&gt;
     same line.
     </para>
 
+    <para>
+    The family of meta-commands starting with <literal>\d</literal> often
+    have an equivalent <literal>\describe-</literal> "long form" command.
+    The long-form commands often have the suffixes <literal>-system</literal>
+    and <literal>-verbose</literal> which are the equivalent of the
+    short form suffixes <literal>S</literal> and <literal>+</literal>
+    respectively. The long form suffixes cannot be used on the short form
+    variants. Every <literal>\describe</literal> variant has an equivalent
+    short form variant.
+    </para>
+
     <para>
     The following meta-commands are defined:
 
@@ -1133,6 +1144,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\d[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1151,13 +1163,13 @@ testdb=&gt;
         </para>
 
         <para>
-        For some types of relation, <literal>\d</literal> shows additional information
+        For some types of relation, <literal>\d</literal> (and <literal>\describe</literal> shows additional information
         for each column: column values for sequences, indexed expressions for
         indexes, and foreign data wrapper options for foreign tables.
         </para>
 
         <para>
-        The command form <literal>\d+</literal> is identical, except that
+        The command forms <literal>\d+</literal> and <literal>\describe-verbose</literal> are identical to <literal>\d</literal>, except that
         more information is displayed: any comments associated with the
         columns of the table are shown, as is the presence of OIDs in the
         table, the view definition if the relation is a view, a non-default
@@ -1167,13 +1179,13 @@ testdb=&gt;
 
         <para>
         By default, only user-created objects are shown;  supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal> modifier for <literal>\d</literal> or <literal>-verbose</literal> modifier for <literal>\describe</literal> modifier to include system
         objects.
         </para>
 
         <note>
         <para>
-        If <command>\d</command> is used without a
+        If <command>\d</command> / <command>\describe</command> is used without a
         <replaceable class="parameter">pattern</replaceable> argument, it is
         equivalent to <command>\dtvmsE</command> which will show a list of
         all visible tables, views, materialized views, sequences and
@@ -1186,6 +1198,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\da[S] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-aggregate[-system] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1194,7 +1207,7 @@ testdb=&gt;
         class="parameter">pattern</replaceable>
         is specified, only aggregates whose names match the pattern are shown.
         By default, only user-created objects are shown;  supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal>/<literal>-system</literal> modifier to include system
         objects.
         </para>
         </listitem>
@@ -1202,13 +1215,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dA[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-access-method[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
         Lists access methods. If <replaceable
         class="parameter">pattern</replaceable> is specified, only access
         methods whose names match the pattern are shown. If
-        <literal>+</literal> is appended to the command name, each access
+        <literal>+</literal>/<literal>-verbose</literal> is appended to the command name, each access
         method is listed with its associated handler function and description.
         </para>
         </listitem>
@@ -1216,13 +1230,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\db[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-tablespace[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
         Lists tablespaces. If <replaceable
         class="parameter">pattern</replaceable>
         is specified, only tablespaces whose names match the pattern are shown.
-        If <literal>+</literal> is appended to the command name, each tablespace
+        If <literal>+</literal>/<literal>-verbose</literal> is appended to the command name, each tablespace
         is listed with its associated options, on-disk size, permissions and
         description.
         </para>
@@ -1232,6 +1247,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dc[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-conversion[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists conversions between character-set encodings.
@@ -1239,9 +1255,9 @@ testdb=&gt;
         is specified, only conversions whose names match the pattern are
         listed.
         By default, only user-created objects are shown;  supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal>/<literal>-system</literal> modifier to include system
         objects.
-        If <literal>+</literal> is appended to the command name, each object
+        If <literal>+</literal>/<literal>-verbose</literal> is appended to the command name, each object
         is listed with its associated description.
         </para>
         </listitem>
@@ -1250,13 +1266,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dC[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-cast[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists type casts.
         If <replaceable class="parameter">pattern</replaceable>
         is specified, only casts whose source or target types match the
         pattern are listed.
-        If <literal>+</literal> is appended to the command name, each object
+        If <literal>+</literal>/<literal>-verbose</literal> is appended to the command name, each object
         is listed with its associated description.
         </para>
         </listitem>
@@ -1265,6 +1282,11 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dd[S] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-constraint[-system] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-operator-class[-system] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-operator-family[-system] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-rule[-system] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-trigger[-system] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Shows the descriptions of objects of type <literal>constraint</literal>,
@@ -1279,7 +1301,7 @@ testdb=&gt;
         objects of the appropriate type if no argument is given.  But in either
         case, only objects that have a description are listed.
         By default, only user-created objects are shown;  supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal>/<literal>-system</literal> modifier to include system
         objects.
         </para>
 
@@ -1294,15 +1316,16 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dD[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-domain[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists domains. If <replaceable
         class="parameter">pattern</replaceable>
         is specified, only domains whose names match the pattern are shown.
         By default, only user-created objects are shown;  supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal>/<literal>-system</literal> modifier to include system
         objects.
-        If <literal>+</literal> is appended to the command name, each object
+        If <literal>+</literal>/<literal>-verbose</literal> is appended to the command name, each object
         is listed with its associated permissions and description.
         </para>
         </listitem>
@@ -1311,6 +1334,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\ddp [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-default-access-privelege [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists default access privilege settings.  An entry is shown for
@@ -1338,6 +1362,11 @@ testdb=&gt;
         <term><literal>\ds[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <term><literal>\dt[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <term><literal>\dv[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-index[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-materialized-view[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-sequence[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-table[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-view[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1346,16 +1375,22 @@ testdb=&gt;
         <literal>t</literal>, and <literal>v</literal>
         stand for foreign table, index, materialized view, sequence, table, and view,
         respectively.
-        You can specify any or all of
+        In the short forms, you can specify any or all of
         these letters, in any order, to obtain a listing of objects
         of these types.  For example, <literal>\dit</literal> lists indexes
-        and tables.  If <literal>+</literal> is
+        and tables.  If <literal>+</literal>/<literal>-verbose</literal> is
         appended to the command name, each object is listed with its
         physical size on disk and its associated description, if any.
+        <literal>\describe-foreign-table</literal> is equivalent to <literal>\dE</literal>.
+        <literal>\describe-index</literal> is equivalent to <literal>\di</literal>.
+        <literal>\describe-materialized-view</literal> is equivalent to <literal>\dm</literal>.
+        <literal>\describe-sequence</literal> is equivalent to <literal>\ds</literal>.
+        <literal>\describe-table</literal> is equivalent to <literal>\dt</literal>.
+        <literal>\describe-view</literal> is equivalent to <literal>\dv</literal>.
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only objects whose names match the pattern are listed.
         By default, only user-created objects are shown; supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal>/<literal>-system</literal> modifier to include system
         objects.
         </para>
         </listitem>
@@ -1364,13 +1399,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\des[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-foreign-servers[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists foreign servers (mnemonic: <quote>external
         servers</quote>).
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only those servers whose name matches the pattern
-        are listed.  If the form <literal>\des+</literal> is used, a
+        are listed.  If the forms <literal>\des+</literal> or <literal>\describe-foreign-server-verbose</literal> are used, a
         full description of each server is shown, including the
         server's access privileges, type, version, options, and description.
         </para>
@@ -1380,13 +1416,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\det[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-foreign-table[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists foreign tables (mnemonic: <quote>external tables</quote>).
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only entries whose table name or schema name matches
-        the pattern are listed.  If the form <literal>\det+</literal>
-        is used, generic options and the foreign table description
+        the pattern are listed.  If the forms <literal>\det+</literal> or <literal>\describe-foreign-table-verbose</literal>
+        are used, generic options and the foreign table description
         are also displayed.
         </para>
         </listitem>
@@ -1395,19 +1432,20 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\deu[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-user-mapping[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists user mappings (mnemonic: <quote>external
         users</quote>).
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only those mappings whose user names match the
-        pattern are listed.  If the form <literal>\deu+</literal> is
+        pattern are listed.  If the forms <literal>\deu+</literal> or <literal>\describe-user-mapping-verboze</literal> are
         used, additional information about each mapping is shown.
         </para>
 
         <caution>
         <para>
-        <literal>\deu+</literal> might also display the user name and
+        <literal>\deu+</literal> and <literal>\describe-user-mapping-verboze</literal> might also display the user name and
         password of the remote user, so care should be taken not to
         disclose them.
         </para>
@@ -1418,14 +1456,15 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dew[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-foreign-data-wrapper[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists foreign-data wrappers (mnemonic: <quote>external
         wrappers</quote>).
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only those foreign-data wrappers whose name matches
-        the pattern are listed.  If the form <literal>\dew+</literal>
-        is used, the access privileges, options, and description of the
+        the pattern are listed.  If the forms <literal>\dew+</literal> or <literal>\describe-foreign-data-wrapper-verbose</literal>
+        are used, the access privileges, options, and description of the
         foreign-data wrapper are also shown.
         </para>
         </listitem>
@@ -1434,25 +1473,37 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\df[anptwS+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-function[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-normal-function[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-procedure[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-aggregate-function[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-trigger-function[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-window-function[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
         Lists functions, together with their result data types, argument data
         types, and function types, which are classified as <quote>agg</quote>
         (aggregate), <quote>normal</quote>, <quote>procedure</quote>, <quote>trigger</quote>, or <quote>window</quote>.
-        To display only functions
+        In the short form, to display only functions
         of specific type(s), add the corresponding letters <literal>a</literal>,
         <literal>n</literal>, <literal>p</literal>, <literal>t</literal>, or <literal>w</literal> to the command.
         If <replaceable
         class="parameter">pattern</replaceable> is specified, only
         functions whose names match the pattern are shown.
         By default, only user-created
-        objects are shown; supply a pattern or the <literal>S</literal>
+        objects are shown; supply a pattern or the <literal>S</literal>/<literal>-system</literal>
         modifier to include system objects.
-        If the form <literal>\df+</literal> is used, additional information
+        If the form <literal>\df+</literal> or the <literal>-verbose</literal> suffix is used, additional information
         about each function is shown, including volatility,
         parallel safety, owner, security classification, access privileges,
         language, source code and description.
+        <literal>\describe-function</literal> is the equivalent of <literal>\df</literal>.
+        <literal>\describe-normal-function</literal> is the equivalent of <literal>\dff</literal>.
+        <literal>\describe-procedure</literal> is the equivalent of <literal>\dfp</literal>.
+        <literal>\describe-aggregate-function</literal> is the equivalent of <literal>\dfa</literal>.
+        <literal>\describe-trigger-function</literal> is the equivalent of <literal>\dft</literal>.
+        <literal>\describe-window-function</literal> is the equivalent of <literal>\dfw</literal>.
         </para>
 
         <tip>
@@ -1468,12 +1519,13 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dF[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-text-search-configuration[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search configurations.
          If <replaceable class="parameter">pattern</replaceable> is specified,
          only configurations whose names match the pattern are shown.
-         If the form <literal>\dF+</literal> is used, a full description of
+         If the form <literal>\dF+</literal> or <literal>\describe-text-search-configuration-verbose</literal> is used, a full description of
          each configuration is shown, including the underlying text search
          parser and the dictionary list for each parser token type.
         </para>
@@ -1482,12 +1534,13 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dFd[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-text-search-dictionary[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search dictionaries.
          If <replaceable class="parameter">pattern</replaceable> is specified,
          only dictionaries whose names match the pattern are shown.
-         If the form <literal>\dFd+</literal> is used, additional information
+         If the form <literal>\dFd+</literal> or <literal>\describe-text-search-dictionary-verbose</literal> is used, additional information
          is shown about each selected dictionary, including the underlying
          text search template and the option values.
         </para>
@@ -1496,12 +1549,13 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dFp[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-text-search-parser[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search parsers.
          If <replaceable class="parameter">pattern</replaceable> is specified,
          only parsers whose names match the pattern are shown.
-         If the form <literal>\dFp+</literal> is used, a full description of
+         If the form <literal>\dFp+</literal> or <literal>\describe-text-search-parser-verbose</literal> is used, a full description of
          each parser is shown, including the underlying functions and the
          list of recognized token types.
         </para>
@@ -1510,12 +1564,13 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dFt[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-text-search-template[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
          Lists text search templates.
          If <replaceable class="parameter">pattern</replaceable> is specified,
          only templates whose names match the pattern are shown.
-         If the form <literal>\dFt+</literal> is used, additional information
+         If the form <literal>\dFt+</literal> or <literal>\describe-text-search-template-verbose</literal> is used, additional information
          is shown about each template, including the underlying function names.
         </para>
         </listitem>
@@ -1524,6 +1579,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dg[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-role[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists database roles.
@@ -1531,10 +1587,10 @@ testdb=&gt;
         unified into <quote>roles</quote>, this command is now equivalent to
         <literal>\du</literal>.)
         By default, only user-created roles are shown; supply the
-        <literal>S</literal> modifier to include system roles.
+        <literal>S</literal> or <literal>-system</literal> modifier to include system roles.
         If <replaceable class="parameter">pattern</replaceable> is specified,
         only those roles whose names match the pattern are listed.
-        If the form <literal>\dg+</literal> is used, additional information
+        If the suffix <literal>+</literal> or <literal>-verbose></literal> is specified, additional information
         is shown about each role; currently this adds the comment for each
         role.
         </para>
@@ -1554,14 +1610,15 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dL[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-procedural-language[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists procedural languages. If <replaceable
         class="parameter">pattern</replaceable>
         is specified, only languages whose names match the pattern are listed.
         By default, only user-created languages
-        are shown; supply the <literal>S</literal> modifier to include system
-        objects. If <literal>+</literal> is appended to the command name, each
+        are shown; supply the <literal>S</literal> or <literal>-system</literal> modifier to include system
+        objects. If <literal>+</literal> or <literal>-verbose</literal> is appended to the command name, each
         language is listed with its call handler, validator, access privileges,
         and whether it is a system object.
         </para>
@@ -1571,6 +1628,8 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dn[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-schema[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-namespace[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
 
         <listitem>
         <para>
@@ -1578,8 +1637,8 @@ testdb=&gt;
         class="parameter">pattern</replaceable>
         is specified, only schemas whose names match the pattern are listed.
         By default, only user-created objects are shown; supply a
-        pattern or the <literal>S</literal> modifier to include system objects.
-        If <literal>+</literal> is appended to the command name, each object
+        pattern or the <literal>S</literal> or <literal>-system</literal> modifier to include system objects.
+        If <literal>+</literal> (or <literal>-verbose</literal> is appended to the command name, each object
         is listed with its associated permissions and description, if any.
         </para>
         </listitem>
@@ -1588,15 +1647,16 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\do[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-operator[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists operators with their operand and result types.
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only operators whose names match the pattern are listed.
         By default, only user-created objects are shown; supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal> or <literal>-system</literal> modifier to include system
         objects.
-        If <literal>+</literal> is appended to the command name,
+        If <literal>+</literal> or <literal>-verbose</literal> is appended to the command name,
         additional information about each operator is shown, currently just
         the name of the underlying function.
         </para>
@@ -1606,14 +1666,15 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dO[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-collation[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists collations.
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only collations whose names match the pattern are
         listed.  By default, only user-created objects are shown;
-        supply a pattern or the <literal>S</literal> modifier to
-        include system objects.  If <literal>+</literal> is appended
+        supply a pattern or the <literal>S</literal> or <literal>-system</literal> modifier to
+        include system objects.  If <literal>+</literal> or <literal>-verbose</literal> is appended
         to the command name, each collation is listed with its associated
         description, if any.
         Note that only collations usable with the current database's encoding
@@ -1626,6 +1687,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dp [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-privilege [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists tables, views and sequences with their
@@ -1647,6 +1709,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\drds [ <link linkend="app-psql-patterns"><replaceable class="parameter">role-pattern</replaceable></link> [ <link linkend="app-psql-patterns"><replaceable class="parameter">database-pattern</replaceable></link> ] ]</literal></term>
+        <term><literal>\describe-defined-configuration-setting [ <link linkend="app-psql-patterns"><replaceable class="parameter">role-pattern</replaceable></link> [ <link linkend="app-psql-patterns"><replaceable class="parameter">database-pattern</replaceable></link> ] ]</literal></term>
         <listitem>
         <para>
         Lists defined configuration settings.  These settings can be
@@ -1669,13 +1732,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dRp[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-replication-publication[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists replication publications.
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only those publications whose names match the pattern are
         listed.
-        If <literal>+</literal> is appended to the command name, the tables
+        If <literal>+</literal> or <literal>-verbose</literal> is appended to the command name, the tables
         associated with each publication are shown as well.
         </para>
         </listitem>
@@ -1683,13 +1747,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dRs[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-replication-subscription[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists replication subscriptions.
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only those subscriptions whose names match the pattern are
         listed.
-        If <literal>+</literal> is appended to the command name, additional
+        If <literal>+</literal> or <literal>-verbose</literal> is appended to the command name, additional
         properties of the subscriptions are shown.
         </para>
         </listitem>
@@ -1697,16 +1762,17 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dT[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-type[-system][-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists data types.
         If <replaceable class="parameter">pattern</replaceable> is
         specified, only types whose names match the pattern are listed.
-        If <literal>+</literal> is appended to the command name, each type is
+        If <literal>+</literal> or <literal>-verbose</literal> is appended to the command name, each type is
         listed with its internal name and size, its allowed values
         if it is an <type>enum</type> type, and its associated permissions.
         By default, only user-created objects are shown;  supply a
-        pattern or the <literal>S</literal> modifier to include system
+        pattern or the <literal>S</literal> or <literal>-system</literal> modifier to include system
         objects.
         </para>
         </listitem>
@@ -1714,6 +1780,7 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\du[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-role[S+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists database roles.
@@ -1721,10 +1788,10 @@ testdb=&gt;
         unified into <quote>roles</quote>, this command is now equivalent to
         <literal>\dg</literal>.)
         By default, only user-created roles are shown; supply the
-        <literal>S</literal> modifier to include system roles.
+        <literal>S</literal> or <literal>-system</literal> modifier to include system roles.
         If <replaceable class="parameter">pattern</replaceable> is specified,
         only those roles whose names match the pattern are listed.
-        If the form <literal>\du+</literal> is used, additional information
+        If the suffix <literal>+</literal> or <literal>-verbose</literal> is used, additional information
         is shown about each role; currently this adds the comment for each
         role.
         </para>
@@ -1733,13 +1800,14 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dx[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-extension[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists installed extensions.
         If <replaceable class="parameter">pattern</replaceable>
         is specified, only those extensions whose names match the pattern
         are listed.
-        If the form <literal>\dx+</literal> is used, all the objects belonging
+        If the suffix <literal>+</literal> or <literal>-verbose</literal> is used, all the objects belonging
         to each matching extension are listed.
         </para>
         </listitem>
@@ -1747,15 +1815,24 @@ testdb=&gt;
 
       <varlistentry>
         <term><literal>\dy[+] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
+        <term><literal>\describe-event-trigger[-verbose] [ <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
         <listitem>
         <para>
         Lists event triggers.
         If <replaceable class="parameter">pattern</replaceable>
         is specified, only those event triggers whose names match the pattern
         are listed.
-        If <literal>+</literal> is appended to the command name, each object
+        If <literal>+</literal> or <literal>-verbose</literal> is appended to the command name, each object
         is listed with its associated description.
         </para>
+
+        <tip>
+        <para>
+        Long form commands can aid in clarity when sharing code with others.
+        Using tab completion can reduce typing and aid in the discovery of new
+        <literal>\describe</literal> commands.
+        </para>
+        </tip>
         </listitem>
       </varlistentry>
 
@@ -2291,7 +2368,7 @@ SELECT
         character set encodings, and access privileges.
         If <replaceable class="parameter">pattern</replaceable> is specified,
         only databases whose names match the pattern are listed.
-        If <literal>+</literal> is appended to the command name, database
+        If <literal>+</literal> (or <literal>-verbose</literal> in the long form) is appended to the command name, database
         sizes, default tablespaces, and descriptions are also displayed.
         (Size information is only available for databases that the current
         user can connect to.)
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index ab259c473a..a27be4d916 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -685,6 +685,12 @@ exec_command_crosstabview(PsqlScanState scan_state, bool active_branch)
 	return status;
 }
 
+static
+bool cmd_match(const char* str, const char* pattern)
+{
+	return (strncmp(str, pattern, strlen(pattern)) == 0);
+}
+
 /*
  * \d* commands
  */
@@ -853,7 +859,131 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
 				switch (cmd[2])
 				{
 					case 's':
-						success = listForeignServers(pattern, show_verbose);
+						if (cmd[3] != 'c')
+						{
+							/* no \describe, just \des */
+							success = listForeignServers(pattern, show_verbose);
+							break;
+						}
+						else if (!cmd_match(cmd,"describe"))
+						{
+							status = PSQL_CMD_UNKNOWN;
+							break;
+						}
+						else
+						{
+							/* Allow -verbose suffix but keep '+' */
+							if (strstr(cmd, "-verbose") != NULL)
+								show_verbose = true;
+							/* Allow -system suffix but keep 'S' */
+							if (strstr(cmd, "-system") != NULL)
+								show_system = true;
+
+							if (cmd_match(cmd,"describe-aggregate-function"))
+								success = describeAggregates(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-access-method"))
+								success = describeAccessMethods(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-tablespace"))
+								success = describeTablespaces(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-conversion"))
+								success = listConversions(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-cast"))
+								success = listCasts(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-constraint") ||
+									 cmd_match(cmd, "describe-operator-class") ||
+									 cmd_match(cmd, "describe-operator-family") ||
+									 cmd_match(cmd, "describe-rule") ||
+									 cmd_match(cmd, "describe-trigger"))
+								success = objectDescription(pattern, show_system);
+							else if (cmd_match(cmd, "describe-domain"))
+								success = listDomains(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-default-access-privelege "))
+								success = listDefaultACLs(pattern);
+							else if (cmd_match(cmd, "describe-foreign-server"))
+								success = listForeignServers(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-foreign-table"))
+								success = listForeignTables(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-index"))
+								success = listTables("i", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-materialized-view"))
+								success = listTables("m", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-sequence"))
+								success = listTables("s", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-table"))
+								success = listTables("t", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-view"))
+								success = listTables("v", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-user-mapping"))
+								success = listUserMappings(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-foreign-data-wrapper"))
+								success = listForeignDataWrappers(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-function"))
+								success = describeFunctions("\0", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-procedure"))
+								success = describeFunctions("p", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-trigger-function"))
+								success = describeFunctions("t", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-window-function"))
+								success = describeFunctions("w", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-normal-function"))
+								success = describeFunctions("n", pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-text-search-configuration"))
+								success = listTSConfigs(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-text-search-dictionary"))
+								success = listTSDictionaries(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-text-search-parser"))
+								success = listTSParsers(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-text-search-templates"))
+								success = listTSTemplates(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-role"))
+								success = describeRoles(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-procedural-language"))
+								success = listLanguages(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-schema") ||
+									 cmd_match(cmd, "describe-namespace"))
+								success = listSchemas(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-operator"))
+								success = describeOperators(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-collation"))
+								success = listCollations(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-privilege "))
+								success = permissionsList(pattern);
+							else if (cmd_match(cmd, "describe-defined-configuration-setting "))
+							{
+								char	   *pattern2 = NULL;
+
+								if (pattern)
+									pattern2 = psql_scan_slash_option(scan_state,
+																	  OT_NORMAL, NULL, true);
+								success = listDbRoleSettings(pattern, pattern2);
+
+								if (pattern2)
+									free(pattern2);
+							}
+							else if (cmd_match(cmd, "describe-replication-publication"))
+								if (show_verbose)
+									success = describePublications(pattern);
+								else
+									success = listPublications(pattern);
+							else if (cmd_match(cmd, "describe-replication-subscription"))
+								success = describeSubscriptions(pattern, show_verbose);
+							else if (cmd_match(cmd, "describe-type"))
+								success = describeTypes(pattern, show_verbose, show_system);
+							else if (cmd_match(cmd, "describe-extension"))
+								if (show_verbose)
+									success = listExtensionContents(pattern);
+								else
+									success = listExtensions(pattern);
+							else if (cmd_match(cmd, "describe-event-trigger"))
+								success = listEventTriggers(pattern, show_verbose);
+							else if (pattern)
+								/* generic describe on a specific pattern */
+								success = describeTableDetails(pattern, show_verbose, show_system);
+							else
+								/* standard listing of interesting things */
+								success = listTables("tvmsE", NULL, show_verbose, show_system);
+						}
+						status = PSQL_CMD_UNKNOWN;
 						break;
 					case 'u':
 						success = listUserMappings(pattern, show_verbose);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 4da6719ce7..444b0a2ae4 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -54,6 +54,18 @@ static bool listOneExtensionContents(const char *extname, const char *oid);
  *----------------
  */
 
+/*
+ * \describe
+ *
+ * The full-word version of every \d* command
+ */
+bool
+describe(const char *words, const char *pattern, bool verbose, bool showSystem)
+{
+
+	return true;
+}
+
 
 /*
  * \da
@@ -294,7 +306,6 @@ describeTablespaces(const char *pattern, bool verbose)
 	return true;
 }
 
-
 /*
  * \df
  * Takes an optional regexp to select particular functions.
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index 4ff1f91f38..ff13e3bbd1 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -9,6 +9,9 @@
 #define DESCRIBE_H
 
 
+/* \describe, \describe-table, etc */
+extern bool describe(const char *words, const char *pattern, bool verbose, bool showSystem);
+
 /* \da */
 extern bool describeAggregates(const char *pattern, bool verbose, bool showSystem);
 
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 292b1f483a..11821a4c86 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1400,6 +1400,51 @@ psql_completion(const char *text, int start, int end)
 		"\\w", "\\watch",
 		"\\z",
 		"\\!", "\\?",
+		"\\describe-aggregate-function",
+		"\\describe-aggregate",
+		"\\describe-access-method",
+		"\\describe-tablespace",
+		"\\describe-conversion",
+		"\\describe-cast",
+		"\\describe-constraint",
+		"\\describe-operator-class",
+		"\\describe-operator-family",
+		"\\describe-rule",
+		"\\describe-trigger",
+		"\\describe-domain",
+		"\\describe-default-access-privelege ",
+		"\\describe-foreign-server",
+		"\\describe-foreign-table",
+		"\\describe-index",
+		"\\describe-materialized-view",
+		"\\describe-sequence",
+		"\\describe-table",
+		"\\describe-view",
+		"\\describe-user-mapping",
+		"\\describe-foreign-data-wrapper",
+		"\\describe-function",
+		"\\describe-procedure",
+		"\\describe-trigger-function",
+		"\\describe-window-function",
+		"\\describe-normal-function",
+		"\\describe-text-search-configuration",
+		"\\describe-text-search-dictionary",
+		"\\describe-text-search-parser",
+		"\\describe-text-search-templates",
+		"\\describe-role",
+		"\\describe-procedural-language",
+		"\\describe-schema",
+		"\\describe-namespace",
+		"\\describe-operator",
+		"\\describe-collation",
+		"\\describe-privilege ",
+		"\\describe-defined-configuration-setting ",
+		"\\describe-replication-publication",
+		"\\describe-replication-subscription",
+		"\\describe-type",
+		"\\describe-extension",
+		"\\describe-event-trigger",
+		"\\describe",
 		NULL
 	};
 
@@ -3460,60 +3505,98 @@ psql_completion(const char *text, int start, int end)
 		if (!recognized_connection_string(prev_wd))
 			COMPLETE_WITH_QUERY(Query_for_list_of_roles);
 	}
-	else if (TailMatchesCS("\\da*"))
+	else if (TailMatchesCS("\\df*") ||
+			 TailMatchesCS("\\describe-function*") ||
+			 TailMatchesCS("\\describe-aggregate-function*") ||
+			 TailMatchesCS("\\describe-window-function*") ||
+			 TailMatchesCS("\\describe-procedure*") ||
+			 TailMatchesCS("\\describe-normal-function*"))
+		COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
+	else if (TailMatchesCS("\\da*") ||
+			 TailMatchesCS("\\describe-aggregate*"))
 		COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_aggregates, NULL);
-	else if (TailMatchesCS("\\dA*"))
+	else if (TailMatchesCS("\\dA*") ||
+			 TailMatchesCS("\\describe-access-method*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
-	else if (TailMatchesCS("\\db*"))
+	else if (TailMatchesCS("\\db*") ||
+			 TailMatchesCS("\\describe-tablespace*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces);
-	else if (TailMatchesCS("\\dD*"))
+	else if (TailMatchesCS("\\dD*") ||
+			 TailMatchesCS("\\describe-domain*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains, NULL);
-	else if (TailMatchesCS("\\des*"))
-		COMPLETE_WITH_QUERY(Query_for_list_of_servers);
-	else if (TailMatchesCS("\\deu*"))
+	else if (TailMatchesCS("\\deu*") ||
+			 TailMatchesCS("\\describe-user-mapping*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_user_mappings);
-	else if (TailMatchesCS("\\dew*"))
+	else if (TailMatchesCS("\\dew*") ||
+			 TailMatchesCS("\\describe-foreign-data-wrapper*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_fdws);
-	else if (TailMatchesCS("\\df*"))
-		COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(Query_for_list_of_functions, NULL);
 
-	else if (TailMatchesCS("\\dFd*"))
+	else if (TailMatchesCS("\\dFd*") ||
+			 TailMatchesCS("\\describe-text-search-dictionary*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_ts_dictionaries);
-	else if (TailMatchesCS("\\dFp*"))
+	else if (TailMatchesCS("\\dFp*") ||
+			 TailMatchesCS("\\describe-text-search-parser*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_ts_parsers);
-	else if (TailMatchesCS("\\dFt*"))
+	else if (TailMatchesCS("\\dFt*") ||
+			 TailMatchesCS("\\describe-text-search-template*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_ts_templates);
 	/* must be at end of \dF alternatives: */
 	else if (TailMatchesCS("\\dF*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_ts_configurations);
 
-	else if (TailMatchesCS("\\di*"))
+	else if (TailMatchesCS("\\di*") ||
+			 TailMatchesCS("\\describe-index*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
-	else if (TailMatchesCS("\\dL*"))
+	else if (TailMatchesCS("\\dL*") ||
+			 TailMatchesCS("\\describe-procedural-language*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_languages);
-	else if (TailMatchesCS("\\dn*"))
+	else if (TailMatchesCS("\\dn*") ||
+			 TailMatchesCS("\\describe-schema*") ||
+			 TailMatchesCS("\\describe-namespace*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
-	else if (TailMatchesCS("\\dp") || TailMatchesCS("\\z"))
+	else if (TailMatchesCS("\\dp") || TailMatchesCS("\\z") ||
+			 TailMatchesCS("\\describe-privelege*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_grantables, NULL);
-	else if (TailMatchesCS("\\ds*"))
+	else if (TailMatchesCS("\\ds*") ||
+			 TailMatchesCS("\\describe-sequence*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences, NULL);
-	else if (TailMatchesCS("\\dt*"))
+	else if (TailMatchesCS("\\dt*") ||
+			 TailMatchesCS("\\describe-table*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
-	else if (TailMatchesCS("\\dT*"))
+	else if (TailMatchesCS("\\dT*") ||
+			 TailMatchesCS("\\describe-type*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
-	else if (TailMatchesCS("\\du*") || TailMatchesCS("\\dg*"))
+	else if (TailMatchesCS("\\du*") || TailMatchesCS("\\dg*") ||
+			 TailMatchesCS("\\describe-role*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
-	else if (TailMatchesCS("\\dv*"))
+	else if (TailMatchesCS("\\dv*") ||
+			 TailMatchesCS("\\describe-view*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views, NULL);
-	else if (TailMatchesCS("\\dx*"))
+	else if (TailMatchesCS("\\dx*") ||
+			 TailMatchesCS("\\describe-extension*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
-	else if (TailMatchesCS("\\dm*"))
+	else if (TailMatchesCS("\\dm*") ||
+			 TailMatchesCS("\\describe-materialized-view*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
-	else if (TailMatchesCS("\\dE*"))
+	else if (TailMatchesCS("\\dE*") ||
+			 TailMatchesCS("\\describe-foreign-table*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_foreign_tables, NULL);
-	else if (TailMatchesCS("\\dy*"))
+	else if (TailMatchesCS("\\dy*") ||
+			 TailMatchesCS("\\describe-event-trigger*"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
 
+	/* short version \\des has conflict with \\describe */
+	else if (TailMatchesCS("\\describe-foreign-server*"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_servers);
+
+	/* catch-all \\describe */
+	else if (TailMatchesCS("\\describe*"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_relations, NULL);
+
+	/* \\des* must go after \\describe */
+	else if (TailMatchesCS("\\des*"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_servers);
+
 	/* must be at end of \d alternatives: */
 	else if (TailMatchesCS("\\d*"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_relations, NULL);
-- 
2.17.1

Reply via email to