[sr-dev] git:master:cf1d885a: db_mysql: set back tick as quoting char for table and column names
Daniel-Constantin Mierla
miconda at gmail.com
Wed May 13 23:58:28 CEST 2015
Module: kamailio
Branch: master
Commit: cf1d885ae8b7c75e41373a0a649a6eb1c161efc7
URL: https://github.com/kamailio/kamailio/commit/cf1d885ae8b7c75e41373a0a649a6eb1c161efc7
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-05-13T23:57:50+02:00
db_mysql: set back tick as quoting char for table and column names
---
Modified: modules/db_mysql/km_dbase.c
---
Diff: https://github.com/kamailio/kamailio/commit/cf1d885ae8b7c75e41373a0a649a6eb1c161efc7.diff
Patch: https://github.com/kamailio/kamailio/commit/cf1d885ae8b7c75e41373a0a649a6eb1c161efc7.patch
---
diff --git a/modules/db_mysql/km_dbase.c b/modules/db_mysql/km_dbase.c
index b44ab55..fd576ff 100644
--- a/modules/db_mysql/km_dbase.c
+++ b/modules/db_mysql/km_dbase.c
@@ -183,7 +183,7 @@ int db_mysql_submit_query_async(const db1_con_t* _h, const str* _s)
return 0;
}
-
+static char *db_mysql_tquote = "`";
/**
* Initialize the database module.
* No function should be called before this
@@ -192,7 +192,10 @@ int db_mysql_submit_query_async(const db1_con_t* _h, const str* _s)
*/
db1_con_t* db_mysql_init(const str* _url)
{
- return db_do_init(_url, (void *)db_mysql_new_connection);
+ db1_con_t *c;
+ c = db_do_init(_url, (void *)db_mysql_new_connection);
+ if(c) CON_TQUOTE(c) = db_mysql_tquote;
+ return c;
}
@@ -781,11 +784,12 @@ int db_mysql_abort_transaction(db1_con_t* _h)
return -1;
}
- ret = snprintf(mysql_sql_buf, sql_buffer_size, "insert into %.*s (", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
+ ret = snprintf(mysql_sql_buf, sql_buffer_size, "insert into %s%.*s%s (",
+ CON_TQUOTESZ(_h), CON_TABLE(_h)->len, CON_TABLE(_h)->s, CON_TQUOTESZ(_h));
if (ret < 0 || ret >= sql_buffer_size) goto error;
off = ret;
- ret = db_print_columns(mysql_sql_buf + off, sql_buffer_size - off, _k, _n);
+ ret = db_print_columns(mysql_sql_buf + off, sql_buffer_size - off, _k, _n, CON_TQUOTESZ(_h));
if (ret < 0) return -1;
off += ret;
More information about the sr-dev
mailing list