Daily patch: gateway

kannel at kannel.org kannel at kannel.org
Wed Oct 14 06:30:06 CEST 2009


File gateway/ChangeLog changed from revision 1.3107 to 1.3108
File gateway/gw/dlr_mysql.c changed from revision 1.16 to 1.17



Index: gateway/ChangeLog
diff -u gateway/ChangeLog:1.3107 gateway/ChangeLog:1.3108
--- gateway/ChangeLog:1.3107	Sun Sep 20 18:19:17 2009
+++ gateway/ChangeLog	Tue Oct 13 11:49:40 2009
@@ -1,3 +1,9 @@
+2009-10-13 Alexander Malysh <amalysh at kannel.org>
+    * gw/dlr_mysql.c: applied patch that fixes table name and field names that
+      use reserved keywords.
+      See http://dev.mysql.com/doc/refman/5.0/en/identifiers.html for details.
+      Thanks to Vincent CHAVANIS <v.chavanis at telemaque.fr> for this patch.
+
 2009-09-20 Alexander Malysh <amalysh at kannel.org>
     * gw/msg.c: fixed crash when wrong packet received on bearerbox port.
       Thanks to Michael Zervakis <michael at zervakis.com> for report.
Index: gateway/gw/dlr_mysql.c
diff -u gateway/gw/dlr_mysql.c:1.16 gateway/gw/dlr_mysql.c:1.17
--- gateway/gw/dlr_mysql.c:1.16	Fri Sep  4 07:59:31 2009
+++ gateway/gw/dlr_mysql.c	Tue Oct 13 11:49:40 2009
@@ -103,7 +103,7 @@
         return;
     }
 
-    sql = octstr_format("INSERT INTO %S (%S, %S, %S, %S, %S, %S, %S, %S, %S) VALUES "
+    sql = octstr_format("INSERT INTO `%S` (`%S`, `%S`, `%S`, `%S`, `%S`, `%S`, `%S`, `%S`, `%S`) VALUES "
                         "(?, ?, ?, ?, ?, ?, ?, ?, 0)",
                         fields->table, fields->field_smsc, fields->field_ts,
                         fields->field_src, fields->field_dst, fields->field_serv,
@@ -144,7 +144,7 @@
     if (pconn == NULL) /* should not happens, but sure is sure */
         return NULL;
 
-    sql = octstr_format("SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S=? AND %S=? LIMIT 1",
+    sql = octstr_format("SELECT `%S`, `%S`, `%S`, `%S`, `%S`, `%S` FROM `%S` WHERE `%S`=? AND `%S`=? LIMIT 1",
                         fields->field_mask, fields->field_serv,
                         fields->field_url, fields->field_src,
                         fields->field_dst, fields->field_boxc,
@@ -202,7 +202,7 @@
     if (pconn == NULL)
         return;
 
-    sql = octstr_format("DELETE FROM %S WHERE %S=? AND %S=? LIMIT 1",
+    sql = octstr_format("DELETE FROM `%S` WHERE `%S`=? AND `%S`=? LIMIT 1",
                         fields->table, fields->field_smsc,
                         fields->field_ts);
 
@@ -234,7 +234,7 @@
     if (pconn == NULL)
         return;
 
-    sql = octstr_format("UPDATE %S SET %S=? WHERE %S=? AND %S=? LIMIT 1",
+    sql = octstr_format("UPDATE `%S` SET `%S`=? WHERE `%S`=? AND `%S`=? LIMIT 1",
                         fields->table, fields->field_status,
                         fields->field_smsc, fields->field_ts);
 
@@ -267,7 +267,7 @@
     if (conn == NULL)
         return -1;
 
-    sql = octstr_format("SELECT count(*) FROM %S", fields->table);
+    sql = octstr_format("SELECT count(*) FROM `%S`", fields->table);
 #if defined(DLR_TRACE)
     debug("dlr.mysql", 0, "sql: %s", octstr_get_cstr(sql));
 #endif
@@ -301,7 +301,7 @@
     if (pconn == NULL)
         return;
 
-    sql = octstr_format("DELETE FROM %S", fields->table);
+    sql = octstr_format("DELETE FROM `%S`", fields->table);
 #if defined(DLR_TRACE)
     debug("dlr.mysql", 0, "sql: %s", octstr_get_cstr(sql));
 #endif
@@ -349,6 +349,20 @@
     gw_assert(fields != NULL);
 
     /*
+     * Escaping special quotes for field/table names
+     */
+    octstr_replace(fields->table, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_smsc, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_ts, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_src, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_dst, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_serv, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_url, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_mask, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_status, octstr_imm("`"), octstr_imm("``"));
+    octstr_replace(fields->field_boxc, octstr_imm("`"), octstr_imm("``"));
+
+    /*
      * now grap the required information from the 'mysql-connection' group
      * with the mysql-id we just obtained
      *



More information about the devel-reports mailing list