[dovecot-cvs] dovecot/src/lib-sql driver-pgsql.c,1.18,1.19

tss at dovecot.org tss at dovecot.org
Tue Apr 3 08:10:07 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-sql
In directory talvi:/tmp/cvs-serv8233

Modified Files:
	driver-pgsql.c 
Log Message:
Don't send commit/rollback if nothing was done in the transaction.



Index: driver-pgsql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-sql/driver-pgsql.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- driver-pgsql.c	3 Apr 2007 05:09:25 -0000	1.18
+++ driver-pgsql.c	3 Apr 2007 05:10:05 -0000	1.19
@@ -699,11 +699,18 @@
 
 	if (ctx->failed) {
 		callback(ctx->error, context);
-		sql_exec(_ctx->db, "ROLLBACK");
+		if (ctx->opened)
+			sql_exec(_ctx->db, "ROLLBACK");
 		i_free(ctx);
 		return;
 	}
 
+	if (!ctx->opened) {
+		/* nothing done */
+		ctx->callback(NULL, ctx->context);
+		return;
+	}
+
 	ctx->callback = callback;
 	ctx->context = context;
 
@@ -720,8 +727,11 @@
 
 	if (ctx->failed) {
 		*error_r = ctx->error;
-		sql_exec(_ctx->db, "ROLLBACK");
-	} else {
+		if (!ctx->opened)
+			sql_exec(_ctx->db, "ROLLBACK");
+	} else if (!ctx->opened)
+		*error_r = NULL;
+	else {
 		result = sql_query_s(_ctx->db, "COMMIT");
 		if (sql_result_next_row(result) < 0)
 			*error_r = sql_result_get_error(result);
@@ -740,7 +750,8 @@
 	struct pgsql_transaction_context *ctx =
 		(struct pgsql_transaction_context *)_ctx;
 
-	sql_exec(_ctx->db, "ROLLBACK");
+	if (ctx->opened)
+		sql_exec(_ctx->db, "ROLLBACK");
 	i_free(ctx);
 }
 



More information about the dovecot-cvs mailing list