... | ... |
@@ -37,9 +37,13 @@ |
37 | 37 |
#include "dbase.h" |
38 | 38 |
#include "db_mod.h" |
39 | 39 |
|
40 |
+#include <mysql.h> |
|
41 |
+ |
|
40 | 42 |
int ping_interval = 5 * 60; /* Default is 5 minutes */ |
41 | 43 |
int auto_reconnect = 1; /* Default is enabled */ |
42 | 44 |
|
45 |
+static int mysql_mod_init(void); |
|
46 |
+ |
|
43 | 47 |
MODULE_VERSION |
44 | 48 |
|
45 | 49 |
|
... | ... |
@@ -73,10 +77,17 @@ static param_export_t params[] = { |
73 | 77 |
struct module_exports exports = { |
74 | 78 |
"mysql", |
75 | 79 |
cmds, |
76 |
- params, /* module parameters */ |
|
77 |
- 0, /* module initialization function */ |
|
78 |
- 0, /* response function*/ |
|
79 |
- 0, /* destroy function */ |
|
80 |
- 0, /* oncancel function */ |
|
81 |
- 0 /* per-child init function */ |
|
80 |
+ params, /* module parameters */ |
|
81 |
+ mysql_mod_init, /* module initialization function */ |
|
82 |
+ 0, /* response function*/ |
|
83 |
+ 0, /* destroy function */ |
|
84 |
+ 0, /* oncancel function */ |
|
85 |
+ 0 /* per-child init function */ |
|
82 | 86 |
}; |
87 |
+ |
|
88 |
+ |
|
89 |
+static int mysql_mod_init(void) |
|
90 |
+{ |
|
91 |
+ DBG("mysql: MySQL client version is %s\n", mysql_get_client_info()); |
|
92 |
+ return 0; |
|
93 |
+} |
... | ... |
@@ -58,7 +58,7 @@ static int submit_query(db_con_t* _h, const char* _s) |
58 | 58 |
int i, code; |
59 | 59 |
|
60 | 60 |
if ((!_h) || (!_s)) { |
61 |
- LOG(L_ERR, "submit_query(): Invalid parameter value\n"); |
|
61 |
+ LOG(L_ERR, "submit_query: Invalid parameter value\n"); |
|
62 | 62 |
return -1; |
63 | 63 |
} |
64 | 64 |
|
... | ... |
@@ -66,7 +66,7 @@ static int submit_query(db_con_t* _h, const char* _s) |
66 | 66 |
t = time(0); |
67 | 67 |
if ((t - CON_TIMESTAMP(_h)) > ping_interval) { |
68 | 68 |
if (mysql_ping(CON_CONNECTION(_h))) { |
69 |
- DBG("submit_query(): mysql_ping failed\n"); |
|
69 |
+ DBG("submit_query: mysql_ping failed\n"); |
|
70 | 70 |
} |
71 | 71 |
} |
72 | 72 |
CON_TIMESTAMP(_h) = t; |
... | ... |
@@ -95,7 +95,7 @@ static int submit_query(db_con_t* _h, const char* _s) |
95 | 95 |
break; |
96 | 96 |
} |
97 | 97 |
} |
98 |
- LOG(L_ERR, "submit_query(): %s\n", mysql_error(CON_CONNECTION(_h))); |
|
98 |
+ LOG(L_ERR, "submit_query: %s\n", mysql_error(CON_CONNECTION(_h))); |
|
99 | 99 |
return -2; |
100 | 100 |
} |
101 | 101 |
|
... | ... |
@@ -109,7 +109,7 @@ static int print_columns(char* _b, int _l, db_key_t* _c, int _n) |
109 | 109 |
int len = 0; |
110 | 110 |
|
111 | 111 |
if ((!_c) || (!_n) || (!_b) || (!_l)) { |
112 |
- LOG(L_ERR, "print_columns(): Invalid parameter value\n"); |
|
112 |
+ LOG(L_ERR, "print_columns: Invalid parameter value\n"); |
|
113 | 113 |
return -1; |
114 | 114 |
} |
115 | 115 |
|
... | ... |
@@ -140,14 +140,14 @@ static int print_values(MYSQL* _c, char* _b, int _l, db_val_t* _v, int _n) |
140 | 140 |
int i, res = 0, l; |
141 | 141 |
|
142 | 142 |
if (!_c || !_b || !_l || !_v || !_n) { |
143 |
- LOG(L_ERR, "print_values(): Invalid parameter value\n"); |
|
143 |
+ LOG(L_ERR, "print_values: Invalid parameter value\n"); |
|
144 | 144 |
return -1; |
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
for(i = 0; i < _n; i++) { |
148 | 148 |
l = _l - res; |
149 | 149 |
if (val2str(_c, _v + i, _b + res, &l) < 0) { |
150 |
- LOG(L_ERR, "print_values(): Error while converting value to string\n"); |
|
150 |
+ LOG(L_ERR, "print_values: Error while converting value to string\n"); |
|
151 | 151 |
return -1; |
152 | 152 |
} |
153 | 153 |
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 |
170 | 170 |
int l; |
171 | 171 |
|
172 | 172 |
if (!_c || !_b || !_l || !_k || !_v || !_n) { |
173 |
- LOG(L_ERR, "print_where(): Invalid parameter value\n"); |
|
173 |
+ LOG(L_ERR, "print_where: Invalid parameter value\n"); |
|
174 | 174 |
return -1; |
175 | 175 |
} |
176 | 176 |
|
... | ... |
@@ -211,7 +211,7 @@ static int print_set(MYSQL* _c, char* _b, int _l, db_key_t* _k, db_val_t* _v, in |
211 | 211 |
int l; |
212 | 212 |
|
213 | 213 |
if (!_c || !_b || !_l || !_k || !_v || !_n) { |
214 |
- LOG(L_ERR, "print_set(): Invalid parameter value\n"); |
|
214 |
+ LOG(L_ERR, "print_set: Invalid parameter value\n"); |
|
215 | 215 |
return -1; |
216 | 216 |
} |
217 | 217 |
|
... | ... |
@@ -246,13 +246,13 @@ db_con_t* db_init(const char* _url) |
246 | 246 |
db_con_t* res; |
247 | 247 |
|
248 | 248 |
if (!_url) { |
249 |
- LOG(L_ERR, "db_init(): Invalid parameter value\n"); |
|
249 |
+ LOG(L_ERR, "db_init: Invalid parameter value\n"); |
|
250 | 250 |
return 0; |
251 | 251 |
} |
252 | 252 |
|
253 | 253 |
res = pkg_malloc(sizeof(db_con_t) + sizeof(struct my_con*)); |
254 | 254 |
if (!res) { |
255 |
- LOG(L_ERR, "db_init(): No memory left\n"); |
|
255 |
+ LOG(L_ERR, "db_init: No memory left\n"); |
|
256 | 256 |
return 0; |
257 | 257 |
} |
258 | 258 |
memset(res, 0, sizeof(db_con_t) + sizeof(struct my_con*)); |
... | ... |
@@ -260,7 +260,7 @@ db_con_t* db_init(const char* _url) |
260 | 260 |
res->tail = (unsigned long)get_connection(_url); |
261 | 261 |
|
262 | 262 |
if (!res->tail) { |
263 |
- LOG(L_ERR, "db_init(): Could not create a connection\n"); |
|
263 |
+ LOG(L_ERR, "db_init: Could not create a connection\n"); |
|
264 | 264 |
pkg_free(res); |
265 | 265 |
return 0; |
266 | 266 |
} |
... | ... |
@@ -276,7 +276,7 @@ db_con_t* db_init(const char* _url) |
276 | 276 |
void db_close(db_con_t* _h) |
277 | 277 |
{ |
278 | 278 |
if (!_h) { |
279 |
- LOG(L_ERR, "db_close(): Invalid parameter value\n"); |
|
279 |
+ LOG(L_ERR, "db_close: Invalid parameter value\n"); |
|
280 | 280 |
return; |
281 | 281 |
} |
282 | 282 |
|
... | ... |
@@ -291,13 +291,13 @@ void db_close(db_con_t* _h) |
291 | 291 |
static int store_result(db_con_t* _h, db_res_t** _r) |
292 | 292 |
{ |
293 | 293 |
if ((!_h) || (!_r)) { |
294 |
- LOG(L_ERR, "store_result(): Invalid parameter value\n"); |
|
294 |
+ LOG(L_ERR, "store_result: Invalid parameter value\n"); |
|
295 | 295 |
return -1; |
296 | 296 |
} |
297 | 297 |
|
298 | 298 |
*_r = new_result(); |
299 | 299 |
if (*_r == 0) { |
300 |
- LOG(L_ERR, "store_result(): No memory left\n"); |
|
300 |
+ LOG(L_ERR, "store_result: No memory left\n"); |
|
301 | 301 |
return -2; |
302 | 302 |
} |
303 | 303 |
|
... | ... |
@@ -308,7 +308,7 @@ static int store_result(db_con_t* _h, db_res_t** _r) |
308 | 308 |
(*_r)->n = 0; |
309 | 309 |
return 0; |
310 | 310 |
} else { |
311 |
- LOG(L_ERR, "store_result(): %s\n", mysql_error(CON_CONNECTION(_h))); |
|
311 |
+ LOG(L_ERR, "store_result: %s\n", mysql_error(CON_CONNECTION(_h))); |
|
312 | 312 |
free_result(*_r); |
313 | 313 |
*_r = 0; |
314 | 314 |
return -3; |
... | ... |
@@ -316,7 +316,7 @@ static int store_result(db_con_t* _h, db_res_t** _r) |
316 | 316 |
} |
317 | 317 |
|
318 | 318 |
if (convert_result(_h, *_r) < 0) { |
319 |
- LOG(L_ERR, "store_result(): Error while converting result\n"); |
|
319 |
+ LOG(L_ERR, "store_result: Error while converting result\n"); |
|
320 | 320 |
pkg_free(*_r); |
321 | 321 |
|
322 | 322 |
/* 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) |
337 | 337 |
int db_free_result(db_con_t* _h, db_res_t* _r) |
338 | 338 |
{ |
339 | 339 |
if ((!_h) || (!_r)) { |
340 |
- LOG(L_ERR, "db_free_result(): Invalid parameter value\n"); |
|
340 |
+ LOG(L_ERR, "db_free_result: Invalid parameter value\n"); |
|
341 | 341 |
return -1; |
342 | 342 |
} |
343 | 343 |
|
344 | 344 |
if (free_result(_r) < 0) { |
345 |
- LOG(L_ERR, "db_free_result(): Unable to free result structure\n"); |
|
345 |
+ LOG(L_ERR, "db_free_result: Unable to free result structure\n"); |
|
346 | 346 |
return -1; |
347 | 347 |
} |
348 | 348 |
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, |
369 | 369 |
int off, ret; |
370 | 370 |
|
371 | 371 |
if (!_h) { |
372 |
- LOG(L_ERR, "db_query(): Invalid parameter value\n"); |
|
372 |
+ LOG(L_ERR, "db_query: Invalid parameter value\n"); |
|
373 | 373 |
return -1; |
374 | 374 |
} |
375 | 375 |
|
... | ... |
@@ -407,14 +407,14 @@ int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op, |
407 | 407 |
|
408 | 408 |
*(sql_buf + off) = '\0'; |
409 | 409 |
if (submit_query(_h, sql_buf) < 0) { |
410 |
- LOG(L_ERR, "submit_query(): Error while submitting query\n"); |
|
410 |
+ LOG(L_ERR, "db_query: Error while submitting query\n"); |
|
411 | 411 |
return -2; |
412 | 412 |
} |
413 | 413 |
|
414 | 414 |
return store_result(_h, _r); |
415 | 415 |
|
416 | 416 |
error: |
417 |
- LOG(L_ERR, "submit_query: Error in snprintf\n"); |
|
417 |
+ LOG(L_ERR, "db_query: Error in snprintf\n"); |
|
418 | 418 |
return -1; |
419 | 419 |
} |
420 | 420 |
|
... | ... |
@@ -425,12 +425,12 @@ int db_query(db_con_t* _h, db_key_t* _k, db_op_t* _op, |
425 | 425 |
int db_raw_query(db_con_t* _h, char* _s, db_res_t** _r) |
426 | 426 |
{ |
427 | 427 |
if ((!_h) || (!_s)) { |
428 |
- LOG(L_ERR, "db_raw_query(): Invalid parameter value\n"); |
|
428 |
+ LOG(L_ERR, "db_raw_query: Invalid parameter value\n"); |
|
429 | 429 |
return -1; |
430 | 430 |
} |
431 | 431 |
|
432 | 432 |
if (submit_query(_h, _s) < 0) { |
433 |
- LOG(L_ERR, "submit_query(): Error while submitting query\n"); |
|
433 |
+ LOG(L_ERR, "db_raw_query: Error while submitting query\n"); |
|
434 | 434 |
return -2; |
435 | 435 |
} |
436 | 436 |
|
... | ... |
@@ -452,7 +452,7 @@ int db_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n) |
452 | 452 |
int off, ret; |
453 | 453 |
|
454 | 454 |
if ((!_h) || (!_k) || (!_v) || (!_n)) { |
455 |
- LOG(L_ERR, "db_insert(): Invalid parameter value\n"); |
|
455 |
+ LOG(L_ERR, "db_insert: Invalid parameter value\n"); |
|
456 | 456 |
return -1; |
457 | 457 |
} |
458 | 458 |
|
... | ... |
@@ -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) |
500 | 500 |
int off, ret; |
501 | 501 |
|
502 | 502 |
if (!_h) { |
503 |
- LOG(L_ERR, "db_delete(): Invalid parameter value\n"); |
|
503 |
+ LOG(L_ERR, "db_delete: Invalid parameter value\n"); |
|
504 | 504 |
return -1; |
505 | 505 |
} |
506 | 506 |
|
... | ... |
@@ -548,7 +548,7 @@ int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, |
548 | 548 |
int off, ret; |
549 | 549 |
|
550 | 550 |
if ((!_h) || (!_uk) || (!_uv) || (!_un)) { |
551 |
- LOG(L_ERR, "db_update(): Invalid parameter value\n"); |
|
551 |
+ LOG(L_ERR, "db_update: Invalid parameter value\n"); |
|
552 | 552 |
return -1; |
553 | 553 |
} |
554 | 554 |
|
... | ... |
@@ -31,6 +31,7 @@ |
31 | 31 |
#include "my_con.h" |
32 | 32 |
#include "../../mem/mem.h" |
33 | 33 |
#include "../../dprint.h" |
34 |
+#include "../../ut.h" |
|
34 | 35 |
#include "utils.h" |
35 | 36 |
|
36 | 37 |
|
... | ... |
@@ -43,13 +44,13 @@ struct my_con* new_connection(struct my_id* id) |
43 | 44 |
struct my_con* ptr; |
44 | 45 |
|
45 | 46 |
if (!id) { |
46 |
- LOG(L_ERR, "new_connection(): Invalid parameter value\n"); |
|
47 |
+ LOG(L_ERR, "new_connection: Invalid parameter value\n"); |
|
47 | 48 |
return 0; |
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
ptr = (struct my_con*)pkg_malloc(sizeof(struct my_con)); |
51 | 52 |
if (!ptr) { |
52 |
- LOG(L_ERR, "new_connection(): No memory left\n"); |
|
53 |
+ LOG(L_ERR, "new_connection: No memory left\n"); |
|
53 | 54 |
return 0; |
54 | 55 |
} |
55 | 56 |
|
... | ... |
@@ -58,21 +59,44 @@ struct my_con* new_connection(struct my_id* id) |
58 | 59 |
|
59 | 60 |
ptr->con = (MYSQL*)pkg_malloc(sizeof(MYSQL)); |
60 | 61 |
if (!ptr->con) { |
61 |
- LOG(L_ERR, "new_connection(): No enough memory\n"); |
|
62 |
+ LOG(L_ERR, "new_connection: No enough memory\n"); |
|
62 | 63 |
goto err; |
63 | 64 |
} |
64 | 65 |
|
65 | 66 |
mysql_init(ptr->con); |
66 | 67 |
|
68 |
+ if (id->port) { |
|
69 |
+ DBG("new_connection: Opening MySQL connection: mysql://%.*s:%.*s@%.*s:%d/%.*s\n", |
|
70 |
+ id->username.len, ZSW(id->username.s), |
|
71 |
+ id->password.len, ZSW(id->password.s), |
|
72 |
+ id->host.len, ZSW(id->host.s), |
|
73 |
+ id->port, |
|
74 |
+ id->database.len, ZSW(id->database.s) |
|
75 |
+ ); |
|
76 |
+ } else { |
|
77 |
+ DBG("new_connection: Opening MySQL connection: mysql://%.*s:%.*s@%.*s/%.*s\n", |
|
78 |
+ id->username.len, ZSW(id->username.s), |
|
79 |
+ id->password.len, ZSW(id->password.s), |
|
80 |
+ id->host.len, ZSW(id->host.s), |
|
81 |
+ id->database.len, ZSW(id->database.s) |
|
82 |
+ ); |
|
83 |
+ } |
|
84 |
+ |
|
67 | 85 |
if (!mysql_real_connect(ptr->con, id->host.s, id->username.s, id->password.s, id->database.s, id->port, 0, 0)) { |
68 |
- LOG(L_ERR, "new_connection(): %s\n", mysql_error(ptr->con)); |
|
86 |
+ LOG(L_ERR, "new_connection: %s\n", mysql_error(ptr->con)); |
|
69 | 87 |
mysql_close(ptr->con); |
70 | 88 |
goto err; |
71 | 89 |
} |
72 | 90 |
|
91 |
+ DBG("new_connection: Connection type is %s\n", mysql_get_host_info(ptr->con)); |
|
92 |
+ DBG("new_connection: Protocol version is %d\n", mysql_get_proto_info(ptr->con)); |
|
93 |
+ DBG("new_connection: Server version is %s\n", mysql_get_server_info(ptr->con)); |
|
94 |
+ |
|
95 |
+ |
|
73 | 96 |
ptr->timestamp = time(0); |
74 | 97 |
|
75 | 98 |
ptr->id = id; |
99 |
+ |
|
76 | 100 |
return ptr; |
77 | 101 |
|
78 | 102 |
err: |
... | ... |
@@ -44,7 +44,7 @@ struct my_id* new_my_id(const char* url) |
44 | 44 |
struct my_id* ptr; |
45 | 45 |
|
46 | 46 |
if (!url) { |
47 |
- LOG(L_ERR, "new_my_id(): Invalid parameter\n"); |
|
47 |
+ LOG(L_ERR, "new_my_id: Invalid parameter\n"); |
|
48 | 48 |
return 0; |
49 | 49 |
} |
50 | 50 |
|
... | ... |
@@ -52,27 +52,27 @@ struct my_id* new_my_id(const char* url) |
52 | 52 |
l = strlen(url); |
53 | 53 |
buf = (char*)pkg_malloc(l + 1); |
54 | 54 |
if (!buf) { |
55 |
- LOG(L_ERR, "new_my_id(): Not enough memory\n"); |
|
55 |
+ LOG(L_ERR, "new_my_id: Not enough memory\n"); |
|
56 | 56 |
return 0; |
57 | 57 |
} |
58 | 58 |
memcpy(buf, url, l + 1); |
59 | 59 |
|
60 | 60 |
ptr = (struct my_id*)pkg_malloc(sizeof(struct my_id)); |
61 | 61 |
if (!ptr) { |
62 |
- LOG(L_ERR, "new_my_id(): No memory left\n"); |
|
62 |
+ LOG(L_ERR, "new_my_id: No memory left\n"); |
|
63 | 63 |
goto err; |
64 | 64 |
} |
65 | 65 |
memset(ptr, 0, sizeof(struct my_id)); |
66 | 66 |
|
67 | 67 |
if (parse_mysql_url(buf, &username, &password, &host, &port, &database) < 0) { |
68 |
- LOG(L_ERR, "new_my_id(): Error while parsing mysql URL: %s\n", url); |
|
68 |
+ LOG(L_ERR, "new_my_id: Error while parsing mysql URL: %s\n", url); |
|
69 | 69 |
goto err; |
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
ptr->username.len = strlen(username); |
73 | 73 |
ptr->username.s = (char*)pkg_malloc(ptr->username.len + 1); |
74 | 74 |
if (!ptr->username.s) { |
75 |
- LOG(L_ERR, "new_connection(): No memory left\n"); |
|
75 |
+ LOG(L_ERR, "new_my_id: No memory left\n"); |
|
76 | 76 |
goto err; |
77 | 77 |
} |
78 | 78 |
memcpy(ptr->username.s, username, ptr->username.len + 1); |
... | ... |
@@ -81,7 +81,7 @@ struct my_id* new_my_id(const char* url) |
81 | 81 |
ptr->password.len = strlen(password); |
82 | 82 |
ptr->password.s = (char*)pkg_malloc(ptr->password.len + 1); |
83 | 83 |
if (!ptr->password.s) { |
84 |
- LOG(L_ERR, "new_connection(): No memory left\n"); |
|
84 |
+ LOG(L_ERR, "new_my_id: No memory left\n"); |
|
85 | 85 |
goto err; |
86 | 86 |
} |
87 | 87 |
memcpy(ptr->password.s, password, ptr->password.len + 1); |
... | ... |
@@ -90,7 +90,7 @@ struct my_id* new_my_id(const char* url) |
90 | 90 |
ptr->host.len = strlen(host); |
91 | 91 |
ptr->host.s = (char*)pkg_malloc(ptr->host.len + 1); |
92 | 92 |
if (!ptr->host.s) { |
93 |
- LOG(L_ERR, "new_connection(): No memory left\n"); |
|
93 |
+ LOG(L_ERR, "new_my_id: No memory left\n"); |
|
94 | 94 |
goto err; |
95 | 95 |
} |
96 | 96 |
memcpy(ptr->host.s, host, ptr->host.len + 1); |
... | ... |
@@ -104,7 +104,7 @@ struct my_id* new_my_id(const char* url) |
104 | 104 |
ptr->database.len = strlen(database); |
105 | 105 |
ptr->database.s = (char*)pkg_malloc(ptr->database.len + 1); |
106 | 106 |
if (!ptr->database.s) { |
107 |
- LOG(L_ERR, "new_connection(): No memory left\n"); |
|
107 |
+ LOG(L_ERR, "new_my_id: No memory left\n"); |
|
108 | 108 |
goto err; |
109 | 109 |
} |
110 | 110 |
memcpy(ptr->database.s, database, ptr->database.len + 1); |
... | ... |
@@ -54,13 +54,13 @@ struct my_con* get_connection(const char* url) |
54 | 54 |
int pid; |
55 | 55 |
|
56 | 56 |
if (!url) { |
57 |
- LOG(L_ERR, "get_connection(): Invalid parameter value\n"); |
|
57 |
+ LOG(L_ERR, "get_connection: Invalid parameter value\n"); |
|
58 | 58 |
return 0; |
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
pid = getpid(); |
62 | 62 |
if (pool && (pool_pid != pid)) { |
63 |
- LOG(L_ERR, "get_connection(): Inherited open database connections, this is not a good idea\n"); |
|
63 |
+ LOG(L_ERR, "get_connection: Inherited open database connections, this is not a good idea\n"); |
|
64 | 64 |
return 0; |
65 | 65 |
} |
66 | 66 |
|
... | ... |
@@ -72,7 +72,7 @@ struct my_con* get_connection(const char* url) |
72 | 72 |
ptr = pool; |
73 | 73 |
while (ptr) { |
74 | 74 |
if (cmp_my_id(id, ptr->id)) { |
75 |
- DBG("get_connection(): Connection found in the pool\n"); |
|
75 |
+ DBG("get_connection: Connection found in the pool\n"); |
|
76 | 76 |
ptr->ref++; |
77 | 77 |
free_my_id(id); |
78 | 78 |
return ptr; |
... | ... |
@@ -80,7 +80,7 @@ struct my_con* get_connection(const char* url) |
80 | 80 |
ptr = ptr->next; |
81 | 81 |
} |
82 | 82 |
|
83 |
- DBG("get_connection(): Connection not found in the pool\n"); |
|
83 |
+ DBG("get_connection: Connection not found in the pool\n"); |
|
84 | 84 |
ptr = new_connection(id); |
85 | 85 |
if (!ptr) { |
86 | 86 |
free_my_id(id); |
... | ... |
@@ -108,12 +108,12 @@ void release_connection(struct my_con* con) |
108 | 108 |
/* There are still other users, just |
109 | 109 |
* decrease the reference count and return |
110 | 110 |
*/ |
111 |
- DBG("release_connection(): Connection still kept in the pool\n"); |
|
111 |
+ DBG("release_connection: Connection still kept in the pool\n"); |
|
112 | 112 |
con->ref--; |
113 | 113 |
return; |
114 | 114 |
} |
115 | 115 |
|
116 |
- DBG("release_connection(): Removing connection from the pool\n"); |
|
116 |
+ DBG("release_connection: Removing connection from the pool\n"); |
|
117 | 117 |
|
118 | 118 |
if (pool == con) { |
119 | 119 |
pool = pool->next; |
... | ... |
@@ -124,7 +124,7 @@ void release_connection(struct my_con* con) |
124 | 124 |
ptr = ptr->next; |
125 | 125 |
} |
126 | 126 |
if (!ptr) { |
127 |
- LOG(L_ERR, "release_connection(): Weird, connection not found in the pool\n"); |
|
127 |
+ LOG(L_ERR, "release_connection: Weird, connection not found in the pool\n"); |
|
128 | 128 |
} else { |
129 | 129 |
/* Remove the connection from the pool */ |
130 | 130 |
ptr->next = con->next; |
... | ... |
@@ -45,25 +45,25 @@ static inline int get_columns(db_con_t* _h, db_res_t* _r) |
45 | 45 |
MYSQL_FIELD* fields; |
46 | 46 |
|
47 | 47 |
if ((!_h) || (!_r)) { |
48 |
- LOG(L_ERR, "get_columns(): Invalid parameter\n"); |
|
48 |
+ LOG(L_ERR, "get_columns: Invalid parameter\n"); |
|
49 | 49 |
return -1; |
50 | 50 |
} |
51 | 51 |
|
52 | 52 |
n = mysql_field_count(CON_CONNECTION(_h)); |
53 | 53 |
if (!n) { |
54 |
- LOG(L_ERR, "get_columns(): No columns\n"); |
|
54 |
+ LOG(L_ERR, "get_columns: No columns\n"); |
|
55 | 55 |
return -2; |
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
RES_NAMES(_r) = (db_key_t*)pkg_malloc(sizeof(db_key_t) * n); |
59 | 59 |
if (!RES_NAMES(_r)) { |
60 |
- LOG(L_ERR, "get_columns(): No memory left\n"); |
|
60 |
+ LOG(L_ERR, "get_columns: No memory left\n"); |
|
61 | 61 |
return -3; |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
RES_TYPES(_r) = (db_type_t*)pkg_malloc(sizeof(db_type_t) * n); |
65 | 65 |
if (!RES_TYPES(_r)) { |
66 |
- LOG(L_ERR, "get_columns(): No memory left\n"); |
|
66 |
+ LOG(L_ERR, "get_columns: No memory left\n"); |
|
67 | 67 |
pkg_free(RES_NAMES(_r)); |
68 | 68 |
return -4; |
69 | 69 |
} |
... | ... |
@@ -119,7 +119,7 @@ static inline int free_rows(db_res_t* _r) |
119 | 119 |
int i; |
120 | 120 |
|
121 | 121 |
if (!_r) { |
122 |
- LOG(L_ERR, "free_rows(): Invalid parameter value\n"); |
|
122 |
+ LOG(L_ERR, "free_rows: Invalid parameter value\n"); |
|
123 | 123 |
return -1; |
124 | 124 |
} |
125 | 125 |
|
... | ... |
@@ -139,7 +139,7 @@ static inline int convert_rows(db_con_t* _h, db_res_t* _r) |
139 | 139 |
int n, i; |
140 | 140 |
|
141 | 141 |
if ((!_h) || (!_r)) { |
142 |
- LOG(L_ERR, "convert_rows(): Invalid parameter\n"); |
|
142 |
+ LOG(L_ERR, "convert_rows: Invalid parameter\n"); |
|
143 | 143 |
return -1; |
144 | 144 |
} |
145 | 145 |
|
... | ... |
@@ -151,20 +151,20 @@ static inline int convert_rows(db_con_t* _h, db_res_t* _r) |
151 | 151 |
} |
152 | 152 |
RES_ROWS(_r) = (struct db_row*)pkg_malloc(sizeof(db_row_t) * n); |
153 | 153 |
if (!RES_ROWS(_r)) { |
154 |
- LOG(L_ERR, "convert_rows(): No memory left\n"); |
|
154 |
+ LOG(L_ERR, "convert_rows: No memory left\n"); |
|
155 | 155 |
return -2; |
156 | 156 |
} |
157 | 157 |
|
158 | 158 |
for(i = 0; i < n; i++) { |
159 | 159 |
CON_ROW(_h) = mysql_fetch_row(CON_RESULT(_h)); |
160 | 160 |
if (!CON_ROW(_h)) { |
161 |
- LOG(L_ERR, "convert_rows(): %s\n", mysql_error(CON_CONNECTION(_h))); |
|
161 |
+ LOG(L_ERR, "convert_rows: %s\n", mysql_error(CON_CONNECTION(_h))); |
|
162 | 162 |
RES_ROW_N(_r) = i; |
163 | 163 |
free_rows(_r); |
164 | 164 |
return -3; |
165 | 165 |
} |
166 | 166 |
if (convert_row(_h, _r, &(RES_ROWS(_r)[i])) < 0) { |
167 |
- LOG(L_ERR, "convert_rows(): Error while converting row #%d\n", i); |
|
167 |
+ LOG(L_ERR, "convert_rows: Error while converting row #%d\n", i); |
|
168 | 168 |
RES_ROW_N(_r) = i; |
169 | 169 |
free_rows(_r); |
170 | 170 |
return -4; |
... | ... |
@@ -180,7 +180,7 @@ static inline int convert_rows(db_con_t* _h, db_res_t* _r) |
180 | 180 |
static inline int free_columns(db_res_t* _r) |
181 | 181 |
{ |
182 | 182 |
if (!_r) { |
183 |
- LOG(L_ERR, "free_columns(): Invalid parameter\n"); |
|
183 |
+ LOG(L_ERR, "free_columns: Invalid parameter\n"); |
|
184 | 184 |
return -1; |
185 | 185 |
} |
186 | 186 |
|
... | ... |
@@ -198,7 +198,7 @@ db_res_t* new_result(void) |
198 | 198 |
db_res_t* r; |
199 | 199 |
r = (db_res_t*)pkg_malloc(sizeof(db_res_t)); |
200 | 200 |
if (!r) { |
201 |
- LOG(L_ERR, "new_result(): No memory left\n"); |
|
201 |
+ LOG(L_ERR, "new_result: No memory left\n"); |
|
202 | 202 |
return 0; |
203 | 203 |
} |
204 | 204 |
RES_NAMES(r) = 0; |
... | ... |
@@ -216,17 +216,17 @@ db_res_t* new_result(void) |
216 | 216 |
int convert_result(db_con_t* _h, db_res_t* _r) |
217 | 217 |
{ |
218 | 218 |
if ((!_h) || (!_r)) { |
219 |
- LOG(L_ERR, "convert_result(): Invalid parameter\n"); |
|
219 |
+ LOG(L_ERR, "convert_result: Invalid parameter\n"); |
|
220 | 220 |
return -1; |
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
if (get_columns(_h, _r) < 0) { |
224 |
- LOG(L_ERR, "convert_result(): Error while getting column names\n"); |
|
224 |
+ LOG(L_ERR, "convert_result: Error while getting column names\n"); |
|
225 | 225 |
return -2; |
226 | 226 |
} |
227 | 227 |
|
228 | 228 |
if (convert_rows(_h, _r) < 0) { |
229 |
- LOG(L_ERR, "convert_result(): Error while converting rows\n"); |
|
229 |
+ LOG(L_ERR, "convert_result: Error while converting rows\n"); |
|
230 | 230 |
free_columns(_r); |
231 | 231 |
return -3; |
232 | 232 |
} |
... | ... |
@@ -240,7 +240,7 @@ int convert_result(db_con_t* _h, db_res_t* _r) |
240 | 240 |
int free_result(db_res_t* _r) |
241 | 241 |
{ |
242 | 242 |
if (!_r) { |
243 |
- LOG(L_ERR, "free_result(): Invalid parameter\n"); |
|
243 |
+ LOG(L_ERR, "free_result: Invalid parameter\n"); |
|
244 | 244 |
return -1; |
245 | 245 |
} |
246 | 246 |
|
... | ... |
@@ -45,14 +45,14 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r) |
45 | 45 |
int i; |
46 | 46 |
|
47 | 47 |
if ((!_h) || (!_res) || (!_r)) { |
48 |
- LOG(L_ERR, "convert_row(): Invalid parameter value\n"); |
|
48 |
+ LOG(L_ERR, "convert_row: Invalid parameter value\n"); |
|
49 | 49 |
return -1; |
50 | 50 |
} |
51 | 51 |
|
52 | 52 |
ROW_VALUES(_r) = (db_val_t*)pkg_malloc(sizeof(db_val_t) * RES_COL_N(_res)); |
53 | 53 |
ROW_N(_r) = RES_COL_N(_res); |
54 | 54 |
if (!ROW_VALUES(_r)) { |
55 |
- LOG(L_ERR, "convert_row(): No memory left\n"); |
|
55 |
+ LOG(L_ERR, "convert_row: No memory left\n"); |
|
56 | 56 |
return -1; |
57 | 57 |
} |
58 | 58 |
|
... | ... |
@@ -61,7 +61,7 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r) |
61 | 61 |
for(i = 0; i < RES_COL_N(_res); i++) { |
62 | 62 |
if (str2val(RES_TYPES(_res)[i], &(ROW_VALUES(_r)[i]), |
63 | 63 |
((MYSQL_ROW)CON_ROW(_h))[i], lengths[i]) < 0) { |
64 |
- LOG(L_ERR, "convert_row(): Error while converting value\n"); |
|
64 |
+ LOG(L_ERR, "convert_row: Error while converting value\n"); |
|
65 | 65 |
free_row(_r); |
66 | 66 |
return -3; |
67 | 67 |
} |
... | ... |
@@ -76,7 +76,7 @@ int convert_row(db_con_t* _h, db_res_t* _res, db_row_t* _r) |
76 | 76 |
int free_row(db_row_t* _r) |
77 | 77 |
{ |
78 | 78 |
if (!_r) { |
79 |
- LOG(L_ERR, "free_row(): Invalid parameter value\n"); |
|
79 |
+ LOG(L_ERR, "free_row: Invalid parameter value\n"); |
|
80 | 80 |
return -1; |
81 | 81 |
} |
82 | 82 |
|
... | ... |
@@ -39,7 +39,7 @@ |
39 | 39 |
static inline int str2int(const char* _s, int* _v) |
40 | 40 |
{ |
41 | 41 |
if ((!_s) || (!_v)) { |
42 |
- LOG(L_ERR, "str2int(): Invalid parameter value\n"); |
|
42 |
+ LOG(L_ERR, "str2int: Invalid parameter value\n"); |
|
43 | 43 |
return -1; |
44 | 44 |
} |
45 | 45 |
|
... | ... |
@@ -54,7 +54,7 @@ static inline int str2int(const char* _s, int* _v) |
54 | 54 |
static inline int str2double(const char* _s, double* _v) |
55 | 55 |
{ |
56 | 56 |
if ((!_s) || (!_v)) { |
57 |
- LOG(L_ERR, "str2double(): Invalid parameter value\n"); |
|
57 |
+ LOG(L_ERR, "str2double: Invalid parameter value\n"); |
|
58 | 58 |
return -1; |
59 | 59 |
} |
60 | 60 |
|
... | ... |
@@ -69,7 +69,7 @@ static inline int str2double(const char* _s, double* _v) |
69 | 69 |
static inline int str2time(const char* _s, time_t* _v) |
70 | 70 |
{ |
71 | 71 |
if ((!_s) || (!_v)) { |
72 |
- LOG(L_ERR, "str2time(): Invalid parameter value\n"); |
|
72 |
+ LOG(L_ERR, "str2time: Invalid parameter value\n"); |
|
73 | 73 |
return -1; |
74 | 74 |
} |
75 | 75 |
|
... | ... |
@@ -86,7 +86,7 @@ static inline int int2str(int _v, char* _s, int* _l) |
86 | 86 |
int ret; |
87 | 87 |
|
88 | 88 |
if ((!_s) || (!_l) || (!*_l)) { |
89 |
- LOG(L_ERR, "int2str(): Invalid parameter value\n"); |
|
89 |
+ LOG(L_ERR, "int2str: Invalid parameter value\n"); |
|
90 | 90 |
return -1; |
91 | 91 |
} |
92 | 92 |
|
... | ... |
@@ -109,7 +109,7 @@ static inline int double2str(double _v, char* _s, int* _l) |
109 | 109 |
int ret; |
110 | 110 |
|
111 | 111 |
if ((!_s) || (!_l) || (!*_l)) { |
112 |
- LOG(L_ERR, "double2str(): Invalid parameter value\n"); |
|
112 |
+ LOG(L_ERR, "double2str: Invalid parameter value\n"); |
|
113 | 113 |
return -1; |
114 | 114 |
} |
115 | 115 |
|
... | ... |
@@ -132,7 +132,7 @@ static inline int time2str(time_t _v, char* _s, int* _l) |
132 | 132 |
int l; |
133 | 133 |
|
134 | 134 |
if ((!_s) || (!_l) || (*_l < 2)) { |
135 |
- LOG(L_ERR, "Invalid parameter value\n"); |
|
135 |
+ LOG(L_ERR, "time2str: Invalid parameter value\n"); |
|
136 | 136 |
return -1; |
137 | 137 |
} |
138 | 138 |
|
... | ... |
@@ -149,7 +149,7 @@ static inline int time2str(time_t _v, char* _s, int* _l) |
149 | 149 |
int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l) |
150 | 150 |
{ |
151 | 151 |
if (!_v) { |
152 |
- LOG(L_ERR, "str2val(): Invalid parameter value\n"); |
|
152 |
+ LOG(L_ERR, "str2val: Invalid parameter value\n"); |
|
153 | 153 |
return -1; |
154 | 154 |
} |
155 | 155 |
|
... | ... |
@@ -164,7 +164,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l) |
164 | 164 |
switch(_t) { |
165 | 165 |
case DB_INT: |
166 | 166 |
if (str2int(_s, &VAL_INT(_v)) < 0) { |
167 |
- LOG(L_ERR, "str2val(): Error while converting integer value from string\n"); |
|
167 |
+ LOG(L_ERR, "str2val: Error while converting integer value from string\n"); |
|
168 | 168 |
return -2; |
169 | 169 |
} else { |
170 | 170 |
VAL_TYPE(_v) = DB_INT; |
... | ... |
@@ -174,7 +174,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l) |
174 | 174 |
|
175 | 175 |
case DB_BITMAP: |
176 | 176 |
if (str2int(_s, &VAL_INT(_v)) < 0) { |
177 |
- LOG(L_ERR, "str2val(): Error while converting bitmap value from string\n"); |
|
177 |
+ LOG(L_ERR, "str2val: Error while converting bitmap value from string\n"); |
|
178 | 178 |
return -3; |
179 | 179 |
} else { |
180 | 180 |
VAL_TYPE(_v) = DB_BITMAP; |
... | ... |
@@ -184,7 +184,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l) |
184 | 184 |
|
185 | 185 |
case DB_DOUBLE: |
186 | 186 |
if (str2double(_s, &VAL_DOUBLE(_v)) < 0) { |
187 |
- LOG(L_ERR, "str2val(): Error while converting double value from string\n"); |
|
187 |
+ LOG(L_ERR, "str2val: Error while converting double value from string\n"); |
|
188 | 188 |
return -4; |
189 | 189 |
} else { |
190 | 190 |
VAL_TYPE(_v) = DB_DOUBLE; |
... | ... |
@@ -205,7 +205,7 @@ int str2val(db_type_t _t, db_val_t* _v, const char* _s, int _l) |
205 | 205 |
|
206 | 206 |
case DB_DATETIME: |
207 | 207 |
if (str2time(_s, &VAL_TIME(_v)) < 0) { |
208 |
- LOG(L_ERR, "str2val(): Error while converting datetime value from string\n"); |
|
208 |
+ LOG(L_ERR, "str2val: Error while converting datetime value from string\n"); |
|
209 | 209 |
return -5; |
210 | 210 |
} else { |
211 | 211 |
VAL_TYPE(_v) = DB_DATETIME; |
... | ... |
@@ -232,7 +232,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
232 | 232 |
char* old_s; |
233 | 233 |
|
234 | 234 |
if (!_c || !_v || !_s || !_len || !*_len) { |
235 |
- LOG(L_ERR, "val2str(): Invalid parameter value\n"); |
|
235 |
+ LOG(L_ERR, "val2str: Invalid parameter value\n"); |
|
236 | 236 |
return -1; |
237 | 237 |
} |
238 | 238 |
|
... | ... |
@@ -248,7 +248,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
248 | 248 |
switch(VAL_TYPE(_v)) { |
249 | 249 |
case DB_INT: |
250 | 250 |
if (int2str(VAL_INT(_v), _s, _len) < 0) { |
251 |
- LOG(L_ERR, "val2str(): Error while converting string to int\n"); |
|
251 |
+ LOG(L_ERR, "val2str: Error while converting string to int\n"); |
|
252 | 252 |
return -2; |
253 | 253 |
} else { |
254 | 254 |
return 0; |
... | ... |
@@ -257,7 +257,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
257 | 257 |
|
258 | 258 |
case DB_BITMAP: |
259 | 259 |
if (int2str(VAL_BITMAP(_v), _s, _len) < 0) { |
260 |
- LOG(L_ERR, "val2str(): Error while converting string to int\n"); |
|
260 |
+ LOG(L_ERR, "val2str: Error while converting string to int\n"); |
|
261 | 261 |
return -3; |
262 | 262 |
} else { |
263 | 263 |
return 0; |
... | ... |
@@ -266,7 +266,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
266 | 266 |
|
267 | 267 |
case DB_DOUBLE: |
268 | 268 |
if (double2str(VAL_DOUBLE(_v), _s, _len) < 0) { |
269 |
- LOG(L_ERR, "val2str(): Error while converting string to double\n"); |
|
269 |
+ LOG(L_ERR, "val2str: Error while converting string to double\n"); |
|
270 | 270 |
return -4; |
271 | 271 |
} else { |
272 | 272 |
return 0; |
... | ... |
@@ -276,7 +276,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
276 | 276 |
case DB_STRING: |
277 | 277 |
l = strlen(VAL_STRING(_v)); |
278 | 278 |
if (*_len < (l * 2 + 3)) { |
279 |
- LOG(L_ERR, "val2str(): Destination buffer too short\n"); |
|
279 |
+ LOG(L_ERR, "val2str: Destination buffer too short\n"); |
|
280 | 280 |
return -5; |
281 | 281 |
} else { |
282 | 282 |
old_s = _s; |
... | ... |
@@ -292,7 +292,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
292 | 292 |
case DB_STR: |
293 | 293 |
l = VAL_STR(_v).len; |
294 | 294 |
if (*_len < (l * 2 + 3)) { |
295 |
- LOG(L_ERR, "val2str(): Destination buffer too short\n"); |
|
295 |
+ LOG(L_ERR, "val2str: Destination buffer too short\n"); |
|
296 | 296 |
return -6; |
297 | 297 |
} else { |
298 | 298 |
old_s = _s; |
... | ... |
@@ -307,7 +307,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
307 | 307 |
|
308 | 308 |
case DB_DATETIME: |
309 | 309 |
if (time2str(VAL_TIME(_v), _s, _len) < 0) { |
310 |
- LOG(L_ERR, "val2str(): Error while converting string to time_t\n"); |
|
310 |
+ LOG(L_ERR, "val2str: Error while converting string to time_t\n"); |
|
311 | 311 |
return -7; |
312 | 312 |
} else { |
313 | 313 |
return 0; |
... | ... |
@@ -317,7 +317,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
317 | 317 |
case DB_BLOB: |
318 | 318 |
l = VAL_BLOB(_v).len; |
319 | 319 |
if (*_len < (l * 2 + 3)) { |
320 |
- LOG(L_ERR, "val2str(): Destination buffer too short\n"); |
|
320 |
+ LOG(L_ERR, "val2str: Destination buffer too short\n"); |
|
321 | 321 |
return -8; |
322 | 322 |
} else { |
323 | 323 |
old_s = _s; |
... | ... |
@@ -331,7 +331,7 @@ int val2str(MYSQL* _c, db_val_t* _v, char* _s, int* _len) |
331 | 331 |
break; |
332 | 332 |
|
333 | 333 |
default: |
334 |
- DBG("val2str(): Unknown data type\n"); |
|
334 |
+ DBG("val2str: Unknown data type\n"); |
|
335 | 335 |
return -9; |
336 | 336 |
} |
337 | 337 |
/*return -8; --not reached*/ |