Make psql's \d+ command indicate whether the table in question
authorNeil Conway
Thu, 22 Apr 2004 17:38:16 +0000 (17:38 +0000)
committerNeil Conway
Thu, 22 Apr 2004 17:38:16 +0000 (17:38 +0000)
contains OIDs. Also, minor documentation improvements to the
psql reference page.

doc/src/sgml/perform.sgml
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/describe.c

index e9a34ecad2b6175048012bb50182b5b9fd039fd9..d49c57793b704c2f21d445618213fc0662b0d618 100644 (file)
@@ -1,5 +1,5 @@
 
 
  
@@ -633,8 +633,9 @@ SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
   
    Disable Autocommit
 
-    zone="disable-autocommit">
+   
     autocommit
+    bulk-loading data
    
 
    
index 6ae2ba854e58029152f4c3d9bf9a8ee2cc20da44..dee5a60e68c0c146761552b26eac1f2f29ef8722 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -638,7 +638,7 @@ testdb=>
       
 
       
-       \cd directoryal>
+       \cd [ directory ]al>
        
         
     Changes the current working directory to
@@ -655,7 +655,7 @@ testdb=>
       
 
       
-        \C [ title ]
+        \C [ title ]
         
         
         Sets the title of any tables being printed as the result of a
@@ -670,7 +670,7 @@ testdb=>
       
 
       
-        \connect (or \cdbname [ username ] ]
+        \connect (or \cdbname [ username ] ]
         
         
    Establishes a connection to a new database and/or under a user
@@ -708,14 +708,14 @@ testdb=>
    [ ( column_list ) ]
         { from | to }
    { filename | stdin | stdout | pstdin | pstdout }
-        [ with ] 
-            [ oids ] 
-            [ delimiter [as]  'character' ]
-            [ null [as]  'string' ]
-            [ csv [ quote [as]  'character' ]
-                           [ escape [as]  'character' ]
-                           [ force quote column_list ]
-                           [ force not null column_list ] ]
+        [ with ] 
+            [ oids ] 
+            [ delimiter [ as ] 'character' ]
+            [ null [ as ] 'string' ]
+            [ csv [ quote [ as ] 'character' ]
+            [ escape [ as ] 'character' ]
+            [ force quote column_list ]
+            [ force not null column_list ] ]
         
 
         
@@ -777,7 +777,8 @@ testdb=>
       
 
       
-        \d [ pattern ]
+        \d [ pattern ]
+        \d+ [ pattern ]
 
         
         
@@ -791,8 +792,10 @@ testdb=>
    
 
    
-   The command form \d+ is identical, but any
-   comments associated with the table columns are shown as well.
+   The command form \d+ is identical, 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.
    
 
    
@@ -808,7 +811,7 @@ testdb=>
       
 
       
-        \da [ pattern ]
+        \da [ pattern ]
 
         
         
@@ -822,7 +825,7 @@ testdb=>
 
 
       
-        \dc [ pattern ]
+        \dc [ pattern ]
         
         
         Lists all available conversions between character-set encodings.
@@ -845,7 +848,7 @@ testdb=>
 
 
       
-        \dd [ pattern ]
+        \dd [ pattern ]
         
         
         Shows the descriptions of objects matching the 
@@ -866,15 +869,16 @@ testdb=>
         
 
         
-        Descriptions for objects can be created with the
-        COMMENT SQL command.
-   
+        Descriptions for objects can be created with the 
+        linkend="sql-comment" endterm="sql-comment-title">
+        SQL command.
+       
         
       
 
 
       
-        \dD [ pattern ]
+        \dD [ pattern ]
         
         
         Lists all available domains. If 
@@ -887,6 +891,7 @@ testdb=>
 
       
         \df [ pattern ]
+        \df+ [ pattern ]
 
         
         
@@ -920,8 +925,9 @@ testdb=>
         \dg [ pattern ]
         
         
