[sr-dev] git:5.0:ebc29b28: db_oracle: fix raw sql queries
Ovidiu Sas
osas at voipembedded.com
Fri Apr 21 18:35:37 CEST 2017
Module: kamailio
Branch: 5.0
Commit: ebc29b28d187527389349c1b1d9d69dcb97d66d0
URL: https://github.com/kamailio/kamailio/commit/ebc29b28d187527389349c1b1d9d69dcb97d66d0
Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date: 2017-04-21T12:35:20-04:00
db_oracle: fix raw sql queries
(cherry picked from commit 5d75450e2a05a029d51ab38c3ef6f36fef49a51b)
---
Modified: src/modules/db_oracle/dbase.c
Modified: src/modules/db_oracle/res.c
---
Diff: https://github.com/kamailio/kamailio/commit/ebc29b28d187527389349c1b1d9d69dcb97d66d0.diff
Patch: https://github.com/kamailio/kamailio/commit/ebc29b28d187527389349c1b1d9d69dcb97d66d0.patch
---
diff --git a/src/modules/db_oracle/dbase.c b/src/modules/db_oracle/dbase.c
index eb400df..a4d54b9 100644
--- a/src/modules/db_oracle/dbase.c
+++ b/src/modules/db_oracle/dbase.c
@@ -216,7 +216,7 @@ static int db_oracle_submit_query(const db1_con_t* _h, const str* _s)
(unsigned)hc);
return -1;
}
-
+
if (!pqd->_rs) {
/*
* This method is at ~25% faster as set OCI_COMMIT_ON_SUCCESS
@@ -373,8 +373,7 @@ int db_oracle_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
int len;
const char *p;
- if (!_h || !_s || !_s->s) {
-badparam:
+ if (!_h || !_r || !_s || !_s->s) {
LM_ERR("invalid parameter value\n");
return -1;
}
@@ -387,7 +386,6 @@ int db_oracle_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
while (len && *p == ' ') ++p, --len;
#define _S_DIFF(p, l, S) (l <= sizeof(S)-1 || strncasecmp(p, S, sizeof(S)-1))
if (!_S_DIFF(p, len, "select ")) {
- if (!_r) goto badparam;
cb._rs = &reshp;
} else {
if ( _S_DIFF(p, len, "insert ")
@@ -398,10 +396,11 @@ int db_oracle_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r)
return -2;
}
#undef _S_DIFF
- if (_r) goto badparam;
cb._rs = NULL;
}
+ CON_ORA(_h)->pqdata = &cb;
+ CON_ORA(_h)->bindpos = 0;
len = db_do_raw_query(_h, _s, _r, db_oracle_submit_query, db_oracle_store_result);
CON_ORA(_h)->pqdata = NULL; /* paranoid for next call */
return len;
@@ -488,7 +487,7 @@ int db_oracle_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
{
query_data_t cb;
int rc;
-
+
if (!_h || !CON_TABLE(_h)) {
LM_ERR("invalid parameter value\n");
return -1;
diff --git a/src/modules/db_oracle/res.c b/src/modules/db_oracle/res.c
index 5511567..ca585fe 100644
--- a/src/modules/db_oracle/res.c
+++ b/src/modules/db_oracle/res.c
@@ -440,7 +440,6 @@ int db_oracle_store_result(const db1_con_t* _h, db1_res_t** _r)
OCIStmt* hs;
if (!_h || !_r) {
-badparam:
LM_ERR("invalid parameter\n");
return -1;
}
@@ -448,15 +447,20 @@ int db_oracle_store_result(const db1_con_t* _h, db1_res_t** _r)
con = CON_ORA(_h);
{
query_data_t *pcb = con->pqdata;
-
- if (!pcb || !pcb->_rs)
- goto badparam;
-
+ if (!pcb) {
+ LM_ERR("invalid parameter\n");
+ return -1;
+ }
+ if (!pcb->_rs) {
+ LM_DBG("no result\n");
+ return 0;
+ }
+
hs = *pcb->_rs;
pcb->_rs = NULL; /* paranoid for next call */
- }
-
+ }
+
rc = -1;
if (_r) *_r = NULL; /* unification for all errors */
More information about the sr-dev
mailing list