diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-05-28 21:13:54 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-05-28 21:13:54 +0000 |
commit | 134b463f027d1113df6f983c3348f165b1ac1ffa (patch) | |
tree | 7e247256f1fcb5e0e1a4759b854f673366c4478d /src/bin/psql/large_obj.c | |
parent | 117d73a9e7af61f6742e3d2b46f1dfbe3e02b9ca (diff) | |
download | postgresql-134b463f027d1113df6f983c3348f165b1ac1ffa.tar.gz postgresql-134b463f027d1113df6f983c3348f165b1ac1ffa.zip |
Fix up pg_dump to do string escaping fully correctly for client encoding
and standard_conforming_strings; likewise for the other client programs
that need it. As per previous discussion, a pg_dump dump now conforms
to the standard_conforming_strings setting of the source database.
We don't use E'' syntax in the dump, thereby improving portability of
the SQL. I added a SET escape_strings_warning = off command to keep
the dumps from getting a lot of back-chatter from that.
Diffstat (limited to 'src/bin/psql/large_obj.c')
-rw-r--r-- | src/bin/psql/large_obj.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index f4b107538ac..5de0348b397 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.42 2006/05/26 23:48:54 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.43 2006/05/28 21:13:54 tgl Exp $ */ #include "postgres_fe.h" #include "large_obj.h" @@ -148,7 +148,6 @@ do_lo_import(const char *filename_arg, const char *comment_arg) PGresult *res; Oid loid; char oidbuf[32]; - unsigned int i; bool own_transaction; if (!start_lo_xact("\\lo_import", &own_transaction)) @@ -171,21 +170,9 @@ do_lo_import(const char *filename_arg, const char *comment_arg) cmdbuf = malloc(slen * 2 + 256); if (!cmdbuf) return fail_lo_xact("\\lo_import", own_transaction); - sprintf(cmdbuf, - "COMMENT ON LARGE OBJECT %u IS ", - loid); + sprintf(cmdbuf, "COMMENT ON LARGE OBJECT %u IS '", loid); bufptr = cmdbuf + strlen(cmdbuf); - - if (strchr(comment_arg, '\\') != NULL) - *bufptr++ = ESCAPE_STRING_SYNTAX; - - *bufptr++ = '\''; - for (i = 0; i < slen; i++) - { - if (SQL_STR_DOUBLE(comment_arg[i], true)) - *bufptr++ = comment_arg[i]; - *bufptr++ = comment_arg[i]; - } + bufptr += PQescapeStringConn(pset.db, bufptr, comment_arg, slen, NULL); strcpy(bufptr, "'"); if (!(res = PSQLexec(cmdbuf, false))) |