-        Lists all database groups or only those that match 
-        class="parameter">pattern.
+        Lists all database groups. If 
+        class="parameter">pattern is specified, only
+        those groups whose names match the pattern are listed.
         
         
       
@@ -932,14 +938,16 @@ testdb=>
 
    
    
-   This is not the actual command name: the letters i, s, t, v, S
-   stand for index, sequence, table, view, and system table,
-   respectively. You can specify any or all of these letters, in any
-   order, to obtain a listing of all the matching objects.  The letter
-   S restricts the listing to system objects; without S, only non-system
-   objects are shown.
-   If + is appended to the command name, each object is
-   listed with its associated description, if any.
+   This is not the actual command name: the letters
+   ist,
+   vS stand for index,
+   sequence, table, view, and system table, respectively. You can
+   specify any or all of these letters, in any order, to obtain a
+   listing of all the matching objects.  The letter S restricts the
+   listing to system objects; without S, only
+   non-system objects are shown.  If + is appended
+   to the command name, each object is listed with its associated
+   description, if any.
    
 
    
@@ -962,7 +970,7 @@ testdb=>
 
 
       
-        \dn [ pattern ]
+        \dn [ pattern ]
 
         
         
@@ -988,7 +996,7 @@ testdb=>
 
 
       
-        \dp [ pattern ]
+        \dp [ pattern ]
    
    
         Produces a list of all available tables, views and sequences with their
@@ -1009,6 +1017,7 @@ testdb=>
 
       
         \dT [ pattern ]
+        \dT+ [ pattern ]
         
         
         Lists all data types or only those that match 
@@ -1031,7 +1040,7 @@ testdb=>
 
 
       
-        \edit (or \efilename ]
+        \edit (or \efilename ]
 
         
         
@@ -1065,7 +1074,7 @@ testdb=>
 
 
       
-        \echo text [ ... ]
+        \echo text [ ... ]
         
    
         Prints the arguments to the standard output, separated by one
@@ -1091,7 +1100,7 @@ Tue Oct 26 21:40:57 CEST 1999
 
 
       
-        \encoding [ encoding ]
+        \encoding [ encoding ]
 
         
         
@@ -1103,7 +1112,7 @@ Tue Oct 26 21:40:57 CEST 1999
 
 
       
-        \f [ string ]
+        \f [ string ]
 
         
         
@@ -1134,7 +1143,7 @@ Tue Oct 26 21:40:57 CEST 1999
       
 
       
-        \help (or \hcommand ]
+        \help (or \hcommand ]
         
         
         Gives syntax help on the specified SQL
@@ -1172,7 +1181,7 @@ Tue Oct 26 21:40:57 CEST 1999
 
 
       
-        \i filename>
+        \i filename>
         
         
         Reads input from the file 
@@ -1192,18 +1201,19 @@ Tue Oct 26 21:40:57 CEST 1999
 
       
         \l (or \list)
+        \l+ (or \list+)
         
         
         List the names, owners, and character set encodings of all the databases in
-        the server.  Append a + to the command name to
-        see any descriptions for the databases as well.
+        the server. If + is appended to the command
+        name, database descriptions are also displayed.
         
         
       
 
 
       
-        \lo_export loid filename>
+        \lo_export loid filename>
 
    
    
@@ -1227,7 +1237,7 @@ Tue Oct 26 21:40:57 CEST 1999
 
 
       
-        \lo_import filename [ comment ]
+        \lo_import filename [ comment ]
 
    
    
@@ -1266,7 +1276,7 @@ lo_import 152801
       
 
       
-        \lo_unlink loid>
+        \lo_unlink loid>
 
    
    
@@ -1326,7 +1336,7 @@ lo_import 152801
 
 
       
-        \pset parameter [ value ]
+        \pset parameter [ value ]
 
    
    
@@ -1459,7 +1469,7 @@ lo_import 152801
      
 
      
-     title [ text ]
+     title [ text ]
      
      
      Sets the table title for any subsequently printed tables. This
@@ -1470,7 +1480,7 @@ lo_import 152801
      
 
      
