[libgda] Correction for bug #663608



commit ad1976252faaae4386c9429d065c48cd456a1e57
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Nov 8 21:41:54 2011 +0100

    Correction for bug #663608

 libgda/sql-parser/gda-statement-struct-util.c |   17 +++++++++++++----
 providers/postgres/gda-postgres-provider.c    |   15 ++++++++++++---
 2 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/libgda/sql-parser/gda-statement-struct-util.c b/libgda/sql-parser/gda-statement-struct-util.c
index 604bf2d..d18dead 100644
--- a/libgda/sql-parser/gda-statement-struct-util.c
+++ b/libgda/sql-parser/gda-statement-struct-util.c
@@ -85,7 +85,6 @@ _remove_quotes (gchar *str)
 	if ((delim != '\'') && (delim != '"'))
 		return str;
 
-
         total = strlen (str);
         if (str[total-1] == delim) {
 		/* string is correctly terminated by a double quote */
@@ -112,7 +111,17 @@ _remove_quotes (gchar *str)
                                 return str;
                         }
                 }
-                if (*ptr == '\\') {
+                else if (*ptr == '"') {
+                        if (*(ptr+1) == '"') {
+                                g_memmove (ptr+1, ptr+2, total - offset);
+                                offset += 2;
+                        }
+                        else {
+				*str = 0;
+				return str;
+                        }
+                }
+		else if (*ptr == '\\') {
                         if (*(ptr+1) == '\\') {
                                 g_memmove (ptr+1, ptr+2, total - offset);
                                 offset += 2;
@@ -143,7 +152,7 @@ _remove_quotes (gchar *str)
  * @str: an SQL identifier
  *
  * Add double quotes around the @str identifier. This function is normally used only by database provider's
- * implementation.
+ * implementation. Any double quote character is replaced by two double quote characters.
  *
  * For other uses, see gda_sql_identifier_quote().
  *
@@ -164,7 +173,7 @@ gda_sql_identifier_force_quotes (const gchar *str)
 	*retval = '"';
 	for (rptr = retval+1, sptr = str; *sptr; sptr++, rptr++) {
 		if (*sptr == '"') {
-			*rptr = '\\';
+			*rptr = '"';
 			rptr++;
 			*rptr = *sptr;
 		}
diff --git a/providers/postgres/gda-postgres-provider.c b/providers/postgres/gda-postgres-provider.c
index 8ff50a3..5c8585f 100644
--- a/providers/postgres/gda-postgres-provider.c
+++ b/providers/postgres/gda-postgres-provider.c
@@ -2417,7 +2417,7 @@ identifier_add_quotes (const gchar *str)
         *retval = '"';
         for (rptr = retval+1, sptr = str; *sptr; sptr++, rptr++) {
                 if (*sptr == '"') {
-                        *rptr = '\\';
+                        *rptr = '"';
                         rptr++;
                         *rptr = *sptr;
                 }
@@ -2468,7 +2468,6 @@ pg_remove_quotes (gchar *str)
 	if ((delim != '\'') && (delim != '"'))
 		return str;
 
-
         total = strlen (str);
         if (str[total-1] == delim) {
 		/* string is correctly terminated */
@@ -2495,7 +2494,17 @@ pg_remove_quotes (gchar *str)
                                 return str;
                         }
                 }
-                if (*ptr == '\\') {
+                else if (*ptr == '"') {
+                        if (*(ptr+1) == '"') {
+                                g_memmove (ptr+1, ptr+2, total - offset);
+                                offset += 2;
+                        }
+                        else {
+				*str = 0;
+				return str;
+                        }
+                }
+		else if (*ptr == '\\') {
                         if (*(ptr+1) == '\\') {
                                 g_memmove (ptr+1, ptr+2, total - offset);
                                 offset += 2;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]