[SR-Dev] git:janakj/mysql: - some synchronisations with db_postgres driver

Jan Janak jan at iptel.org
Mon Feb 16 22:07:53 CET 2009


Module: sip-router
Branch: janakj/mysql
Commit: bcdd7e786876b4cce49fb0fdea56ec696caa77cd
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bcdd7e786876b4cce49fb0fdea56ec696caa77cd

Author: Henning Westerholt <henning.westerholt at 1und1.de>
Committer: Henning Westerholt <henning.westerholt at 1und1.de>
Date:   Thu May  8 16:12:31 2008 +0000

- 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

---

 modules/db_mysql/km_dbase.c |    7 ++++++-
 modules/db_mysql/km_res.c   |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/modules/db_mysql/km_dbase.c b/modules/db_mysql/km_dbase.c
index 1da7953..e4f78ba 100644
--- a/modules/db_mysql/km_dbase.c
+++ b/modules/db_mysql/km_dbase.c
@@ -323,9 +323,11 @@ int db_mysql_fetch_result(const db_con_t* _h, db_res_t** _r, const int nrows)
 	if(nrows < rows)
 		rows = nrows;
 
-	RES_LAST_ROW(*_r) += rows;
 	RES_ROW_N(*_r) = rows;
 
+	LM_DBG("converting row %d of %d count %d\n", RES_LAST_ROW(*_r),
+			RES_NUM_ROWS(*_r), RES_ROW_N(*_r));
+
 	RES_ROWS(*_r) = (struct db_row*)pkg_malloc(sizeof(db_row_t) * rows);
 	if (!RES_ROWS(*_r)) {
 		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)
 			return -7;
 		}
 	}
+
+	/* update the total number of rows processed */
+	RES_LAST_ROW(*_r) += rows;
 	return 0;
 }
 
diff --git a/modules/db_mysql/km_res.c b/modules/db_mysql/km_res.c
index 91a8211..740b254 100644
--- a/modules/db_mysql/km_res.c
+++ b/modules/db_mysql/km_res.c
@@ -144,6 +144,7 @@ static inline int db_mysql_convert_rows(const db_con_t* _h, db_res_t* _r)
 
 	RES_ROW_N(_r) = mysql_num_rows(CON_RESULT(_h));
 	if (!RES_ROW_N(_r)) {
+		LM_DBG("no rows returned from the query\n");
 		RES_ROWS(_r) = 0;
 		return 0;
 	}




More information about the sr-dev mailing list