Module: kamailio Branch: master Commit: d66fc7146267417a7a0a0cee22a0148bf94d0b6a URL: https://github.com/kamailio/kamailio/commit/d66fc7146267417a7a0a0cee22a0148b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-10-01T10:45:52+02:00
db_mysql: added parameter unsigend_type
- if set to 1, then the module converts unsigned column value to DB1_UINT or DB1_UBIGINT
---
Modified: src/modules/db_mysql/db_mysql.c Modified: src/modules/db_mysql/km_res.c
---
Diff: https://github.com/kamailio/kamailio/commit/d66fc7146267417a7a0a0cee22a0148b... Patch: https://github.com/kamailio/kamailio/commit/d66fc7146267417a7a0a0cee22a0148b...
---
diff --git a/src/modules/db_mysql/db_mysql.c b/src/modules/db_mysql/db_mysql.c index ebf85e35be..4a79a1878d 100644 --- a/src/modules/db_mysql/db_mysql.c +++ b/src/modules/db_mysql/db_mysql.c @@ -44,6 +44,7 @@ unsigned int my_retries = 1; /* Number of retries when command fails */ unsigned int my_server_timezone = 0; /* Use FROM_UNIXTIME() for date conversion */
unsigned long my_client_ver = 0; +int db_mysql_unsigned_type = 0;
struct mysql_counters_h mysql_cnts_h; counter_def_t mysql_cnt_defs[] = { @@ -98,6 +99,7 @@ static param_export_t params[] = { {"auto_reconnect", INT_PARAM, &db_mysql_auto_reconnect}, {"insert_delayed", INT_PARAM, &db_mysql_insert_all_delayed}, {"update_affected_found", INT_PARAM, &db_mysql_update_affected_found}, + {"unsigned_type", PARAM_INT, &db_mysql_unsigned_type}, {0, 0, 0} };
diff --git a/src/modules/db_mysql/km_res.c b/src/modules/db_mysql/km_res.c index 81f24dfc99..df7b00bce7 100644 --- a/src/modules/db_mysql/km_res.c +++ b/src/modules/db_mysql/km_res.c @@ -38,6 +38,7 @@ #include "km_my_con.h" #include "km_res.h"
+extern int db_mysql_unsigned_type;
/*! * \brief Get and convert columns from a result @@ -96,17 +97,19 @@ int db_mysql_get_columns(const db1_con_t* _h, db1_res_t* _r) case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: case MYSQL_TYPE_TIMESTAMP: - if (fields[col].flags & UNSIGNED_FLAG) { + if ((db_mysql_unsigned_type != 0) + && (fields[col].flags & UNSIGNED_FLAG)) { LM_DBG("use DB1_UINT result type\n"); RES_TYPES(_r)[col] = DB1_UINT; } else { LM_DBG("use DB1_INT result type\n"); - RES_TYPES(_r)[col] = DB1_UINT; + RES_TYPES(_r)[col] = DB1_INT; } break;
case MYSQL_TYPE_LONGLONG: - if (fields[col].flags & UNSIGNED_FLAG) { + if ((db_mysql_unsigned_type != 0) + && (fields[col].flags & UNSIGNED_FLAG)) { LM_DBG("use DB1_UBIGINT result type\n"); RES_TYPES(_r)[col] = DB1_UBIGINT; } else {