[libgda/LIBGDA_4.2] Correctly handle SQL identifiers containing a double quote
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.2] Correctly handle SQL identifiers containing a double quote
- Date: Wed, 18 Jan 2012 17:45:35 +0000 (UTC)
commit 7ef3c6ac1e4eb9930f8e321a86aa3fe84d11737d
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Jan 8 15:13:37 2012 +0100
Correctly handle SQL identifiers containing a double quote
in _split_identifier_string() and _string_is_identifier()
libgda/sql-parser/gda-statement-struct-util.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/libgda/sql-parser/gda-statement-struct-util.c b/libgda/sql-parser/gda-statement-struct-util.c
index 8b4bb7d..3a5f86c 100644
--- a/libgda/sql-parser/gda-statement-struct-util.c
+++ b/libgda/sql-parser/gda-statement-struct-util.c
@@ -284,9 +284,16 @@ _string_is_identifier (const gchar *str)
ptr = str + 1;
else
ptr = str;
- for (;
- IdChar(*ptr) || (*ptr == '*') || (*ptr == '.') || (*ptr == '-') || (((*ptr == '"') || (*ptr == '`')) && ptr[1] == 0);
- ptr++);
+ for (; IdChar(*ptr) ||
+ (*ptr == '*') ||
+ (*ptr == '.') ||
+ (*ptr == '-') ||
+ ((*ptr == '"') && (ptr[1] == '"')) ||
+ (((*ptr == '"') || (*ptr == '`')) && ptr[1] == 0);
+ ptr++) {
+ if ((*ptr == '"') && (ptr[1] == '"'))
+ ptr++;
+ }
if (*ptr)
return FALSE;
if (((*str == '"') && (ptr[-1] == '"')) ||
@@ -446,8 +453,13 @@ _split_identifier_string (gchar *str, gchar **remain, gchar **last)
}
for (ptr = str + strlen (str) - 1; ptr >= str; ptr--) {
- if (*ptr == '"')
+ if (*ptr == '"') {
+ if ((ptr > str) && (ptr[-1] == '"')) {
+ ptr--;
+ continue;
+ }
inq = !inq;
+ }
else if ((*ptr == '.') && !inq) {
*ptr = 0;
*remain = str;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]