Skip site navigation (1) Skip section navigation (2)

\d+ should display the storage options for columns

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Cc: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
Subject: \d+ should display the storage options for columns
Date: 2008-05-21 20:30:28
Message-ID: 87d4nfo0wr.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: 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

Responses

pgsql-patches by date

Next:From: Gregory StarkDate: 2008-05-21 20:54:48
Subject: Re: \d+ should display the storage options for columns
Previous:From: Gregory StarkDate: 2008-05-21 17:04:34
Subject: Re: [HACKERS] WITH RECURSIVE patch V0.1

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group