1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
diff --git a/lib/srdb1/db_query.c b/lib/srdb1/db_query.c
index dbde735..8efc15c 100644
--- a/lib/srdb1/db_query.c
+++ b/lib/srdb1/db_query.c
@@ -54,6 +54,10 @@ int db_do_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
LM_ERR("invalid parameter value\n");
return -1;
}
+ if (sql_buf == NULL) {
+ if (db_query_init() != 0)
+ return -2;
+ }
if (!_c) {
ret = snprintf(sql_buf, sql_buffer_size, "select * from %.*s ", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
@@ -154,6 +158,10 @@ int db_do_insert_cmd(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v
LM_ERR("invalid parameter value\n");
return -1;
}
+ if (sql_buf == NULL) {
+ if (db_query_init() != 0)
+ return -2;
+ }
if(mode==1)
ret = snprintf(sql_buf, sql_buffer_size, "insert delayed into %.*s (",
@@ -218,6 +226,10 @@ int db_do_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
LM_ERR("invalid parameter value\n");
return -1;
}
+ if (sql_buf == NULL) {
+ if (db_query_init() != 0)
+ return -2;
+ }
ret = snprintf(sql_buf, sql_buffer_size, "delete from %.*s", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= sql_buffer_size) goto error;
@@ -261,6 +273,10 @@ int db_do_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
LM_ERR("invalid parameter value\n");
return -1;
}
+ if (sql_buf == NULL) {
+ if (db_query_init() != 0)
+ return -2;
+ }
ret = snprintf(sql_buf, sql_buffer_size, "update %.*s set ", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= sql_buffer_size) goto error;
@@ -306,6 +322,10 @@ int db_do_replace(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
LM_ERR("invalid parameter value\n");
return -1;
}
+ if (sql_buf == NULL) {
+ if (db_query_init() != 0)
+ return -2;
+ }
ret = snprintf(sql_buf, sql_buffer_size, "replace %.*s (", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
if (ret < 0 || ret >= sql_buffer_size) goto error;
|