Gregory Stark wrote:
> "Alvaro Herrera" <[EMAIL PROTECTED]> writes:
> 
> > This seems to be against an older version of psql ... with the
> > printTable API stuff, we reworked this -- in particular the mbvalidate()
> > call that's only on WIN32 is gone (actually it's the lack of it that's
> > gone.)
> 
> Sorry. Here's a patch against a current sync of HEAD.
> 
> Incidentally how can this new API work? Calling _() on a function parameter
> would work but how would the translation tools know what strings need to be
> translated?

Update patch applied;  I also adjusted some translation function calls.
The new output of psql \d+ is:

        test=> \d+ test
                         Table "public.test"
         Column |  Type   | Modifiers | Storage | Description
        --------+---------+-----------+---------+-------------
         x      | integer |           | plain   |
        Has OIDs: no

-- 
  Bruce Momjian  <[EMAIL PROTECTED]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/psql/describe.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.177
diff -c -c -r1.177 describe.c
*** src/bin/psql/describe.c	14 Jul 2008 22:00:04 -0000	1.177
--- src/bin/psql/describe.c	14 Jul 2008 22:50:32 -0000
***************
*** 811,817 ****
  	printTableContent cont;
  	int			i;
  	char	   *view_def = NULL;
! 	char	   *headers[4];
  	char	  **modifiers = NULL;
  	char	  **ptr;
  	PQExpBufferData title;
--- 811,817 ----
  	printTableContent cont;
  	int			i;
  	char	   *view_def = NULL;
! 	char	   *headers[5];
  	char	  **modifiers = NULL;
  	char	  **ptr;
  	PQExpBufferData title;
***************
*** 878,884 ****
  					  "\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");
  	if (tableinfo.relkind == 'i')
  		appendPQExpBuffer(&buf, ", pg_catalog.pg_index i");
--- 878,884 ----
  					  "\n   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
  					  "\n  a.attnotnull, a.attnum");
  	if (verbose)
! 		appendPQExpBuffer(&buf, ", a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)");
  	appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_attribute a");
  	if (tableinfo.relkind == 'i')
  		appendPQExpBuffer(&buf, ", pg_catalog.pg_index i");
***************
*** 933,951 ****
  
  	/* Set the number of columns, and their names */
  	cols = 2;
! 	headers[0] = "Column";
! 	headers[1] = "Type";
  
  	if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v')
  	{
  		show_modifiers = true;
! 		headers[cols++] = "Modifiers";
  		modifiers = pg_malloc_zero((numrows + 1) * sizeof(*modifiers));
  	}
  
  	if (verbose)
! 		headers[cols++] = "Description";
! 
  	printTableInit(&cont, &myopt, title.data, cols, numrows);
  
  	for (i = 0; i < cols; i++)
--- 933,954 ----
  
  	/* Set the number of columns, and their names */
  	cols = 2;
! 	headers[0] = gettext_noop("Column");
! 	headers[1] = gettext_noop("Type");
  
  	if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v')
  	{
  		show_modifiers = true;
! 		headers[cols++] = gettext_noop("Modifiers");
  		modifiers = pg_malloc_zero((numrows + 1) * sizeof(*modifiers));
  	}
  
  	if (verbose)
! 	{
! 		headers[cols++] = gettext_noop("Storage");
! 		headers[cols++] = gettext_noop("Description");
! 	}
! 	
  	printTableInit(&cont, &myopt, title.data, cols, numrows);
  
  	for (i = 0; i < cols; i++)
***************
*** 1000,1008 ****
  			printTableAddCell(&cont, modifiers[i], false);
  		}
  
! 		/* Description */
  		if (verbose)
! 			printTableAddCell(&cont, PQgetvalue(res, i, 5), false);
  	}
  
  	/* Make footers */
--- 1003,1020 ----
  			printTableAddCell(&cont, modifiers[i], false);
  		}
  
! 		/* Storage and Description */
  		if (verbose)
! 		{
! 			char *storage = PQgetvalue(res, i, 5);
! 			printTableAddCell(&cont, (storage[0]=='p' ? "plain" :
! 									  (storage[0]=='m' ? "main" :
! 									   (storage[0]=='x' ? "extended" :
! 										(storage[0]=='e' ? "external" :
! 										 "???")))),
! 							  false);
! 			printTableAddCell(&cont, PQgetvalue(res, i, 6), false);
! 		}
  	}
  
  	/* Make footers */
-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches

Reply via email to