changeset 6793:33cfef65a5e1 HEAD

Fixes to handling transaction updates.
author Timo Sirainen <tss@iki.fi>
date Mon, 12 Nov 2007 19:56:25 +0200
parents 7005fc7e69dc
children 513076febc7a
files src/lib-sql/driver-pgsql.c
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-sql/driver-pgsql.c	Mon Nov 12 19:23:55 2007 +0200
+++ b/src/lib-sql/driver-pgsql.c	Mon Nov 12 19:56:25 2007 +0200
@@ -248,6 +248,9 @@
 	if (result->api.callback)
 		return;
 
+	if (_result == db->sync_result)
+		db->sync_result = NULL;
+
 	if (result->pgres != NULL) {
 		PQclear(result->pgres);
 
@@ -464,6 +467,8 @@
 {
         struct pgsql_db *db = (struct pgsql_db *)result->api.db;
 
+	i_assert(db->sync_result == NULL);
+
 	if (db->querying) {
 		/* only one query at a time */
 		driver_pgsql_queue_query(result, query);
@@ -570,6 +575,12 @@
 				old_io.callback, old_io.context);
 	}
 
+	if (db->queue_to != NULL) {
+		/* we're creating a new ioloop, make sure the timeout gets
+		   added there. */
+		timeout_remove(&db->queue_to);
+	}
+
 	db->query_finished = FALSE;
 	driver_pgsql_query(_db, query, pgsql_query_s_callback, db);
 
@@ -829,7 +840,9 @@
 		*error_r = NULL;
 	else {
 		result = sql_query_s(_ctx->db, "COMMIT");
-		if (sql_result_next_row(result) < 0)
+		if (ctx->failed)
+			*error_r = ctx->error;
+		else if (sql_result_next_row(result) < 0)
 			*error_r = sql_result_get_error(result);
 		else
 			*error_r = NULL;