|
@@ -38,7 +38,7 @@
|
|
#include "dbcl_api.h"
|
|
#include "dbcl_api.h"
|
|
|
|
|
|
|
|
|
|
-#define DBCL_READ(command) \
|
|
|
|
|
|
+#define DBCL_READ(qfunc, command) \
|
|
do {\
|
|
do {\
|
|
int ret;\
|
|
int ret;\
|
|
int i;\
|
|
int i;\
|
|
@@ -61,6 +61,10 @@
|
|
LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
|
|
LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
dbh = cls->rlist[i].clist[j]->dbh;\
|
|
dbh = cls->rlist[i].clist[j]->dbh;\
|
|
|
|
+ if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\
|
|
|
|
+ LM_ERR("unsupported command by db connector\n");\
|
|
|
|
+ return -1;\
|
|
|
|
+ }\
|
|
ret = cls->rlist[i].clist[j]->dbf.command;\
|
|
ret = cls->rlist[i].clist[j]->dbf.command;\
|
|
if (ret==0) {\
|
|
if (ret==0) {\
|
|
cls->usedcon = cls->rlist[i].clist[j];\
|
|
cls->usedcon = cls->rlist[i].clist[j];\
|
|
@@ -84,6 +88,10 @@
|
|
LM_DBG("round robin operation - cluster [%.*s] (%d/%d)\n",\
|
|
LM_DBG("round robin operation - cluster [%.*s] (%d/%d)\n",\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
dbh = cls->rlist[i].clist[j]->dbh;\
|
|
dbh = cls->rlist[i].clist[j]->dbh;\
|
|
|
|
+ if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\
|
|
|
|
+ LM_ERR("unsupported command by db connector\n");\
|
|
|
|
+ return -1;\
|
|
|
|
+ }\
|
|
ret = cls->rlist[i].clist[j]->dbf.command;\
|
|
ret = cls->rlist[i].clist[j]->dbf.command;\
|
|
if (ret==0)\
|
|
if (ret==0)\
|
|
{\
|
|
{\
|
|
@@ -110,7 +118,7 @@
|
|
return ret;\
|
|
return ret;\
|
|
} while(0)
|
|
} while(0)
|
|
|
|
|
|
-#define DBCL_WRITE(command) \
|
|
|
|
|
|
+#define DBCL_WRITE(qfunc, command) \
|
|
do {\
|
|
do {\
|
|
int ret;\
|
|
int ret;\
|
|
int rc;\
|
|
int rc;\
|
|
@@ -137,6 +145,10 @@
|
|
LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
|
|
LM_DBG("serial operation - cluster [%.*s] (%d/%d)\n",\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
|
|
+ if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\
|
|
|
|
+ LM_ERR("unsupported command by db connector\n");\
|
|
|
|
+ return -1;\
|
|
|
|
+ }\
|
|
ret = cls->wlist[i].clist[j]->dbf.command;\
|
|
ret = cls->wlist[i].clist[j]->dbf.command;\
|
|
if (ret==0) {\
|
|
if (ret==0) {\
|
|
cls->usedcon = cls->wlist[i].clist[j];\
|
|
cls->usedcon = cls->wlist[i].clist[j];\
|
|
@@ -160,6 +172,10 @@
|
|
LM_DBG("round robin operation - cluster [%.*s] (%d/%d)\n",\
|
|
LM_DBG("round robin operation - cluster [%.*s] (%d/%d)\n",\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
|
|
+ if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\
|
|
|
|
+ LM_ERR("unsupported command by db connector\n");\
|
|
|
|
+ return -1;\
|
|
|
|
+ }\
|
|
ret = cls->wlist[i].clist[j]->dbf.command;\
|
|
ret = cls->wlist[i].clist[j]->dbf.command;\
|
|
if (ret==0)\
|
|
if (ret==0)\
|
|
{\
|
|
{\
|
|
@@ -184,6 +200,10 @@
|
|
LM_DBG("parallel operation - cluster [%.*s] (%d/%d)\n",\
|
|
LM_DBG("parallel operation - cluster [%.*s] (%d/%d)\n",\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
cls->name.len, cls->name.s, i, j);\
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
dbh = cls->wlist[i].clist[j]->dbh;\
|
|
|
|
+ if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\
|
|
|
|
+ LM_ERR("unsupported command by db connector\n");\
|
|
|
|
+ return -1;\
|
|
|
|
+ }\
|
|
rc = cls->wlist[i].clist[j]->dbf.command;\
|
|
rc = cls->wlist[i].clist[j]->dbf.command;\
|
|
if(rc==0) {\
|
|
if(rc==0) {\
|
|
cls->usedcon = cls->wlist[i].clist[j];\
|
|
cls->usedcon = cls->wlist[i].clist[j];\
|
|
@@ -297,7 +317,7 @@ int db_cluster_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op
|
|
const db_key_t _o, db1_res_t** _r)
|
|
const db_key_t _o, db1_res_t** _r)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster query command\n");
|
|
LM_DBG("executing db cluster query command\n");
|
|
- DBCL_READ(query(dbh, _k, _op, _v, _c, _n, _nc, _o, _r));
|
|
|
|
|
|
+ DBCL_READ(query, query(dbh, _k, _op, _v, _c, _n, _nc, _o, _r));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -322,7 +342,7 @@ int db_cluster_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows
|
|
int db_cluster_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
|
|
int db_cluster_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster raw query command\n");
|
|
LM_DBG("executing db cluster raw query command\n");
|
|
- DBCL_READ(raw_query(dbh, _s, _r));
|
|
|
|
|
|
+ DBCL_READ(raw_query, raw_query(dbh, _s, _r));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -332,7 +352,7 @@ int db_cluster_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
|
|
int db_cluster_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n)
|
|
int db_cluster_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster insert command\n");
|
|
LM_DBG("executing db cluster insert command\n");
|
|
- DBCL_WRITE(insert(dbh, _k, _v, _n));
|
|
|
|
|
|
+ DBCL_WRITE(insert, insert(dbh, _k, _v, _n));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -343,7 +363,7 @@ int db_cluster_delete(const db1_con_t* _h, const db_key_t* _k, const
|
|
db_op_t* _o, const db_val_t* _v, const int _n)
|
|
db_op_t* _o, const db_val_t* _v, const int _n)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster delete command\n");
|
|
LM_DBG("executing db cluster delete command\n");
|
|
- DBCL_WRITE(delete(dbh, _k, _o, _v, _n));
|
|
|
|
|
|
+ DBCL_WRITE(delete, delete(dbh, _k, _o, _v, _n));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -355,7 +375,7 @@ int db_cluster_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o
|
|
const int _un)
|
|
const int _un)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster update command\n");
|
|
LM_DBG("executing db cluster update command\n");
|
|
- DBCL_WRITE(update(dbh, _k, _o, _v, _uk, _uv, _n, _un));
|
|
|
|
|
|
+ DBCL_WRITE(update, update(dbh, _k, _o, _v, _uk, _uv, _n, _un));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -366,7 +386,7 @@ int db_cluster_replace(const db1_con_t* _h, const db_key_t* _k,
|
|
const db_val_t* _v, const int _n, const int _un, const int _m)
|
|
const db_val_t* _v, const int _n, const int _un, const int _m)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster replace command\n");
|
|
LM_DBG("executing db cluster replace command\n");
|
|
- DBCL_WRITE(replace(dbh, _k, _v, _n, _un, _m));
|
|
|
|
|
|
+ DBCL_WRITE(replace, replace(dbh, _k, _v, _n, _un, _m));
|
|
}
|
|
}
|
|
|
|
|
|
/*! \brief
|
|
/*! \brief
|
|
@@ -406,7 +426,7 @@ int db_cluster_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_v
|
|
const int _n)
|
|
const int _n)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster insert-update command\n");
|
|
LM_DBG("executing db cluster insert-update command\n");
|
|
- DBCL_WRITE(insert_update(dbh, _k, _v, _n));
|
|
|
|
|
|
+ DBCL_WRITE(insert_update, insert_update(dbh, _k, _v, _n));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -417,7 +437,7 @@ int db_cluster_insert_delayed(const db1_con_t* _h, const db_key_t* _k,
|
|
const db_val_t* _v, const int _n)
|
|
const db_val_t* _v, const int _n)
|
|
{
|
|
{
|
|
LM_DBG("executing db cluster insert delayed command\n");
|
|
LM_DBG("executing db cluster insert delayed command\n");
|
|
- DBCL_WRITE(insert_delayed(dbh, _k, _v, _n));
|
|
|
|
|
|
+ DBCL_WRITE(insert_delayed, insert_delayed(dbh, _k, _v, _n));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|