-     tableattr (or Ttext ]
+     tableattr (or Ttext ]
      
      
      Allows you to specify any attributes to be placed inside the
@@ -1546,7 +1556,7 @@ lo_import 152801
 
 
       
-        \qecho text [ ... ] 
+        \qecho text [ ... ] 
         
         
    This command is identical to \echo except
@@ -1568,7 +1578,7 @@ lo_import 152801
 
 
       
-        \s [ filename ]
+        \s [ filename ]
         
         
         Print or save the command line history to 
@@ -1592,7 +1602,7 @@ lo_import 152801
 
 
       
-        \set [ name [ value [ ... ]]]
+        \set [ name [ value [ ... ] ] ]
 
    
    
@@ -1641,7 +1651,7 @@ lo_import 152801
 
 
       
-        \T table_options>
+        \T table_options>
         
         
         Allows you to specify attributes to be placed within the
@@ -1688,7 +1698,7 @@ lo_import 152801
 
 
       
-        \z [ pattern ]
+        \z [ pattern ]
         
         
         Produces a list of all available tables, views and sequences with their
@@ -1713,7 +1723,7 @@ lo_import 152801
 
 
       
-        \! [ command ]
+        \! [ command ]
         
         
         Escapes to a separate Unix shell or executes the Unix command
@@ -1832,6 +1842,10 @@ bar
 
     
       
+      
+       autocommit
+       psql
+      
         AUTOCOMMIT
    
    
index f37296a2cb6974b42c8bdbcbec8ddfec1e23e7a4..1a0ed8c8819c174df76e736c6cea9cb2c04a2b07 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2003, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.96 2004/04/06 04:05:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.97 2004/04/22 17:38:16 neilc Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -549,6 +549,8 @@ objectDescription(const char *pattern)
  *
  * This routine finds the tables to be displayed, and calls
  * describeOneTableDetails for each one.
+ *
+ * verbose: if true, this is \d+
  */
 bool
 describeTableDetails(const char *pattern, bool verbose)
@@ -635,11 +637,12 @@ describeOneTableDetails(const char *schemaname,
    int         numrows = 0;
    struct
    {
-       bool        hasindex;
-       char        relkind;
        int16       checks;
        int16       triggers;
+       char        relkind;
+       bool        hasindex;
        bool        hasrules;
+       bool        hasoids;
    }           tableinfo;
    bool        show_modifiers = false;
    bool        retval;
@@ -652,7 +655,7 @@ describeOneTableDetails(const char *schemaname,
 
    /* Get general table info */
    printfPQExpBuffer(&buf,
-    "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules\n"
+    "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, relhasoids\n"
                      "FROM pg_catalog.pg_class WHERE oid = '%s'",
                      oid);
    res = PSQLexec(buf.data, false);
@@ -669,11 +672,12 @@ describeOneTableDetails(const char *schemaname,
    }
 
    /* FIXME: check for null pointers here? */
-   tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
-   tableinfo.relkind = *(PQgetvalue(res, 0, 1));
    tableinfo.checks = atoi(PQgetvalue(res, 0, 2));
    tableinfo.triggers = atoi(PQgetvalue(res, 0, 3));
+   tableinfo.relkind = *(PQgetvalue(res, 0, 1));
+   tableinfo.hasindex = strcmp(PQgetvalue(res, 0, 0), "t") == 0;
    tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
+   tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
    PQclear(res);
 
    headers[0] = _("Column");
@@ -1185,6 +1189,14 @@ describeOneTableDetails(const char *schemaname,
            footers[count_footers++] = pg_strdup(buf.data);
        }
 
+       if (verbose)
+       {
+           char *s = _("Contains OIDs");
+           printfPQExpBuffer(&buf, "%s: %s", s,
+                             (tableinfo.hasoids ? _("yes") : _("no")));
+           footers[count_footers++] = pg_strdup(buf.data);
+       }
+
        /* end of list marker */
        footers[count_footers] = NULL;