- server: DB update queries check that the number of affected rows is 1.

However, MySQL's default is that "affected rows" is
    rows actually modified, which is not what we want.
    Use the CLIENT_FOUND_ROWS option in mysql_real_connect()
    to change the semantics to "rows matched".
    From Oliver Bock.

svn path=/trunk/boinc/; revision=20880
This commit is contained in:
David Anderson 2010-03-12 19:36:20 +00:00
parent d6ce6ca0b7
commit 85d0027d3b
2 changed files with 17 additions and 1 deletions

View File

@ -1919,3 +1919,14 @@ David 12 Mar 2010
client/
cpu_sched.cpp
David 12 Mar 2010
- server: DB update queries check that the number of affected rows is 1.
However, MySQL's default is that "affected rows" is
rows actually modified, which is not what we want.
Use the CLIENT_FOUND_ROWS option in mysql_real_connect()
to change the semantics to "rows matched".
From Oliver Bock.
db/
db_base.cpp

View File

@ -70,8 +70,11 @@ int DB_CONN::open(char* db_name, char* db_host, char* db_user, char* dbpassword)
my_bool mbReconnect = 1;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &mbReconnect);
}
// CLIENT_FOUND_ROWS means that the # of affected rows for an update
// is the # matched by the where, rather than the # actually changed
//
mysql = mysql_real_connect(
mysql, db_host, db_user, dbpassword, db_name, 0, 0, 0
mysql, db_host, db_user, dbpassword, db_name, 0, 0, CLIENT_FOUND_ROWS
);
if (mysql == 0) return ERR_DB_CANT_CONNECT;
@ -122,6 +125,8 @@ int DB_CONN::do_query(const char* p) {
return retval;
}
// returns the number of rows matched by an update query
//
int DB_CONN::affected_rows() {
unsigned long x = (unsigned long)mysql_affected_rows(mysql);
//fprintf(stderr, "x: %lu i: %d\n", x, (int)x);