diff options
author | Bruce Momjian <bruce@momjian.us> | 2006-05-26 23:48:54 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2006-05-26 23:48:54 +0000 |
commit | 7a846ecc00b13a81adbf78b66dcf927077a802f8 (patch) | |
tree | 78124ecf7f8ca7922f1412ad8638eac46396f136 /src/interfaces/ecpg/ecpglib/execute.c | |
parent | 4d63e267742a2afe481a34f4742c0551c6b0a112 (diff) | |
download | postgresql-7a846ecc00b13a81adbf78b66dcf927077a802f8.tar.gz postgresql-7a846ecc00b13a81adbf78b66dcf927077a802f8.zip |
Use E'' strings internally only when standard_conforming_strings =
'off'. This allows pg_dump output with standard_conforming_strings =
'on' to generate proper strings that can be loaded into other databases
without the backslash doubling we typically do. I have added the
dumping of the standard_conforming_strings value to pg_dump.
I also added standard backslash handling for plpgsql.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 2cca58aa098..a3a14e2e481 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.45 2006/04/24 09:45:22 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.46 2006/05/26 23:48:54 momjian Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -32,8 +32,9 @@ #include "pgtypes_timestamp.h" #include "pgtypes_interval.h" -/* This function returns a newly malloced string that has the \ - in the argument quoted with \ and the ' quoted with ' as SQL92 says. +/* + * This function returns a newly malloced string that has ' and \ + * escaped. */ static char * quote_postgres(char *arg, int lineno) @@ -45,13 +46,17 @@ quote_postgres(char *arg, int lineno) if (!res) return (res); + /* + * We don't know if the target database is using + * standard_conforming_strings, so we always use E'' strings. + */ if (strchr(arg, '\\') != NULL) res[ri++] = ESCAPE_STRING_SYNTAX; res[ri++] = '\''; for (i = 0; arg[i]; i++, ri++) { - if (SQL_STR_DOUBLE(arg[i])) + if (SQL_STR_DOUBLE(arg[i], true)) res[ri++] = arg[i]; res[ri] = arg[i]; } |