Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 476ef10

Browse files
committed
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
1 parent e7a110b commit 476ef10

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bin/psql/psql.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.18 1996/08/14 04:56:48 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.19 1996/08/14 05:44:25 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -133,7 +133,7 @@ slashUsage(PsqlSettings *ps)
133133
fprintf(stderr,"\t \\C [<captn>] -- set html3 caption (currently '%s')\n", ps->opt.caption? ps->opt.caption: "");
134134
fprintf(stderr,"\t \\c <dbname> -- connect to new database (currently '%s')\n", PQdb(ps->db));
135135
fprintf(stderr,"\t \\d [<table>] -- list tables in database or columns in <table>,* for all\n");
136-
fprintf(stderr,"\t \\e [<fname>] -- edit the current query buffer or <fname>, \\E execute too\n");
136+
fprintf(stderr,"\t \\e [<fname>] -- edit the current query buffer or <fname>,\\E execute too\n");
137137
fprintf(stderr,"\t \\f [<sep>] -- change field separater (currently '%s')\n", ps->opt.fieldSep);
138138
fprintf(stderr,"\t \\g [<fname>] -- send query to backend [and place results in <fname>]\n");
139139
fprintf(stderr,"\t \\g |<cmd> -- send query to backend and pipe results into <cmd>\n");
@@ -1291,7 +1291,9 @@ handleCopyOut(PGresult *res, bool quiet)
12911291
while (!copydone) {
12921292
ret = PQgetline(res->conn, copybuf, COPYBUFSIZ);
12931293

1294-
if (copybuf[0] == '.' && copybuf[1] =='\0') {
1294+
if (copybuf[0] == '\\' &&
1295+
copybuf[1] == '.' &&
1296+
copybuf[2] =='\0') {
12951297
copydone = true; /* don't print this... */
12961298
} else {
12971299
fputs(copybuf, stdout);
@@ -1325,7 +1327,7 @@ handleCopyIn(PGresult *res, bool quiet)
13251327

13261328
if (!quiet) {
13271329
fputs("Enter info followed by a newline\n", stdout);
1328-
fputs("End with a dot on a line by itself.\n", stdout);
1330+
fputs("End with a backslash and a period on a line by itself.\n", stdout);
13291331
}
13301332

13311333
/*
@@ -1354,14 +1356,14 @@ handleCopyIn(PGresult *res, bool quiet)
13541356
}
13551357
if (c == EOF) {
13561358
/* reading from stdin, but from a file */
1357-
PQputline(res->conn, ".");
1359+
PQputline(res->conn, "\\.");
13581360
copydone = true;
13591361
break;
13601362
}
13611363
*s = '\0';
13621364
PQputline(res->conn, copybuf);
13631365
if (firstload) {
1364-
if (!strcmp(copybuf, ".")) {
1366+
if (!strcmp(copybuf, "\\.")) {
13651367
copydone = true;
13661368
}
13671369
firstload = false;

0 commit comments

Comments
 (0)