diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-08-22 12:46:18 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-08-22 12:46:18 +0000 |
commit | 54f55276060529343dff7c942604c7644a3f0f21 (patch) | |
tree | 376e43ca28d60359f056b232ddb0b81986704426 /src/interfaces/ecpg/ecpglib/execute.c | |
parent | a3132359fd633d63014e5a8cc0f5c119d6449f71 (diff) | |
download | postgresql-54f55276060529343dff7c942604c7644a3f0f21.tar.gz postgresql-54f55276060529343dff7c942604c7644a3f0f21.zip |
Descriptor values were quoted twice.
Fixed some regression test problems.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 0eb12e1b152..bba3b6ee499 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.59 2006/08/18 16:30:53 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.60 2006/08/22 12:46:17 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -39,9 +39,8 @@ static char * quote_postgres(char *arg, int lineno) { char *res = (char *) ECPGalloc(2 * strlen(arg) + 3, lineno); - int i, + int i, quoted = false, ri = 0; - if (!res) return (res); @@ -51,16 +50,29 @@ quote_postgres(char *arg, int lineno) */ if (strchr(arg, '\\') != NULL) res[ri++] = ESCAPE_STRING_SYNTAX; + + i = 0; res[ri++] = '\''; + /* do not quote the string if it is already quoted */ + if (*arg == '\'' && arg[strlen(arg)-1] == '\'') + { + quoted = true; + i = 1; + } - for (i = 0; arg[i]; i++, ri++) + for (; arg[i]; i++, ri++) { if (SQL_STR_DOUBLE(arg[i], true)) res[ri++] = arg[i]; res[ri] = arg[i]; } - res[ri++] = '\''; + /* do not quote the string if it is already quoted */ + if (quoted) + ri--; + else + res[ri++] = '\''; + res[ri] = '\0'; ECPGfree(arg); |