Re: [HACKERS] Fixes for psql describeOneTableDetails

2008-11-03 Thread Tom Lane
Kris Jurka [EMAIL PROTECTED] writes:
 Attached are two and a half fixes for problems in psql's 
 describeOneTableDetails function.

Applied, thanks.

 3) When describing a sequence it queries the sequence by name and was not 
 schema qualifying it which is necessary when describing objects not in the 
 search path.  This is still busted because it does not correctly quote the 
 identifiers.

I fixed the quoting problem by using fmtId(), which seems to have been
sucked into psql awhile back.

regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] Fixes for psql describeOneTableDetails

2008-10-08 Thread Kris Jurka


Attached are two and a half fixes for problems in psql's 
describeOneTableDetails function.


1) After PQclear(res) we must null res out, so that later error handling 
cleanup doesn't try to PQclear it again.


2) In error cleanup we cannot call printTableCleanup unless we've called 
printTableInit.


3) When describing a sequence it queries the sequence by name and was not 
schema qualifying it which is necessary when describing objects not in the 
search path.  This is still busted because it does not correctly quote the 
identifiers.


Kris JurkaIndex: src/bin/psql/describe.c
===
RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.185
diff -c -r1.185 describe.c
*** src/bin/psql/describe.c 23 Sep 2008 09:20:38 -  1.185
--- src/bin/psql/describe.c 8 Oct 2008 23:28:48 -
***
*** 826,831 
--- 826,832 
PGresult   *res = NULL;
printTableOpt myopt = pset.popt.topt;
printTableContent cont;
+   bool printTableInitialized = false;
int i;
char   *view_def = NULL;
char   *headers[6];
***
*** 887,892 
--- 888,894 
tableinfo.tablespace = (pset.sversion = 8) ?

atooid(PQgetvalue(res, 0, 6)) : 0;
PQclear(res);
+   res = NULL;

/*
 * This is used to get the values of a sequence and store it in an
***
*** 902,909 
   start_value, increment_by, \n
   max_value, min_value, 
cache_value, \n
   log_cnt, is_cycled, is_called 
\n
!   FROM \%s\,
!   relationname);

result = PSQLexec(buf.data, false);
if (!result)
--- 904,911 
   start_value, increment_by, \n
   max_value, min_value, 
cache_value, \n
   log_cnt, is_cycled, is_called 
\n
!   FROM \%s\.\%s\,
!   schemaname, relationname);

result = PSQLexec(buf.data, false);
if (!result)
***
*** 1000,1005 
--- 1002,1008 
}

printTableInit(cont, myopt, title.data, cols, numrows);
+   printTableInitialized = true;
  
for (i = 0; i  cols; i++)
printTableAddHeader(cont, headers[i], true, 'l');
***
*** 1593,1599 
  error_return:
  
/* clean up */
!   printTableCleanup(cont);
termPQExpBuffer(buf);
termPQExpBuffer(title);
termPQExpBuffer(tmpbuf);
--- 1596,1603 
  error_return:
  
/* clean up */
!   if (printTableInitialized)
!   printTableCleanup(cont);
termPQExpBuffer(buf);
termPQExpBuffer(title);
termPQExpBuffer(tmpbuf);

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers