aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1996-07-27 02:29:51 +0000
committerMarc G. Fournier <scrappy@hub.org>1996-07-27 02:29:51 +0000
commit22113f81fdb552e389d971c2d45c90271d5544ff (patch)
treed8c24179850586c8804ef50142fd4d6d56e59f42 /src
parentc13ef1afed3c5c4d63909b817cc2975b0937c5b1 (diff)
downloadpostgresql-22113f81fdb552e389d971c2d45c90271d5544ff.tar.gz
postgresql-22113f81fdb552e389d971c2d45c90271d5544ff.zip
This is a patch to pg_dump which fixes varchar and char printing in the
case where the attribute length is variable (stored as -1). Previously, you'd get output that looked like: CREATE TABLE foo (bar varchar(-1)); Monitor and psql don't like this at all :). Here is a fix: Submitted by: Adam Sussman <myddryn@vidya.com>
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 2ee8155e5d3..639d0b5ec81 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -20,7 +20,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.3 1996/07/22 08:36:59 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.4 1996/07/27 02:29:51 scrappy Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
@@ -35,6 +35,10 @@
* - Added single. quote to twin single quote expansion for 'insert' string
* mode.
*
+ * Modifications - 7/26/96 - asussman@vidya.com
+ *
+ * - Fixed ouput lengths for char and varchar type where the length is variable (-1)
+ *
*-------------------------------------------------------------------------
*/
@@ -1210,20 +1214,30 @@ void dumpTables(FILE* fout, TableInfo *tblinfo, int numTables,
/* Show lengths on bpchar and varchar */
if (!strcmp(tblinfo[i].typnames[j],"bpchar")) {
- sprintf(q, "%s%s%s char(%d)",
+ sprintf(q, "%s%s%s char",
q,
(actual_atts > 0) ? ", " : "",
- tblinfo[i].attnames[j],
- tblinfo[i].attlen[j]);
+ tblinfo[i].attnames[j]);
+
+ /* stored length can be -1 (variable) */
+ if (tblinfo[i].attlen[j] > 0)
+ sprintf(q, "%s(%d)",
+ q,
+ tblinfo[i].attlen[j]);
actual_atts++;
}
else if (!strcmp(tblinfo[i].typnames[j],"varchar")) {
- sprintf(q, "%s%s%s %s(%d)",
+ sprintf(q, "%s%s%s %s",
q,
(actual_atts > 0) ? ", " : "",
tblinfo[i].attnames[j],
- tblinfo[i].typnames[j],
- tblinfo[i].attlen[j]);
+ tblinfo[i].typnames[j]);
+
+ /* stored length can be -1 (variable) */
+ if (tblinfo[i].attlen[j] > 0)
+ sprintf(q, "%s(%d)",
+ q,
+ tblinfo[i].attlen[j]);
actual_atts++;
}
else {