mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Add E'' to internally created SQL strings that contain backslashes.
Improve code clarity by using macros for E'' processing.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.40 2005/06/02 12:35:11 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.41 2005/07/02 17:01:53 momjian Exp $ */
|
||||
|
||||
/*
|
||||
* The aim is to get a simpler inteface to the database routines.
|
||||
@ -45,21 +45,14 @@ quote_postgres(char *arg, int lineno)
|
||||
if (!res)
|
||||
return (res);
|
||||
|
||||
if (strchr(arg, '\\') != NULL)
|
||||
res[ri++] = ESCAPE_STRING_SYNTAX;
|
||||
res[ri++] = '\'';
|
||||
|
||||
for (i = 0; arg[i]; i++, ri++)
|
||||
{
|
||||
switch (arg[i])
|
||||
{
|
||||
case '\'':
|
||||
res[ri++] = '\'';
|
||||
break;
|
||||
case '\\':
|
||||
res[ri++] = '\\';
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
if (SQL_STR_DOUBLE(arg[i]))
|
||||
res[ri++] = arg[i];
|
||||
res[ri] = arg[i];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user