Browse code

- some synchronisations with db_postgres driver - move LAST_ROW incrementation to the end of the function, to only update after a successfull fetch - add two debug messages

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4138 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 08/05/2008 16:12:31
Showing 2 changed files
... ...
@@ -323,9 +323,11 @@ int db_mysql_fetch_result(const db_con_t* _h, db_res_t** _r, const int nrows)
323 323
 	if(nrows < rows)
324 324
 		rows = nrows;
325 325
 
326
-	RES_LAST_ROW(*_r) += rows;
327 326
 	RES_ROW_N(*_r) = rows;
328 327
 
328
+	LM_DBG("converting row %d of %d count %d\n", RES_LAST_ROW(*_r),
329
+			RES_NUM_ROWS(*_r), RES_ROW_N(*_r));
330
+
329 331
 	RES_ROWS(*_r) = (struct db_row*)pkg_malloc(sizeof(db_row_t) * rows);
330 332
 	if (!RES_ROWS(*_r)) {
331 333
 		LM_ERR("no memory left\n");
... ...
@@ -347,6 +349,9 @@ int db_mysql_fetch_result(const db_con_t* _h, db_res_t** _r, const int nrows)
347 349
 			return -7;
348 350
 		}
349 351
 	}
352
+
353
+	/* update the total number of rows processed */
354
+	RES_LAST_ROW(*_r) += rows;
350 355
 	return 0;
351 356
 }
352 357
 
... ...
@@ -144,6 +144,7 @@ static inline int db_mysql_convert_rows(const db_con_t* _h, db_res_t* _r)
144 144
 
145 145
 	RES_ROW_N(_r) = mysql_num_rows(CON_RESULT(_h));
146 146
 	if (!RES_ROW_N(_r)) {
147
+		LM_DBG("no rows returned from the query\n");
147 148
 		RES_ROWS(_r) = 0;
148 149
 		return 0;
149 150
 	}