From 476ef109133b1e062c2805d4932ef331dda84a68 Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Wed, 14 Aug 1996 05:44:25 +0000 Subject: [PATCH] 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 --- src/bin/psql/psql.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index e5b37a16b2..5ac20796c5 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 [] -- set html3 caption (currently '%s')\n", ps->opt.caption? ps->opt.caption: ""); fprintf(stderr,"\t \\c -- connect to new database (currently '%s')\n", PQdb(ps->db)); fprintf(stderr,"\t \\d [] -- list tables in database or columns in
,* for all\n"); - fprintf(stderr,"\t \\e [] -- edit the current query buffer or , \\E execute too\n"); + fprintf(stderr,"\t \\e [] -- edit the current query buffer or ,\\E execute too\n"); fprintf(stderr,"\t \\f [] -- change field separater (currently '%s')\n", ps->opt.fieldSep); fprintf(stderr,"\t \\g [] -- send query to backend [and place results in ]\n"); fprintf(stderr,"\t \\g | -- send query to backend and pipe results into \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;