Bruce Momjian wrote:
> I know we don't like the current behavior, but I think we need to make
> them consistent first for easy testing and so when we change it, it will
> remain consistent.
> 
> I will work on a consensus patch soon for the new behavior.

Here is what I hope is a consensus patch.  It adds 'A' to show all
objects, including system ones.  It turns out that this is how 'S' works
now in CVS, but 'S' is unclear because it suggests just system objects;
'A' for show 'all' objects seems clearer.

I did not add any special handling for patterns:

        test=> \df repeat
                           List of functions
         Schema | Name | Result data type | Argument data types
        --------+------+------------------+---------------------
        (0 rows)
        
        test=> \dfA repeat
                              List of functions
           Schema   |  Name  | Result data type | Argument data types
        ------------+--------+------------------+---------------------
         pg_catalog | repeat | text             | text, integer
        (1 row)

I am afraid that special pattern rules are going to be too confusing. 
You can see only system objects by referencing pg_catalog:

        test=> \dtA pg_catalog.pg_t*
                        List of relations
           Schema   |       Name       | Type  |  Owner
        ------------+------------------+-------+----------
         pg_catalog | pg_tablespace    | table | postgres
         pg_catalog | pg_trigger       | table | postgres
         pg_catalog | pg_ts_config     | table | postgres
         pg_catalog | pg_ts_config_map | table | postgres
         pg_catalog | pg_ts_dict       | table | postgres
         pg_catalog | pg_ts_parser     | table | postgres
         pg_catalog | pg_ts_template   | table | postgres
         pg_catalog | pg_type          | table | postgres
        (8 rows)

Patch attached.  One interesting idea would be to assume 'A' if the
a schema is specified in the pattern, so;

        \df pg_catalog.*

would work without 'A'.

With this patch, \d and \dt show only user tables, and \df shows only
user functions.  I think usability-wise, these are good, and \dA, \dtA,
and \dfA include system tables and functions.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.218
diff -c -c -r1.218 psql-ref.sgml
*** doc/src/sgml/ref/psql-ref.sgml	20 Jan 2009 02:38:37 -0000	1.218
--- doc/src/sgml/ref/psql-ref.sgml	20 Jan 2009 03:54:20 -0000
***************
*** 833,840 ****
          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 letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
  
--- 833,840 ----
          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 letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
  
***************
*** 859,866 ****
          return type and the data types they operate on. If <replaceable
          class="parameter">pattern</replaceable>
          is specified, only aggregates whose names match the pattern are shown.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
--- 859,866 ----
          return type and the data types they operate on. If <replaceable
          class="parameter">pattern</replaceable>
          is specified, only aggregates whose names match the pattern are shown.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
***************
*** 890,897 ****
          If <replaceable class="parameter">pattern</replaceable>
          is specified, only conversions whose names match the pattern are
          listed.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
--- 890,897 ----
          If <replaceable class="parameter">pattern</replaceable>
          is specified, only conversions whose names match the pattern are
          listed.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
