[dovecot-cvs] dovecot/src/lib-sql driver-mysql.c,1.16.2.2,1.16.2.3

cras at dovecot.org cras at dovecot.org
Fri Jun 16 14:42:31 EEST 2006


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

Modified Files:
      Tag: branch_1_0
	driver-mysql.c 
Log Message:
Fixes to handling database updates.



Index: driver-mysql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-sql/driver-mysql.c,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -d -r1.16.2.2 -r1.16.2.3
--- driver-mysql.c	31 May 2006 11:02:45 -0000	1.16.2.2
+++ driver-mysql.c	16 Jun 2006 11:42:29 -0000	1.16.2.3
@@ -228,6 +228,12 @@
 	}
 	t_pop();
 
+#ifdef CLIENT_MULTI_STATEMENTS
+	/* Updates require this because everything is committed in one large
+	   SQL statement. */
+	db->client_flags |= CLIENT_MULTI_STATEMENTS;
+#endif
+
 	if (array_count(&db->connections) == 0)
 		i_fatal("mysql: No hosts given in connect string");
 }
@@ -393,7 +399,7 @@
 	case 1:
 		/* query ok */
 		result->result = mysql_store_result(conn->mysql);
-		if (result->result != NULL)
+		if (result->result != NULL || mysql_errno(conn->mysql) == 0)
 			break;
 		/* fallback */
 	case -1:
@@ -422,11 +428,16 @@
 {
 	struct mysql_result *result = (struct mysql_result *)_result;
 
+	if (result->result == NULL) {
+		/* no results */
+		return 0;
+	}
+
 	result->row = mysql_fetch_row(result->result);
 	if (result->row != NULL)
 		return 1;
 
-	return mysql_errno(result->conn->mysql) ? -1 : 0;
+	return mysql_errno(result->conn->mysql) != 0 ? -1 : 0;
 }
 
 static void driver_mysql_result_fetch_fields(struct mysql_result *result)



More information about the dovecot-cvs mailing list