diff --git a/checkin_notes b/checkin_notes index eeca9572ba..4c2dd8eb83 100755 --- a/checkin_notes +++ b/checkin_notes @@ -16554,3 +16554,27 @@ David 20 Aug 2004 client/ app_control.C + +David 20 Aug 2004 + - already_sent_to_different_platform(): + fix concurrency bug by reading WU.workseq_next + from database just prior to checking, + then updating the field immediately if needed. + - scheduler: update_wu_transition_time(): + use update_field(); more efficient + - Added DB_BASE::get_field_int(): get a single integer + field from a DB record. + A little cheaper than reading the whole record + - DB_BASE::lookup(): remove code that sees if record is unique. + It's called after mysql_free_result(), + so it will never return anything. + - DB code: changed "if (db->mysql && is_high_priority) to just + "if (is_high_priority)". + db->mysql is a pointer, and is always nonzero. + It's not a flag saying whether the DB is MySQL. + All this code is only for MySQL anyway. + + db/ + db_base.C,h + sched/ + sched_send.C diff --git a/db/db_base.C b/db/db_base.C index c0162b3035..ade8a4fee0 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -108,13 +108,31 @@ int DB_BASE::update_field(char* clause) { return db->do_query(query); } +int DB_BASE::get_field_int(char* field, int& val) { + char query[MAX_QUERY_LEN]; + int retval; + MYSQL_ROW row; + MYSQL_RES* rp; + + sprintf(query, "select %s from %s where id=%d", field, table_name, get_id()); + retval = db->do_query(query); + if (retval) return retval; + rp = mysql_store_result(db->mysql); + if (!rp) return -1; + row = mysql_fetch_row(rp); + if (row) val = atoi(row[0]); + mysql_free_result(rp); + if (row == 0) return ERR_DB_NOT_FOUND; + return 0; +} + int DB_BASE::lookup(char* clause) { char query[MAX_QUERY_LEN]; int retval; MYSQL_ROW row; MYSQL_RES* rp; - if (db->mysql && is_high_priority) { + if (is_high_priority) { sprintf(query, "select HIGH_PRIORITY * from %s %s", table_name, clause); } else { sprintf(query, "select * from %s %s", table_name, clause); @@ -128,11 +146,6 @@ int DB_BASE::lookup(char* clause) { if (row) db_parse(row); mysql_free_result(rp); if (row == 0) return ERR_DB_NOT_FOUND; - - // make sure there's exactly one row - // - row = mysql_fetch_row(rp); - if (row) return ERR_DB_NOT_UNIQUE; return 0; } @@ -142,7 +155,7 @@ int DB_BASE::lookup_id(int id) { MYSQL_ROW row; MYSQL_RES* rp; - if (db->mysql && is_high_priority) { + if (is_high_priority) { sprintf(query, "select HIGH_PRIORITY * from %s where id=%d", table_name, id); } else { sprintf(query, "select * from %s where id=%d", table_name, id); @@ -169,7 +182,7 @@ int DB_BASE::enumerate(char* clause) { if (!cursor.active) { cursor.active = true; - if (db->mysql && is_high_priority) { + if (is_high_priority) { sprintf(query, "select HIGH_PRIORITY * from %s %s", table_name, clause); } else { sprintf(query, "select * from %s %s", table_name, clause); @@ -242,7 +255,7 @@ int DB_BASE::get_double(char* query, double& x) { int DB_BASE::count(int& n, char* clause) { char query[MAX_QUERY_LEN]; - if (db->mysql && is_high_priority) { + if (is_high_priority) { sprintf(query, "select HIGH_PRIORITY count(*) from %s %s", table_name, clause); } else { sprintf(query, "select count(*) from %s %s", table_name, clause); @@ -254,7 +267,7 @@ int DB_BASE::count(int& n, char* clause) { int DB_BASE::sum(double& x, char* field, char* clause) { char query[MAX_QUERY_LEN]; - if (db->mysql && is_high_priority) { + if (is_high_priority) { sprintf(query, "select HIGH_PRIORITY sum(%s) from %s %s", field, table_name, clause); } else { sprintf(query, "select sum(%s) from %s %s", field, table_name, clause); diff --git a/db/db_base.h b/db/db_base.h index 5a0d2dc9b8..6fd42daa1a 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -82,6 +82,7 @@ public: int insert_batch(const char*); int update(); int update_field(char*); + int get_field_int(char*, int&); int lookup_id(int id); int lookup(char*); int enumerate(char* clause=""); diff --git a/sched/sched_send.C b/sched/sched_send.C index 8f13a1ef24..7df58eddbf 100644 --- a/sched/sched_send.C +++ b/sched/sched_send.C @@ -354,20 +354,13 @@ int insert_deadline_tag(RESULT& result) { } static int update_wu_transition_time(WORKUNIT wu, time_t x) { - // TODO: this might be better: a mysql statement such as "update set - // transition_time=X where id=ID and transition_time