diff --git a/checkin_notes b/checkin_notes index 436beeb71a..9604b8f2d2 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/db/db_base.cpp b/db/db_base.cpp index adaf540b1f..bf869124e4 100644 --- a/db/db_base.cpp +++ b/db/db_base.cpp @@ -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);