Browse code

db_unixodbc: catch queries without result to skip printing error logs

- GH #2810

(cherry picked from commit 795a09077ccc5dd06f9074978dc77dd81389512b)

Daniel-Constantin Mierla authored on 13/01/2022 15:49:33
Showing 1 changed files
... ...
@@ -252,6 +252,8 @@ void db_unixodbc_close(db1_con_t* _h)
252 252
  */
253 253
 static int db_unixodbc_store_result(const db1_con_t* _h, db1_res_t** _r)
254 254
 {
255
+	SQLSMALLINT cols = 0;
256
+
255 257
 	if ((!_h) || (!_r))
256 258
 	{
257 259
 		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)
266 268
 		return -2;
267 269
 	}
268 270
 
271
+	SQLNumResultCols(CON_RESULT(_h), &cols);
272
+	if(cols==0) {
273
+		/* no result */
274
+		(*_r)->col.n = 0;
275
+		(*_r)->n = 0;
276
+		return 0;
277
+	}
278
+
269 279
 	if (db_unixodbc_convert_result(_h, *_r) < 0)
270 280
 	{
271 281
 		LM_ERR("failed to convert result\n");