aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1996-08-14 05:44:25 +0000
committerMarc G. Fournier <scrappy@hub.org>1996-08-14 05:44:25 +0000
commit476ef109133b1e062c2805d4932ef331dda84a68 (patch)
treef51d6ceb7c78793da32e21f71f1cb7cb644a47b6
parente7a110b418f557d768d7d6bfe595268f092201bc (diff)
downloadpostgresql-476ef109133b1e062c2805d4932ef331dda84a68.tar.gz
postgresql-476ef109133b1e062c2805d4932ef331dda84a68.zip
This patch can be installed as part of 1.02.1 so people can properly
pg_dump and load to 2.0. I haven't gotten any feedback on whether people want it, so I am submitting it for others to decide. I would recommend an install in 1.02.1. I had said that the 2.0 pg_dump could dump a 1.02.1 database, but I was wrong. The copy is actually performed by the backend, and the 2.0 database will not be able to read 1.02.1 databases because of the new system columns. This patch does several things. It copies nulls out as \N, so they can be distinguished from '' strings. It fixes a problem where backslashes in the input stream were not output as double-backslashes. Without this patch, backslashes copied out were deleted upon input, or interpreted as special characters. Third, input is now terminated by backslash-period. This can not be part of a normal input stream. I tested this by creating a database with all sorts of nulls, backslash, and period fields and dumped the database and reloaded into a new database and compared them. Submitted by: Bruce
-rw-r--r--src/bin/psql/psql.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index e5b37a16b20..5ac20796c53 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.18 1996/08/14 04:56:48 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.19 1996/08/14 05:44:25 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -133,7 +133,7 @@ slashUsage(PsqlSettings *ps)
fprintf(stderr,"\t \\C [<captn>] -- set html3 caption (currently '%s')\n", ps->opt.caption? ps->opt.caption: "");
fprintf(stderr,"\t \\c <dbname> -- connect to new database (currently '%s')\n", PQdb(ps->db));
fprintf(stderr,"\t \\d [<table>] -- list tables in database or columns in <table>,* for all\n");
- fprintf(stderr,"\t \\e [<fname>] -- edit the current query buffer or <fname>, \\E execute too\n");
+ fprintf(stderr,"\t \\e [<fname>] -- edit the current query buffer or <fname>,\\E execute too\n");
fprintf(stderr,"\t \\f [<sep>] -- change field separater (currently '%s')\n", ps->opt.fieldSep);
fprintf(stderr,"\t \\g [<fname>] -- send query to backend [and place results in <fname>]\n");
fprintf(stderr,"\t \\g |<cmd> -- send query to backend and pipe results into <cmd>\n");
@@ -1291,7 +1291,9 @@ handleCopyOut(PGresult *res, bool quiet)
while (!copydone) {
ret = PQgetline(res->conn, copybuf, COPYBUFSIZ);
- if (copybuf[0] == '.' && copybuf[1] =='\0') {
+ if (copybuf[0] == '\\' &&
+ copybuf[1] == '.' &&
+ copybuf[2] =='\0') {
copydone = true; /* don't print this... */
} else {
fputs(copybuf, stdout);
@@ -1325,7 +1327,7 @@ handleCopyIn(PGresult *res, bool quiet)
if (!quiet) {
fputs("Enter info followed by a newline\n", stdout);
- fputs("End with a dot on a line by itself.\n", stdout);
+ fputs("End with a backslash and a period on a line by itself.\n", stdout);
}
/*
@@ -1354,14 +1356,14 @@ handleCopyIn(PGresult *res, bool quiet)
}
if (c == EOF) {
/* reading from stdin, but from a file */
- PQputline(res->conn, ".");
+ PQputline(res->conn, "\\.");
copydone = true;
break;
}
*s = '\0';
PQputline(res->conn, copybuf);
if (firstload) {
- if (!strcmp(copybuf, ".")) {
+ if (!strcmp(copybuf, "\\.")) {
copydone = true;
}
firstload = false;