\d+ should display the storage options for columns - Mailing list pgsql-patches

From Gregory Stark
Subject \d+ should display the storage options for columns
Date
Msg-id 87d4nfo0wr.fsf@oxford.xeocode.com
Whole thread Raw
Responses Re: \d+ should display the storage options for columns
List pgsql-patches
Oleg pointed out to me here that while we have a command to *set* the toast
storage characteristics there's no actual supported way to display the current
settings.

It seems like this would be a reasonable thing to add to \d+


Index: src/bin/psql/describe.c
===================================================================
RCS file: /home/stark/src/REPOSITORY/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.170
diff -c -r1.170 describe.c
*** src/bin/psql/describe.c    5 May 2008 01:21:03 -0000    1.170
--- src/bin/psql/describe.c    21 May 2008 18:07:13 -0000
***************
*** 865,871 ****

      if (verbose)
      {
!         cols++;
          headers[cols - 1] = _("Description");
      }

--- 865,872 ----

      if (verbose)
      {
!         cols+=2;
!         headers[cols - 2] = _("Storage");
          headers[cols - 1] = _("Description");
      }

***************
*** 877,883 ****
                        "\n  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)"
                        "\n   FROM pg_catalog.pg_attrdef d"
                        "\n   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
!                       "\n  a.attnotnull, a.attnum");
      if (verbose)
          appendPQExpBuffer(&buf, ", pg_catalog.col_description(a.attrelid, a.attnum)");
      appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
--- 878,884 ----
                        "\n  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128)"
                        "\n   FROM pg_catalog.pg_attrdef d"
                        "\n   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
!                       "\n  a.attnotnull, a.attnum, a.attstorage");
      if (verbose)
          appendPQExpBuffer(&buf, ", pg_catalog.col_description(a.attrelid, a.attnum)");
      appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
***************
*** 957,967 ****
--- 958,979 ----

          /* Description */
          if (verbose)
+         {
+             char *storage = PQgetvalue(res, i, 6);
+
+             cells[i * cols + cols -2] =
+                 (storage[0]=='p' ? "PLAIN" :
+                  (storage[0]=='m' ? "MAIN" :
+                   (storage[0]=='x' ? "EXTENDED" :
+                    (storage[0]=='e' ? "EXTERNAL" :
+                     "???"))));
+
  #ifdef WIN32
              cells[i * cols + cols - 1] = mbvalidate(PQgetvalue(res, i, 5), myopt.encoding);
  #else
              cells[i * cols + cols - 1] = PQgetvalue(res, i, 5);
  #endif
+         }
      }

      /* Make title */


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's On-Demand Production Tuning

pgsql-patches by date:

Previous
From: Gregory Stark
Date:
Subject: Re: [HACKERS] WITH RECURSIVE patch V0.1
Next
From: Gregory Stark
Date:
Subject: Re: \d+ should display the storage options for columns