Module: sip-router
Branch: janakj/mysql
Commit: f828dad0ca2b3962afaae081fc109106ca905042
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f828dad…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Wed Dec 10 18:41:09 2008 +0000
- move db_mysql and db_unixodbc str2val implementation to the DB core,
remove the duplicated implementation in the modules
(preparation for query copy problem)
- introduced a small regression for the unixodbc in the NULL value handling
that needs to be fixed
git-svn-id:
https://openser.svn.sourceforge.net/svnroot/openser/trunk@5322
689a6050-402a-0410-94f2-e92a70836424
---
modules/db_mysql/km_row.c | 4 +-
modules/db_mysql/km_val.c | 114 ---------------------------------------------
modules/db_mysql/km_val.h | 13 -----
3 files changed, 2 insertions(+), 129 deletions(-)
diff --git a/modules/db_mysql/km_row.c b/modules/db_mysql/km_row.c
index c623198..87aecfb 100644
--- a/modules/db_mysql/km_row.c
+++ b/modules/db_mysql/km_row.c
@@ -32,7 +32,7 @@
#include "../../dprint.h"
#include "../../mem/mem.h"
#include "../../db/db_row.h"
-#include "../../db/db_ut.h"
+#include "../../db/db_val.h"
#include "my_con.h"
#include "val.h"
#include "row.h"
@@ -70,7 +70,7 @@ int db_mysql_convert_row(const db_con_t* _h, db_res_t* _res, db_row_t*
_r)
lengths = mysql_fetch_lengths(CON_RESULT(_h));
for(i = 0; i < RES_COL_N(_res); i++) {
- if (db_mysql_str2val(RES_TYPES(_res)[i], &(ROW_VALUES(_r)[i]),
+ if (db_str2val(RES_TYPES(_res)[i], &(ROW_VALUES(_r)[i]),
((MYSQL_ROW)CON_ROW(_h))[i], lengths[i]) < 0) {
LM_ERR("failed to convert value\n");
LM_DBG("free row at %p\n", _r);
diff --git a/modules/db_mysql/km_val.c b/modules/db_mysql/km_val.c
index 3af1e65..12f6ac5 100644
--- a/modules/db_mysql/km_val.c
+++ b/modules/db_mysql/km_val.c
@@ -37,120 +37,6 @@
/*!
- * \brief Convert a str to a db value, does not copy strings
- *
- * Convert a str to a db value, does not copy strings.
- * \param _t destination value type
- * \param _v destination value
- * \param _s source string
- * \param _l string length
- * \return 0 on success, negative on error
- */
-int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l)
-{
- static str dummy_string = {"", 0};
-
- if (!_v) {
- LM_ERR("invalid parameter value\n");
- return -1;
- }
- /* A NULL string is a NULL value in mysql, otherwise its an empty value */
- if (!_s) {
- memset(_v, 0, sizeof(db_val_t));
- /* Initialize the string pointers to a dummy empty
- * string so that we do not crash when the NULL flag
- * is set but the module does not check it properly
- */
- VAL_STRING(_v) = dummy_string.s;
- VAL_STR(_v) = dummy_string;
- VAL_BLOB(_v) = dummy_string;
- VAL_TYPE(_v) = _t;
- VAL_NULL(_v) = 1;
- return 0;
- }
- VAL_NULL(_v) = 0;
-
- switch(_t) {
- case DB_INT:
- LM_DBG("converting INT [%s]\n", _s);
- if (db_str2int(_s, &VAL_INT(_v)) < 0) {
- LM_ERR("error while converting integer value from string\n");
- return -2;
- } else {
- VAL_TYPE(_v) = DB_INT;
- return 0;
- }
- break;
-
- case DB_BIGINT:
- LM_DBG("converting BIGINT [%s]\n", _s);
- if (db_str2longlong(_s, &VAL_BIGINT(_v)) < 0) {
- LM_ERR("error while converting big integer value from string\n");
- return -3;
- } else {
- VAL_TYPE(_v) = DB_BIGINT;
- return 0;
- }
- break;
-
- case DB_BITMAP:
- LM_DBG("converting BITMAP [%s]\n", _s);
- if (db_str2int(_s, &VAL_INT(_v)) < 0) {
- LM_ERR("error while converting bitmap value from string\n");
- return -4;
- } else {
- VAL_TYPE(_v) = DB_BITMAP;
- return 0;
- }
- break;
-
- case DB_DOUBLE:
- LM_DBG("converting DOUBLE [%s]\n", _s);
- if (db_str2double(_s, &VAL_DOUBLE(_v)) < 0) {
- LM_ERR("error while converting double value from string\n");
- return -5;
- } else {
- VAL_TYPE(_v) = DB_DOUBLE;
- return 0;
- }
- break;
-
- case DB_STRING:
- LM_DBG("converting STRING [%s]\n", _s);
- VAL_STRING(_v) = _s;
- VAL_TYPE(_v) = DB_STRING;
- return 0;
-
- case DB_STR:
- LM_DBG("converting STR [%.*s]\n", _l, _s);
- VAL_STR(_v).s = (char*)_s;
- VAL_STR(_v).len = _l;
- VAL_TYPE(_v) = DB_STR;
- return 0;
-
- case DB_DATETIME:
- LM_DBG("converting DATETIME [%s]\n", _s);
- if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
- LM_ERR("error while converting datetime value from string\n");
- return -6;
- } else {
- VAL_TYPE(_v) = DB_DATETIME;
- return 0;
- }
- break;
-
- case DB_BLOB:
- LM_DBG("converting BLOB [%.*s]\n", _l, _s);
- VAL_BLOB(_v).s = (char*)_s;
- VAL_BLOB(_v).len = _l;
- VAL_TYPE(_v) = DB_BLOB;
- return 0;
- }
- return -7;
-}
-
-
-/*!
* \brief Converting a value to a string
*
* Converting a value to a string, used when converting result from a query
diff --git a/modules/db_mysql/km_val.h b/modules/db_mysql/km_val.h
index f9cb609..1040ea4 100644
--- a/modules/db_mysql/km_val.h
+++ b/modules/db_mysql/km_val.h
@@ -38,19 +38,6 @@
/*!
- * \brief Convert a str to a db value, does not copy strings
- *
- * Convert a str to a db value, does not copy strings.
- * \param _t destination value type
- * \param _v destination value
- * \param _s source string
- * \param _l string length
- * \return 0 on success, negative on error
- */
-int db_mysql_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l);
-
-
-/*!
* \brief Converting a value to a string
*
* Converting a value to a string, used when converting result from a query