1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

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.
This commit is contained in:
Bruce Momjian
2006-05-26 23:48:54 +00:00
parent 4d63e26774
commit 7a846ecc00
15 changed files with 174 additions and 89 deletions

View File

@ -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];
}