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

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


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

Modified Files:
	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.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- driver-mysql.c	31 May 2006 11:02:50 -0000	1.18
+++ driver-mysql.c	16 Jun 2006 11:42:30 -0000	1.19
@@ -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