Browse Source

- some useful debugging information

Jan Janak 20 năm trước cách đây
mục cha
commit
c802ee8810

+ 1 - 1
modules/db_mysql/db_con.c

@@ -41,7 +41,7 @@
 int use_table(db_con_t* _h, const char* _t)
 {
 	if ((!_h) || (!_t)) {
-		LOG(L_ERR, "use_table(): Invalid parameter value\n");
+		LOG(L_ERR, "use_table: Invalid parameter value\n");
 		return -1;
 	}
 

+ 17 - 6
modules/db_mysql/db_mod.c

@@ -37,9 +37,13 @@
 #include "dbase.h"
 #include "db_mod.h"
 
+#include <mysql.h>
+
 int ping_interval = 5 * 60; /* Default is 5 minutes */
 int auto_reconnect = 1;     /* Default is enabled */
 
+static int mysql_mod_init(void);
+
 MODULE_VERSION
 
 
@@ -73,10 +77,17 @@ static param_export_t params[] = {
 struct module_exports exports = {	
 	"mysql",
 	cmds,
-	params, /*  module parameters */
-	0,      /* module initialization function */
-	0,      /* response function*/
-	0,      /* destroy function */
-	0,      /* oncancel function */
-	0       /* per-child init function */
+	params,          /*  module parameters */
+	mysql_mod_init,  /* module initialization function */
+	0,               /* response function*/
+	0,               /* destroy function */
+	0,               /* oncancel function */
+	0                /* per-child init function */
 };
+
+
+static int mysql_mod_init(void)
+{
+	DBG("mysql: MySQL client version is %s\n", mysql_get_client_info());
+	return 0;
+}

+ 26 - 26
modules/db_mysql/dbase.c

@@ -58,7 +58,7 @@ static int submit_query(db_con_t* _h, const char* _s)
 	int i, code;
 
 	if ((!_h) || (!_s)) {
-		LOG(L_ERR, "submit_query(): Invalid parameter value\n");
+		LOG(L_ERR, "submit_query: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -66,7 +66,7 @@ static int submit_query(db_con_t* _h, const char* _s)
 		t = time(0);
 		if ((t - CON_TIMESTAMP(_h)) > ping_interval) {
 			if (mysql_ping(CON_CONNECTION(_h))) {
-				DBG("submit_query(): mysql_ping failed\n");
+				DBG("submit_query: mysql_ping failed\n");
 			}
 		}
 		CON_TIMESTAMP(_h) = t;
@@ -95,7 +95,7 @@ static int submit_query(db_con_t* _h, const char* _s)
 			break;
 		}
 	}
-	LOG(L_ERR, "submit_query(): %s\n", mysql_error(CON_CONNECTION(_h)));
+	LOG(L_ERR, "submit_query: %s\n", mysql_error(CON_CONNECTION(_h)));
 	return -2;
 }
 
@@ -109,7 +109,7 @@ static int print_columns(char* _b, int _l, db_key_t* _c, int _n)
 	int len = 0;
 
 	if ((!_c) || (!_n) || (!_b) || (!_l)) {
-		LOG(L_ERR, "print_columns(): Invalid parameter value\n");
+		LOG(L_ERR, "print_columns: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -140,14 +140,14 @@ static int print_values(MYSQL* _c, char* _b, int _l, db_val_t* _v, int _n)
 	int i, res = 0, l;
 
 	if (!_c || !_b || !_l || !_v || !_n) {
-		LOG(L_ERR, "print_values(): Invalid parameter value\n");
+		LOG(L_ERR, "print_values: Invalid parameter value\n");
 		return -1;
 	}
 
 	for(i = 0; i < _n; i++) {
 		l = _l - res;
 		if (val2str(_c, _v + i, _b + res, &l) < 0) {
-			LOG(L_ERR, "print_values(): Error while converting value to string\n");
+			LOG(L_ERR, "print_values: Error while converting value to string\n");
 			return -1;
 		}
 		res += l;
@@ -170,7 +170,7 @@ static int print_where(MYSQL* _c, char* _b, int _l, db_key_t* _k, db_op_t* _o, d
 	int l;
 
 	if (!_c || !_b || !_l || !_k || !_v || !_n) {
-		LOG(L_ERR, "print_where(): Invalid parameter value\n");
+		LOG(L_ERR, "print_where: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -211,7 +211,7 @@ static int print_set(MYSQL* _c, char* _b, int _l, db_key_t* _k, db_val_t* _v, in
 	int l;
 
 	if (!_c || !_b || !_l || !_k || !_v || !_n) {
-		LOG(L_ERR, "print_set(): Invalid parameter value\n");
+		LOG(L_ERR, "print_set: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -246,13 +246,13 @@ db_con_t* db_init(const char* _url)
 	db_con_t* res;
 
 	if (!_url) {
-		LOG(L_ERR, "db_init(): Invalid parameter value\n");
+		LOG(L_ERR, "db_init: Invalid parameter value\n");
 		return 0;
 	}
 
 	res = pkg_malloc(sizeof(db_con_t) + sizeof(struct my_con*));
 	if (!res) {
-		LOG(L_ERR, "db_init(): No memory left\n");
+		LOG(L_ERR, "db_init: No memory left\n");
 		return 0;
 	}
 	memset(res, 0, sizeof(db_con_t) + sizeof(struct my_con*));
@@ -260,7 +260,7 @@ db_con_t* db_init(const char* _url)
 	res->tail = (unsigned long)get_connection(_url);
 
 	if (!res->tail) {
-		LOG(L_ERR, "db_init(): Could not create a connection\n");
+		LOG(L_ERR, "db_init: Could not create a connection\n");
 		pkg_free(res);
 		return 0;
 	}
@@ -276,7 +276,7 @@ db_con_t* db_init(const char* _url)
 void db_close(db_con_t* _h)
 {
 	if (!_h) {
-		LOG(L_ERR, "db_close(): Invalid parameter value\n");
+		LOG(L_ERR, "db_close: Invalid parameter value\n");
 		return;
 	}
 
@@ -291,13 +291,13 @@ void db_close(db_con_t* _h)
 static int store_result(db_con_t* _h, db_res_t** _r)
 {
 	if ((!_h) || (!_r)) {
-		LOG(L_ERR, "store_result(): Invalid parameter value\n");
+		LOG(L_ERR, "store_result: Invalid parameter value\n");
 		return -1;
 	}
 
 	*_r = new_result();
 	if (*_r == 0) {
-		LOG(L_ERR, "store_result(): No memory left\n");
+		LOG(L_ERR, "store_result: No memory left\n");
 		return -2;
 	}
 
@@ -308,7 +308,7 @@ static int store_result(db_con_t* _h, db_res_t** _r)
 			(*_r)->n = 0;
 			return 0;
 		} else {
-			LOG(L_ERR, "store_result(): %s\n", mysql_error(CON_CONNECTION(_h)));
+			LOG(L_ERR, "store_result: %s\n", mysql_error(CON_CONNECTION(_h)));
 			free_result(*_r);
 			*_r = 0;
 			return -3;
@@ -316,7 +316,7 @@ static int store_result(db_con_t* _h, db_res_t** _r)
 	}
 
         if (convert_result(_h, *_r) < 0) {
-		LOG(L_ERR, "store_result(): Error while converting result\n");
+		LOG(L_ERR, "store_result: Error while converting result\n");
 		pkg_free(*_r);
 
 		     /* This cannot be used because if convert_result fails,
@@ -337,12 +337,12 @@ static int store_result(db_con_t* _h, db_res_t** _r)
 int db_free_result(db_con_t* _h, db_res_t* _r)
 {
      if ((!_h) || (!_r)) {
-	     LOG(L_ERR, "db_free_result(): Invalid parameter value\n");
+	     LOG(L_ERR, "db_free_result: Invalid parameter value\n");
 	     return -1;
      }
 
      if (free_result(_r) < 0) {
-	     LOG(L_ERR, "db_free_result(): Unable to free result structure\n");
+	     LOG(L_ERR, "db_free_result: Unable to free result structure\n");
 	     return -1;
      }
      mysql_free_result(CON_RESULT(_h));
@@ -369,7 +369,7 @@ int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op,
 	int off, ret;
 
 	if (!_h) {
-		LOG(L_ERR, "db_query(): Invalid parameter value\n");
+		LOG(L_ERR, "db_query: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -407,14 +407,14 @@ int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op,
 	
 	*(sql_buf + off) = '\0';
 	if (submit_query(_h, sql_buf) < 0) {
-		LOG(L_ERR, "submit_query(): Error while submitting query\n");
+		LOG(L_ERR, "db_query: Error while submitting query\n");
 		return -2;
 	}
 
 	return store_result(_h, _r);
 
  error:
-	LOG(L_ERR, "submit_query: Error in snprintf\n");
+	LOG(L_ERR, "db_query: Error in snprintf\n");
 	return -1;
 }
 
@@ -425,12 +425,12 @@ int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op,
 int db_raw_query(db_con_t* _h, char* _s, db_res_t** _r)
 {
 	if ((!_h) || (!_s)) {
-		LOG(L_ERR, "db_raw_query(): Invalid parameter value\n");
+		LOG(L_ERR, "db_raw_query: Invalid parameter value\n");
 		return -1;
 	}
 
 	if (submit_query(_h, _s) < 0) {
-		LOG(L_ERR, "submit_query(): Error while submitting query\n");
+		LOG(L_ERR, "db_raw_query: Error while submitting query\n");
 		return -2;
 	}
 
@@ -452,7 +452,7 @@ int db_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
 	int off, ret;
 
 	if ((!_h) || (!_k) || (!_v) || (!_n)) {
-		LOG(L_ERR, "db_insert(): Invalid parameter value\n");
+		LOG(L_ERR, "db_insert: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -500,7 +500,7 @@ int db_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n)
 	int off, ret;
 
 	if (!_h) {
-		LOG(L_ERR, "db_delete(): Invalid parameter value\n");
+		LOG(L_ERR, "db_delete: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -548,7 +548,7 @@ int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
 	int off, ret;
 
 	if ((!_h) || (!_uk) || (!_uv) || (!_un)) {
-		LOG(L_ERR, "db_update(): Invalid parameter value\n");
+		LOG(L_ERR, "db_update: Invalid parameter value\n");
 		return -1;
 	}
 

+ 28 - 4
modules/db_mysql/my_con.c

@@ -31,6 +31,7 @@
 #include "my_con.h"
 #include "../../mem/mem.h"
 #include "../../dprint.h"
+#include "../../ut.h"
 #include "utils.h"
 
 
@@ -43,13 +44,13 @@ struct my_con* new_connection(struct my_id* id)
 	struct my_con* ptr;
 
 	if (!id) {
-		LOG(L_ERR, "new_connection(): Invalid parameter value\n");
+		LOG(L_ERR, "new_connection: Invalid parameter value\n");
 		return 0;
 	}
 
 	ptr = (struct my_con*)pkg_malloc(sizeof(struct my_con));
 	if (!ptr) {
-		LOG(L_ERR, "new_connection(): No memory left\n");
+		LOG(L_ERR, "new_connection: No memory left\n");
 		return 0;
 	}
 
@@ -58,21 +59,44 @@ struct my_con* new_connection(struct my_id* id)
 	
 	ptr->con = (MYSQL*)pkg_malloc(sizeof(MYSQL));
 	if (!ptr->con) {
-		LOG(L_ERR, "new_connection(): No enough memory\n");
+		LOG(L_ERR, "new_connection: No enough memory\n");
 		goto err;
 	}
 
 	mysql_init(ptr->con);
 
+	if (id->port) {
+		DBG("new_connection: Opening MySQL connection: mysql://%.*s:%.*s@%.*s:%d/%.*s\n",
+		    id->username.len, ZSW(id->username.s),
+		    id->password.len, ZSW(id->password.s),
+		    id->host.len, ZSW(id->host.s),
+		    id->port,
+		    id->database.len, ZSW(id->database.s)
+		    );
+	} else {
+		DBG("new_connection: Opening MySQL connection: mysql://%.*s:%.*s@%.*s/%.*s\n",
+		    id->username.len, ZSW(id->username.s),
+		    id->password.len, ZSW(id->password.s),
+		    id->host.len, ZSW(id->host.s),
+		    id->database.len, ZSW(id->database.s)
+		    );
+	}
+
 	if (!mysql_real_connect(ptr->con, id->host.s, id->username.s, id->password.s, id->database.s, id->port, 0, 0)) {
-		LOG(L_ERR, "new_connection(): %s\n", mysql_error(ptr->con));
+		LOG(L_ERR, "new_connection: %s\n", mysql_error(ptr->con));
 		mysql_close(ptr->con);
 		goto err;
 	}
 
+	DBG("new_connection: Connection type is %s\n", mysql_get_host_info(ptr->con));
+	DBG("new_connection: Protocol version is %d\n", mysql_get_proto_info(ptr->con));
+	DBG("new_connection: Server version is %s\n", mysql_get_server_info(ptr->con));
+
+
 	ptr->timestamp = time(0);
 
 	ptr->id = id;
+	
 	return ptr;
 
  err:

+ 8 - 8
modules/db_mysql/my_id.c

@@ -44,7 +44,7 @@ struct my_id* new_my_id(const char* url)
 	struct my_id* ptr;
 
 	if (!url) {
-		LOG(L_ERR, "new_my_id(): Invalid parameter\n");
+		LOG(L_ERR, "new_my_id: Invalid parameter\n");
 		return 0;
 	}
 
@@ -52,27 +52,27 @@ struct my_id* new_my_id(const char* url)
 	l = strlen(url);
 	buf = (char*)pkg_malloc(l + 1);
 	if (!buf) {
-		LOG(L_ERR, "new_my_id(): Not enough memory\n");
+		LOG(L_ERR, "new_my_id: Not enough memory\n");
 		return 0;
 	}
 	memcpy(buf, url, l + 1);
 
 	ptr = (struct my_id*)pkg_malloc(sizeof(struct my_id));
 	if (!ptr) {
-		LOG(L_ERR, "new_my_id(): No memory left\n");
+		LOG(L_ERR, "new_my_id: No memory left\n");
 		goto err;
 	}
 	memset(ptr, 0, sizeof(struct my_id));
 
 	if (parse_mysql_url(buf, &username, &password, &host, &port, &database) < 0) {
-		LOG(L_ERR, "new_my_id(): Error while parsing mysql URL: %s\n", url);
+		LOG(L_ERR, "new_my_id: Error while parsing mysql URL: %s\n", url);
 		goto err;
 	}
 
 	ptr->username.len = strlen(username);
 	ptr->username.s = (char*)pkg_malloc(ptr->username.len + 1);
 	if (!ptr->username.s) {
-		LOG(L_ERR, "new_connection(): No memory left\n");
+		LOG(L_ERR, "new_my_id: No memory left\n");
 		goto err;
 	}
 	memcpy(ptr->username.s, username, ptr->username.len + 1);
@@ -81,7 +81,7 @@ struct my_id* new_my_id(const char* url)
 		ptr->password.len = strlen(password);
 		ptr->password.s = (char*)pkg_malloc(ptr->password.len + 1);
 		if (!ptr->password.s) {
-			LOG(L_ERR, "new_connection(): No memory left\n");
+			LOG(L_ERR, "new_my_id: No memory left\n");
 			goto err;
 		}
 		memcpy(ptr->password.s, password, ptr->password.len + 1);
@@ -90,7 +90,7 @@ struct my_id* new_my_id(const char* url)
 	ptr->host.len = strlen(host);
 	ptr->host.s = (char*)pkg_malloc(ptr->host.len + 1);
 	if (!ptr->host.s) {
-		LOG(L_ERR, "new_connection(): No memory left\n");
+		LOG(L_ERR, "new_my_id: No memory left\n");
 		goto err;
 	}
 	memcpy(ptr->host.s, host, ptr->host.len + 1);
@@ -104,7 +104,7 @@ struct my_id* new_my_id(const char* url)
 	ptr->database.len = strlen(database);
 	ptr->database.s = (char*)pkg_malloc(ptr->database.len + 1);
 	if (!ptr->database.s) {
-		LOG(L_ERR, "new_connection(): No memory left\n");
+		LOG(L_ERR, "new_my_id: No memory left\n");
 		goto err;
 	}
 	memcpy(ptr->database.s, database, ptr->database.len + 1);

+ 7 - 7
modules/db_mysql/my_pool.c

@@ -54,13 +54,13 @@ struct my_con* get_connection(const char* url)
 	int pid;
 
 	if (!url) {
-		LOG(L_ERR, "get_connection(): Invalid parameter value\n");
+		LOG(L_ERR, "get_connection: Invalid parameter value\n");
 		return 0;
 	}
 
 	pid = getpid();
 	if (pool && (pool_pid != pid)) {
-		LOG(L_ERR, "get_connection(): Inherited open database connections, this is not a good idea\n");
+		LOG(L_ERR, "get_connection: Inherited open database connections, this is not a good idea\n");
 		return 0;
 	}
 
@@ -72,7 +72,7 @@ struct my_con* get_connection(const char* url)
 	ptr = pool;
 	while (ptr) {
 		if (cmp_my_id(id, ptr->id)) {
-			DBG("get_connection(): Connection found in the pool\n");
+			DBG("get_connection: Connection found in the pool\n");
 			ptr->ref++;
 			free_my_id(id);
 			return ptr;
@@ -80,7 +80,7 @@ struct my_con* get_connection(const char* url)
 		ptr = ptr->next;
 	}
 
-	DBG("get_connection(): Connection not found in the pool\n");
+	DBG("get_connection: Connection not found in the pool\n");
 	ptr = new_connection(id);
 	if (!ptr) {
 		free_my_id(id);
@@ -108,12 +108,12 @@ void release_connection(struct my_con* con)
 		     /* There are still other users, just
 		      * decrease the reference count and return
 		      */
-		DBG("release_connection(): Connection still kept in the pool\n");
+		DBG("release_connection: Connection still kept in the pool\n");
 		con->ref--;
 		return;
 	}
 
-	DBG("release_connection(): Removing connection from the pool\n");
+	DBG("release_connection: Removing connection from the pool\n");
 
 	if (pool == con) {
 		pool = pool->next;
@@ -124,7 +124,7 @@ void release_connection(struct my_con* con)
 			ptr = ptr->next;
 		}
 		if (!ptr) {
-			LOG(L_ERR, "release_connection(): Weird, connection not found in the pool\n");
+			LOG(L_ERR, "release_connection: Weird, connection not found in the pool\n");
 		} else {
 			     /* Remove the connection from the pool */
 			ptr->next = con->next;

+ 15 - 15
modules/db_mysql/res.c

@@ -45,25 +45,25 @@ static inline int get_columns(db_con_t* _h, db_res_t* _r)
 	MYSQL_FIELD* fields;
 
 	if ((!_h) || (!_r)) {
-		LOG(L_ERR, "get_columns(): Invalid parameter\n");
+		LOG(L_ERR, "get_columns: Invalid parameter\n");
 		return -1;
 	}
 
 	n = mysql_field_count(CON_CONNECTION(_h));
 	if (!n) {
-		LOG(L_ERR, "get_columns(): No columns\n");
+		LOG(L_ERR, "get_columns: No columns\n");
 		return -2;
 	}
 	
         RES_NAMES(_r) = (db_key_t*)pkg_malloc(sizeof(db_key_t) * n);
 	if (!RES_NAMES(_r)) {
-		LOG(L_ERR, "get_columns(): No memory left\n");
+		LOG(L_ERR, "get_columns: No memory left\n");
 		return -3;
 	}
 
 	RES_TYPES(_r) = (db_type_t*)pkg_malloc(sizeof(db_type_t) * n);
 	if (!RES_TYPES(_r)) {
-		LOG(L_ERR, "get_columns(): No memory left\n");
+		LOG(L_ERR, "get_columns: No memory left\n");
 		pkg_free(RES_NAMES(_r));
 		return -4;
 	}
@@ -119,7 +119,7 @@ static inline int free_rows(db_res_t* _r)
 	int i;
 
 	if (!_r) {
-		LOG(L_ERR, "free_rows(): Invalid parameter value\n");
+		LOG(L_ERR, "free_rows: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -139,7 +139,7 @@ static inline int convert_rows(db_con_t* _h, db_res_t* _r)
 	int n, i;
 
 	if ((!_h) || (!_r)) {
-		LOG(L_ERR, "convert_rows(): Invalid parameter\n");
+		LOG(L_ERR, "convert_rows: Invalid parameter\n");
 		return -1;
 	}
 
@@ -151,20 +151,20 @@ static inline int convert_rows(db_con_t* _h, db_res_t* _r)
 	}
 	RES_ROWS(_r) = (struct db_row*)pkg_malloc(sizeof(db_row_t) * n);
 	if (!RES_ROWS(_r)) {
-		LOG(L_ERR, "convert_rows(): No memory left\n");
+		LOG(L_ERR, "convert_rows: No memory left\n");
 		return -2;
 	}
 
 	for(i = 0; i < n; i++) {
 		CON_ROW(_h) = mysql_fetch_row(CON_RESULT(_h));
 		if (!CON_ROW(_h)) {
-			LOG(L_ERR, "convert_rows(): %s\n", mysql_error(CON_CONNECTION(_h)));
+			LOG(L_ERR, "convert_rows: %s\n", mysql_error(CON_CONNECTION(_h)));
 			RES_ROW_N(_r) = i;
 			free_rows(_r);
 			return -3;
 		}
 		if (convert_row(_h, _r, &(RES_ROWS(_r)[i])) < 0) {
-			LOG(L_ERR, "convert_rows(): Error while converting row #%d\n", i);
+			LOG(L_ERR, "convert_rows: Error while converting row #%d\n", i);
 			RES_ROW_N(_r) = i;
 			free_rows(_r);
 			return -4;
@@ -180,7 +180,7 @@ static inline int convert_rows(db_con_t* _h, db_res_t* _r)
 static inline int free_columns(db_res_t* _r)
 {
 	if (!_r) {
-		LOG(L_ERR, "free_columns(): Invalid parameter\n");
+		LOG(L_ERR, "free_columns: Invalid parameter\n");
 		return -1;
 	}
 
@@ -198,7 +198,7 @@ db_res_t* new_result(void)
 	db_res_t* r;
 	r = (db_res_t*)pkg_malloc(sizeof(db_res_t));
 	if (!r) {
-		LOG(L_ERR, "new_result(): No memory left\n");
+		LOG(L_ERR, "new_result: No memory left\n");
 		return 0;
 	}
 	RES_NAMES(r) = 0;
@@ -216,17 +216,17 @@ db_res_t* new_result(void)
 int convert_result(db_con_t* _h, db_res_t* _r)
 {
 	if ((!_h) || (!_r)) {
-		LOG(L_ERR, "convert_result(): Invalid parameter\n");
+		LOG(L_ERR, "convert_result: Invalid parameter\n");
 		return -1;
 	}
 
 	if (get_columns(_h, _r) < 0) {
-		LOG(L_ERR, "convert_result(): Error while getting column names\n");
+		LOG(L_ERR, "convert_result: Error while getting column names\n");
 		return -2;
 	}
 
 	if (convert_rows(_h, _r) < 0) {
-		LOG(L_ERR, "convert_result(): Error while converting rows\n");
+		LOG(L_ERR, "convert_result: Error while converting rows\n");
 		free_columns(_r);
 		return -3;
 	}
@@ -240,7 +240,7 @@ int convert_result(db_con_t* _h, db_res_t* _r)
 int free_result(db_res_t* _r)
 {
 	if (!_r) {
-		LOG(L_ERR, "free_result(): Invalid parameter\n");
+		LOG(L_ERR, "free_result: Invalid parameter\n");
 		return -1;
 	}
 

+ 4 - 4
modules/db_mysql/row.c

@@ -45,14 +45,14 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
 	int i;
 
 	if ((!_h) || (!_res) || (!_r)) {
-		LOG(L_ERR, "convert_row(): Invalid parameter value\n");
+		LOG(L_ERR, "convert_row: Invalid parameter value\n");
 		return -1;
 	}
 
 	ROW_VALUES(_r) = (db_val_t*)pkg_malloc(sizeof(db_val_t) * RES_COL_N(_res));
 	ROW_N(_r) = RES_COL_N(_res);
 	if (!ROW_VALUES(_r)) {
-		LOG(L_ERR, "convert_row(): No memory left\n");
+		LOG(L_ERR, "convert_row: No memory left\n");
 		return -1;
 	}
 
@@ -61,7 +61,7 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
 	for(i = 0; i < RES_COL_N(_res); i++) {
 		if (str2val(RES_TYPES(_res)[i], &(ROW_VALUES(_r)[i]), 
 			    ((MYSQL_ROW)CON_ROW(_h))[i], lengths[i]) < 0) {
-			LOG(L_ERR, "convert_row(): Error while converting value\n");
+			LOG(L_ERR, "convert_row: Error while converting value\n");
 			free_row(_r);
 			return -3;
 		}
@@ -76,7 +76,7 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r)
 int free_row(db_row_t* _r)
 {
 	if (!_r) {
-		LOG(L_ERR, "free_row(): Invalid parameter value\n");
+		LOG(L_ERR, "free_row: Invalid parameter value\n");
 		return -1;
 	}
 

+ 20 - 20
modules/db_mysql/val.c

@@ -39,7 +39,7 @@
 static inline int str2int(const char* _s, int* _v)
 {
 	if ((!_s) || (!_v)) {
-		LOG(L_ERR, "str2int(): Invalid parameter value\n");
+		LOG(L_ERR, "str2int: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -54,7 +54,7 @@ static inline int str2int(const char* _s, int* _v)
 static inline int str2double(const char* _s, double* _v)
 {
 	if ((!_s) || (!_v)) {
-		LOG(L_ERR, "str2double(): Invalid parameter value\n");
+		LOG(L_ERR, "str2double: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -69,7 +69,7 @@ static inline int str2double(const char* _s, double* _v)
 static inline int str2time(const char* _s, time_t* _v)
 {
 	if ((!_s) || (!_v)) {
-		LOG(L_ERR, "str2time(): Invalid parameter value\n");
+		LOG(L_ERR, "str2time: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -86,7 +86,7 @@ static inline int int2str(int _v, char* _s, int* _l)
 	int ret;
 
 	if ((!_s) || (!_l) || (!*_l)) {
-		LOG(L_ERR, "int2str(): Invalid parameter value\n");
+		LOG(L_ERR, "int2str: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -109,7 +109,7 @@ static inline int double2str(double _v, char* _s, int* _l)
 	int ret;
 
 	if ((!_s) || (!_l) || (!*_l)) {
-		LOG(L_ERR, "double2str(): Invalid parameter value\n");
+		LOG(L_ERR, "double2str: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -132,7 +132,7 @@ static inline int time2str(time_t _v, char* _s, int* _l)
 	int l;
 
 	if ((!_s) || (!_l) || (*_l < 2))  {
-		LOG(L_ERR, "Invalid parameter value\n");
+		LOG(L_ERR, "time2str: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -149,7 +149,7 @@ static inline int time2str(time_t _v, char* _s, int* _l)
 int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l)
 {
 	if (!_v) {
-		LOG(L_ERR, "str2val(): Invalid parameter value\n");
+		LOG(L_ERR, "str2val: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -164,7 +164,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l)
 	switch(_t) {
 	case DB_INT:
 		if (str2int(_s, &VAL_INT(_v)) < 0) {
-			LOG(L_ERR, "str2val(): Error while converting integer value from string\n");
+			LOG(L_ERR, "str2val: Error while converting integer value from string\n");
 			return -2;
 		} else {
 			VAL_TYPE(_v) = DB_INT;
@@ -174,7 +174,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l)
 
 	case DB_BITMAP:
 		if (str2int(_s, &VAL_INT(_v)) < 0) {
-			LOG(L_ERR, "str2val(): Error while converting bitmap value from string\n");
+			LOG(L_ERR, "str2val: Error while converting bitmap value from string\n");
 			return -3;
 		} else {
 			VAL_TYPE(_v) = DB_BITMAP;
@@ -184,7 +184,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l)
 	
 	case DB_DOUBLE:
 		if (str2double(_s, &VAL_DOUBLE(_v)) < 0) {
-			LOG(L_ERR, "str2val(): Error while converting double value from string\n");
+			LOG(L_ERR, "str2val: Error while converting double value from string\n");
 			return -4;
 		} else {
 			VAL_TYPE(_v) = DB_DOUBLE;
@@ -205,7 +205,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l)
 
 	case DB_DATETIME:
 		if (str2time(_s, &VAL_TIME(_v)) < 0) {
-			LOG(L_ERR, "str2val(): Error while converting datetime value from string\n");
+			LOG(L_ERR, "str2val: Error while converting datetime value from string\n");
 			return -5;
 		} else {
 			VAL_TYPE(_v) = DB_DATETIME;
@@ -232,7 +232,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 	char* old_s;
 
 	if (!_c || !_v || !_s || !_len || !*_len) {
-		LOG(L_ERR, "val2str(): Invalid parameter value\n");
+		LOG(L_ERR, "val2str: Invalid parameter value\n");
 		return -1;
 	}
 
@@ -248,7 +248,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 	switch(VAL_TYPE(_v)) {
 	case DB_INT:
 		if (int2str(VAL_INT(_v), _s, _len) < 0) {
-			LOG(L_ERR, "val2str(): Error while converting string to int\n");
+			LOG(L_ERR, "val2str: Error while converting string to int\n");
 			return -2;
 		} else {
 			return 0;
@@ -257,7 +257,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 
 	case DB_BITMAP:
 		if (int2str(VAL_BITMAP(_v), _s, _len) < 0) {
-			LOG(L_ERR, "val2str(): Error while converting string to int\n");
+			LOG(L_ERR, "val2str: Error while converting string to int\n");
 			return -3;
 		} else {
 			return 0;
@@ -266,7 +266,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 
 	case DB_DOUBLE:
 		if (double2str(VAL_DOUBLE(_v), _s, _len) < 0) {
-			LOG(L_ERR, "val2str(): Error while converting string to double\n");
+			LOG(L_ERR, "val2str: Error while converting string to double\n");
 			return -4;
 		} else {
 			return 0;
@@ -276,7 +276,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 	case DB_STRING:
 		l = strlen(VAL_STRING(_v));
 		if (*_len < (l * 2 + 3)) {
-			LOG(L_ERR, "val2str(): Destination buffer too short\n");
+			LOG(L_ERR, "val2str: Destination buffer too short\n");
 			return -5;
 		} else {
 			old_s = _s;
@@ -292,7 +292,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 	case DB_STR:
 		l = VAL_STR(_v).len;
 		if (*_len < (l * 2 + 3)) {
-			LOG(L_ERR, "val2str(): Destination buffer too short\n");
+			LOG(L_ERR, "val2str: Destination buffer too short\n");
 			return -6;
 		} else {
 			old_s = _s;
@@ -307,7 +307,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 
 	case DB_DATETIME:
 		if (time2str(VAL_TIME(_v), _s, _len) < 0) {
-			LOG(L_ERR, "val2str(): Error while converting string to time_t\n");
+			LOG(L_ERR, "val2str: Error while converting string to time_t\n");
 			return -7;
 		} else {
 			return 0;
@@ -317,7 +317,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 	case DB_BLOB:
 		l = VAL_BLOB(_v).len;
 		if (*_len < (l * 2 + 3)) {
-			LOG(L_ERR, "val2str(): Destination buffer too short\n");
+			LOG(L_ERR, "val2str: Destination buffer too short\n");
 			return -8;
 		} else {
 			old_s = _s;
@@ -331,7 +331,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len)
 		break;
 
 	default:
-		DBG("val2str(): Unknown data type\n");
+		DBG("val2str: Unknown data type\n");
 		return -9;
 	}
 	/*return -8; --not reached*/