***************
*** 919,926 ****
          class="parameter">pattern</replaceable>, or of all visible objects if
          no argument is given.  But in either case, only objects that have
          a description are listed.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          (<quote>Object</quote> covers aggregates, functions, operators,
          types, relations (tables, views, indexes, sequences, large
--- 919,926 ----
          class="parameter">pattern</replaceable>, or of all visible objects if
          no argument is given.  But in either case, only objects that have
          a description are listed.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          (<quote>Object</quote> covers aggregates, functions, operators,
          types, relations (tables, views, indexes, sequences, large
***************
*** 951,958 ****
          Lists all available domains. If <replaceable
          class="parameter">pattern</replaceable>
          is specified, only matching domains are shown.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
--- 951,958 ----
          Lists all available domains. If <replaceable
          class="parameter">pattern</replaceable>
          is specified, only matching domains are shown.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
***************
*** 1025,1032 ****
          is specified, only functions whose names match the pattern are shown.
          If the form <literal>\df+</literal> is used, additional information about
          each function, including volatility, language, source code and description, is shown.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
  
--- 1025,1032 ----
          is specified, only functions whose names match the pattern are shown.
          If the form <literal>\df+</literal> is used, additional information about
          each function, including volatility, language, source code and description, is shown.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
  
***************
*** 1135,1142 ****
          and tables.  If <literal>+</literal> is
          appended to the command name, each object is listed with its
          physical size on disk and its associated description, if any.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
  
--- 1135,1142 ----
          and tables.  If <literal>+</literal> is
          appended to the command name, each object is listed with its
          physical size on disk and its associated description, if any.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
  
***************
*** 1182,1189 ****
          Lists available operators with their operand and return types.
          If <replaceable class="parameter">pattern</replaceable> is
          specified, only operators whose names match the pattern are listed.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
--- 1182,1189 ----
          Lists available operators with their operand and return types.
          If <replaceable class="parameter">pattern</replaceable> is
          specified, only operators whose names match the pattern are listed.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
***************
*** 1217,1224 ****
          class="parameter">pattern</replaceable>. The command form
          <literal>\dT+</literal> shows extra information, namely the type's internal name, size, and
          allowed values for <type>enum</> types.
!         The letter <literal>S</literal> adds the listing of system
!         objects; without <literal>S</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
--- 1217,1224 ----
          class="parameter">pattern</replaceable>. The command form
          <literal>\dT+</literal> shows extra information, namely the type's internal name, size, and
          allowed values for <type>enum</> types.
!         The letter <literal>A</literal> adds the listing of system
!         objects; without <literal>A</literal>, only non-system
          objects are shown.
          </para>
          </listitem>
Index: src/bin/psql/command.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.202
diff -c -c -r1.202 command.c
*** src/bin/psql/command.c	20 Jan 2009 02:13:42 -0000	1.202
--- src/bin/psql/command.c	20 Jan 2009 03:54:20 -0000
***************
*** 334,346 ****
  										 OT_NORMAL, NULL, true);
  
  		show_verbose = strchr(cmd, '+') ? true : false;
! 		show_system = strchr(cmd, 'S') ? true : false;
  
  		switch (cmd[1])
  		{
  			case '\0':
  			case '+':
! 			case 'S':
  				if (pattern)
  					success = describeTableDetails(pattern, show_verbose, show_system);
  				else
--- 334,346 ----
  										 OT_NORMAL, NULL, true);
  
  		show_verbose = strchr(cmd, '+') ? true : false;
! 		show_system = strchr(cmd, 'A') ? true : false;
  
  		switch (cmd[1])
  		{
  			case '\0':
  			case '+':
! 			case 'A':
  				if (pattern)
  					success = describeTableDetails(pattern, show_verbose, show_system);
  				else
Index: src/bin/psql/describe.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.197
diff -c -c -r1.197 describe.c
*** src/bin/psql/describe.c	20 Jan 2009 02:13:42 -0000	1.197
--- src/bin/psql/describe.c	20 Jan 2009 03:54:20 -0000
***************
*** 1007,1013 ****
  							  schemaname, relationname);
  			break;
  		case 's':
! 			/* not used as of 8.2, but keep it for backwards compatibility */
  			printfPQExpBuffer(&title, _("Special relation \"%s.%s\""),
  							  schemaname, relationname);
  			break;
--- 1007,1013 ----
  							  schemaname, relationname);
  			break;
  		case 's':
! 			/* used in <= 8.1.X for special; keep for backward compatibility */
  			printfPQExpBuffer(&title, _("Special relation \"%s.%s\""),
  							  schemaname, relationname);
  			break;
Index: src/bin/psql/help.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/help.c,v
retrieving revision 1.138
diff -c -c -r1.138 help.c
*** src/bin/psql/help.c	7 Jan 2009 03:05:26 -0000	1.138
--- src/bin/psql/help.c	20 Jan 2009 03:54:20 -0000
***************
*** 196,229 ****
  	fprintf(output, _("Informational\n"));
  	fprintf(output, _("  Modifiers: S = show system objects  + = Additional detail\n"));
  	fprintf(output, _("  \\l[+]                 list all databases\n"));
! 	fprintf(output, _("  \\d[S+]                list tables, views, and sequences\n"));
! 	fprintf(output, _("  \\d[S+]   NAME         describe table, view, sequence, or index\n"));
! 	fprintf(output, _("  \\da[S]   [PATTERN]    list aggregate functions\n"));
  	fprintf(output, _("  \\db[+]   [PATTERN]    list tablespaces\n"));
! 	fprintf(output, _("  \\dc[S]   [PATTERN]    list conversions\n"));
  	fprintf(output, _("  \\dC      [PATTERN]    list casts\n"));
! 	fprintf(output, _("  \\dd[S]   [PATTERN]    show comments on objects\n"));
! 	fprintf(output, _("  \\dD[S]   [PATTERN]    list domains\n"));
  	fprintf(output, _("  \\des[+]  [PATTERN]    list foreign servers\n"));
  	fprintf(output, _("  \\deu[+]  [PATTERN]    list user mappings\n"));
  	fprintf(output, _("  \\dew[+]  [PATTERN]    list foreign-data wrappers\n"));
! 	fprintf(output, _("  \\df[S+]  [PATTERN]    list functions\n"));
  	fprintf(output, _("  \\dF[+]   [PATTERN]    list text search configurations\n"));
  	fprintf(output, _("  \\dFd[+]  [PATTERN]    list text search dictionaries\n"));
  	fprintf(output, _("  \\dFp[+]  [PATTERN]    list text search parsers\n"));
  	fprintf(output, _("  \\dFt[+]  [PATTERN]    list text search templates\n"));
  	fprintf(output, _("  \\dg      [PATTERN]    list roles (groups)\n"));
! 	fprintf(output, _("  \\di[S+]  [PATTERN]    list indexes\n"));
  	fprintf(output, _("  \\dl                   list large objects, same as \\lo_list\n"));
  	fprintf(output, _("  \\dn[+]   [PATTERN]    list schemas\n"));
! 	fprintf(output, _("  \\do[S]   [PATTERN]    list operators\n"));
  	fprintf(output, _("  \\dp      [PATTERN]    list table, view, and sequence access privileges\n"));
  	fprintf(output, _("   \\z      [PATTERN]    same as \\dp\n"));
! 	fprintf(output, _("  \\ds[S+]  [PATTERN]    list sequences\n"));
! 	fprintf(output, _("  \\dt[S+]  [PATTERN]    list tables\n"));
! 	fprintf(output, _("  \\dT[S+]  [PATTERN]    list data types\n"));
  	fprintf(output, _("  \\du      [PATTERN]    list roles (users)\n"));
! 	fprintf(output, _("  \\dv[S+]  [PATTERN]    list views\n"));
  	fprintf(output, "\n");
  
  	fprintf(output, _("Formatting\n"));
--- 196,229 ----
  	fprintf(output, _("Informational\n"));
  	fprintf(output, _("  Modifiers: S = show system objects  + = Additional detail\n"));
  	fprintf(output, _("  \\l[+]                 list all databases\n"));
! 	fprintf(output, _("  \\d[A+]                list tables, views, and sequences\n"));
! 	fprintf(output, _("  \\d[A+]   NAME         describe table, view, sequence, or index\n"));
! 	fprintf(output, _("  \\da[A]   [PATTERN]    list aggregate functions\n"));
  	fprintf(output, _("  \\db[+]   [PATTERN]    list tablespaces\n"));
! 	fprintf(output, _("  \\dc[A]   [PATTERN]    list conversions\n"));
  	fprintf(output, _("  \\dC      [PATTERN]    list casts\n"));
! 	fprintf(output, _("  \\dd[A]   [PATTERN]    show comments on objects\n"));
! 	fprintf(output, _("  \\dD[A]   [PATTERN]    list domains\n"));
  	fprintf(output, _("  \\des[+]  [PATTERN]    list foreign servers\n"));
  	fprintf(output, _("  \\deu[+]  [PATTERN]    list user mappings\n"));
  	fprintf(output, _("  \\dew[+]  [PATTERN]    list foreign-data wrappers\n"));
! 	fprintf(output, _("  \\df[A+]  [PATTERN]    list functions\n"));
  	fprintf(output, _("  \\dF[+]   [PATTERN]    list text search configurations\n"));
  	fprintf(output, _("  \\dFd[+]  [PATTERN]    list text search dictionaries\n"));
  	fprintf(output, _("  \\dFp[+]  [PATTERN]    list text search parsers\n"));
  	fprintf(output, _("  \\dFt[+]  [PATTERN]    list text search templates\n"));
  	fprintf(output, _("  \\dg      [PATTERN]    list roles (groups)\n"));
! 	fprintf(output, _("  \\di[A+]  [PATTERN]    list indexes\n"));
  	fprintf(output, _("  \\dl                   list large objects, same as \\lo_list\n"));
  	fprintf(output, _("  \\dn[+]   [PATTERN]    list schemas\n"));
! 	fprintf(output, _("  \\do[A]   [PATTERN]    list operators\n"));
  	fprintf(output, _("  \\dp      [PATTERN]    list table, view, and sequence access privileges\n"));
  	fprintf(output, _("   \\z      [PATTERN]    same as \\dp\n"));
! 	fprintf(output, _("  \\ds[A+]  [PATTERN]    list sequences\n"));
! 	fprintf(output, _("  \\dt[A+]  [PATTERN]    list tables\n"));
! 	fprintf(output, _("  \\dT[A+]  [PATTERN]    list data types\n"));
  	fprintf(output, _("  \\du      [PATTERN]    list roles (users)\n"));
! 	fprintf(output, _("  \\dv[A+]  [PATTERN]    list views\n"));
  	fprintf(output, "\n");
  
  	fprintf(output, _("Formatting\n"));
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to