Module: kamailio
Branch: master
Commit: 795a09077ccc5dd06f9074978dc77dd81389512b
URL:
https://github.com/kamailio/kamailio/commit/795a09077ccc5dd06f9074978dc77dd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-01-13T16:49:33+01:00
db_unixodbc: catch queries without result to skip printing error logs
- GH #2810
---
Modified: src/modules/db_unixodbc/dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/795a09077ccc5dd06f9074978dc77dd…
Patch:
https://github.com/kamailio/kamailio/commit/795a09077ccc5dd06f9074978dc77dd…
---
diff --git a/src/modules/db_unixodbc/dbase.c b/src/modules/db_unixodbc/dbase.c
index f2e1a3b12e..bbbb6e2d38 100644
--- a/src/modules/db_unixodbc/dbase.c
+++ b/src/modules/db_unixodbc/dbase.c
@@ -252,6 +252,8 @@ void db_unixodbc_close(db1_con_t* _h)
*/
static int db_unixodbc_store_result(const db1_con_t* _h, db1_res_t** _r)
{
+ SQLSMALLINT cols = 0;
+
if ((!_h) || (!_r))
{
LM_ERR("invalid parameter value\n");
@@ -266,6 +268,14 @@ static int db_unixodbc_store_result(const db1_con_t* _h, db1_res_t**
_r)
return -2;
}
+ SQLNumResultCols(CON_RESULT(_h), &cols);
+ if(cols==0) {
+ /* no result */
+ (*_r)->col.n = 0;
+ (*_r)->n = 0;
+ return 0;
+ }
+
if (db_unixodbc_convert_result(_h, *_r) < 0)
{
LM_ERR("failed to convert result\n");