aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2008-05-13 00:14:11 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2008-05-13 00:14:11 +0000
commite6a64bd3b6ec4646e4d3bc06692af76bca4967ab (patch)
treecd41665e5de04b431c4cf069bdf7ed0262922296 /src
parent1e9199e84c26eca7bdd49b47c1c627d4f3a60747 (diff)
downloadpostgresql-e6a64bd3b6ec4646e4d3bc06692af76bca4967ab.tar.gz
postgresql-e6a64bd3b6ec4646e4d3bc06692af76bca4967ab.zip
Fix a bug in the previous patch, which caused the title pointer to be used
before it was actually set.
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/describe.c80
-rw-r--r--src/bin/psql/print.c6
2 files changed, 44 insertions, 42 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index cd807230272..a4fe9d997ea 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.171 2008/05/12 22:59:58 alvherre Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.172 2008/05/13 00:14:11 alvherre Exp $
*/
#include "postgres_fe.h"
@@ -865,6 +865,45 @@ describeOneTableDetails(const char *schemaname,
goto error_return;
numrows = PQntuples(res);
+ /* Make title */
+ switch (tableinfo.relkind)
+ {
+ case 'r':
+ printfPQExpBuffer(&title, _("Table \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ case 'v':
+ printfPQExpBuffer(&title, _("View \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ case 'S':
+ printfPQExpBuffer(&title, _("Sequence \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ case 'i':
+ printfPQExpBuffer(&title, _("Index \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ case 's':
+ /* not used as of 8.2, but keep it for backwards compatibility */
+ printfPQExpBuffer(&title, _("Special relation \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ case 't':
+ printfPQExpBuffer(&title, _("TOAST table \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ case 'c':
+ printfPQExpBuffer(&title, _("Composite type \"%s.%s\""),
+ schemaname, relationname);
+ break;
+ default:
+ /* untranslated unknown relkind */
+ printfPQExpBuffer(&title, "?%c? \"%s.%s\"",
+ tableinfo.relkind, schemaname, relationname);
+ break;
+ }
+
/* Set the number of columns, and their names */
cols = 2;
headers[0] = "Column";
@@ -937,45 +976,6 @@ describeOneTableDetails(const char *schemaname,
printTableAddCell(&cont, PQgetvalue(res, i, 5), false);
}
- /* Make title */
- switch (tableinfo.relkind)
- {
- case 'r':
- printfPQExpBuffer(&title, _("Table \"%s.%s\""),
- schemaname, relationname);
- break;
- case 'v':
- printfPQExpBuffer(&title, _("View \"%s.%s\""),
- schemaname, relationname);
- break;
- case 'S':
- printfPQExpBuffer(&title, _("Sequence \"%s.%s\""),
- schemaname, relationname);
- break;
- case 'i':
- printfPQExpBuffer(&title, _("Index \"%s.%s\""),
- schemaname, relationname);
- break;
- case 's':
- /* not used as of 8.2, but keep it for backwards compatibility */
- printfPQExpBuffer(&title, _("Special relation \"%s.%s\""),
- schemaname, relationname);
- break;
- case 't':
- printfPQExpBuffer(&title, _("TOAST table \"%s.%s\""),
- schemaname, relationname);
- break;
- case 'c':
- printfPQExpBuffer(&title, _("Composite type \"%s.%s\""),
- schemaname, relationname);
- break;
- default:
- /* untranslated unknown relkind */
- printfPQExpBuffer(&title, "?%c? \"%s.%s\"",
- tableinfo.relkind, schemaname, relationname);
- break;
- }
-
/* Make footers */
if (tableinfo.relkind == 'i')
{
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 2dcf964a8a9..f27c1e1f488 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.100 2008/05/12 22:59:58 alvherre Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.101 2008/05/13 00:14:11 alvherre Exp $
*/
#include "postgres_fe.h"
@@ -1918,8 +1918,10 @@ ClosePager(FILE *pagerpipe)
/*
* Initialise a table contents struct.
+ * Must be called before any other printTable method is used.
*
- * Must be called before any other printTable method is used.
+ * The title is not duplicated; the caller must ensure that the buffer
+ * is available for the lifetime of the printTableContent struct.
*
* If you call this, you must call printTableCleanup once you're done with the
* table.