diff --git a/db/boinc_db.cpp b/db/boinc_db.cpp index 923a55f63c..72ddcc3768 100644 --- a/db/boinc_db.cpp +++ b/db/boinc_db.cpp @@ -177,22 +177,22 @@ DB_CREDIT_USER::DB_CREDIT_USER(DB_CONN* dc) : DB_CREDIT_TEAM::DB_CREDIT_TEAM(DB_CONN* dc) : DB_BASE("credit_team", dc?dc:&boinc_db){} -int DB_PLATFORM::get_id() {return id;} -int DB_APP::get_id() {return id;} -int DB_APP_VERSION::get_id() {return id;} -int DB_USER::get_id() {return id;} -int DB_TEAM::get_id() {return id;} -int DB_HOST::get_id() {return id;} -int DB_WORKUNIT::get_id() {return id;} -int DB_RESULT::get_id() {return id;} -int DB_MSG_FROM_HOST::get_id() {return id;} -int DB_MSG_TO_HOST::get_id() {return id;} -int DB_ASSIGNMENT::get_id() {return id;} -int DB_STATE_COUNTS::get_id() {return appid;} -int DB_FILE::get_id() {return id;} -int DB_FILESET::get_id() {return id;} -int DB_SCHED_TRIGGER::get_id() {return id;} -int DB_VDA_FILE::get_id() {return id;} +DB_ID_TYPE DB_PLATFORM::get_id() {return id;} +DB_ID_TYPE DB_APP::get_id() {return id;} +DB_ID_TYPE DB_APP_VERSION::get_id() {return id;} +DB_ID_TYPE DB_USER::get_id() {return id;} +DB_ID_TYPE DB_TEAM::get_id() {return id;} +DB_ID_TYPE DB_HOST::get_id() {return id;} +DB_ID_TYPE DB_WORKUNIT::get_id() {return id;} +DB_ID_TYPE DB_RESULT::get_id() {return id;} +DB_ID_TYPE DB_MSG_FROM_HOST::get_id() {return id;} +DB_ID_TYPE DB_MSG_TO_HOST::get_id() {return id;} +DB_ID_TYPE DB_ASSIGNMENT::get_id() {return id;} +DB_ID_TYPE DB_STATE_COUNTS::get_id() {return appid;} +DB_ID_TYPE DB_FILE::get_id() {return id;} +DB_ID_TYPE DB_FILESET::get_id() {return id;} +DB_ID_TYPE DB_SCHED_TRIGGER::get_id() {return id;} +DB_ID_TYPE DB_VDA_FILE::get_id() {return id;} void DB_PLATFORM::db_print(char* buf){ sprintf(buf, diff --git a/db/boinc_db.h b/db/boinc_db.h index 8356d170c4..3d016981d1 100644 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -105,7 +105,7 @@ struct STATE_COUNTS { struct DB_STATE_COUNTS : public DB_BASE, public STATE_COUNTS { DB_STATE_COUNTS(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char *); void db_parse(MYSQL_ROW &row); }; @@ -121,7 +121,7 @@ struct VALIDATOR_ITEM { class DB_PLATFORM : public DB_BASE, public PLATFORM { public: DB_PLATFORM(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); }; @@ -129,7 +129,7 @@ public: class DB_APP : public DB_BASE, public APP { public: DB_APP(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); }; @@ -137,7 +137,7 @@ public: class DB_APP_VERSION : public DB_BASE, public APP_VERSION { public: DB_APP_VERSION(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); void operator=(APP_VERSION& w) {APP_VERSION::operator=(w);} @@ -146,7 +146,7 @@ public: class DB_USER : public DB_BASE, public USER { public: DB_USER(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); void operator=(USER& r) {USER::operator=(r);} @@ -155,7 +155,7 @@ public: class DB_TEAM : public DB_BASE, public TEAM { public: DB_TEAM(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); }; @@ -163,7 +163,7 @@ public: class DB_HOST : public DB_BASE, public HOST { public: DB_HOST(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); int update_diff_sched(HOST&); int update_diff_validator(HOST&); int fpops_percentile(double percentile, double& fpops); @@ -178,7 +178,7 @@ public: class DB_RESULT : public DB_BASE, public RESULT { public: DB_RESULT(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); int mark_as_sent(int old_server_state, int report_grace_period); void db_print(char*); void db_print_values(char*); @@ -193,7 +193,7 @@ public: class DB_WORKUNIT : public DB_BASE, public WORKUNIT { public: DB_WORKUNIT(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_print_values(char*); void db_parse(MYSQL_ROW &row); @@ -211,7 +211,7 @@ public: class DB_MSG_FROM_HOST : public DB_BASE, public MSG_FROM_HOST { public: DB_MSG_FROM_HOST(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); }; @@ -219,7 +219,7 @@ public: class DB_MSG_TO_HOST : public DB_BASE, public MSG_TO_HOST { public: DB_MSG_TO_HOST(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); }; @@ -227,7 +227,7 @@ public: class DB_ASSIGNMENT : public DB_BASE, public ASSIGNMENT { public: DB_ASSIGNMENT(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW& row); }; @@ -390,7 +390,7 @@ struct FILE_ITEM { class DB_FILE : public DB_BASE, public FILE_ITEM { public: DB_FILE(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); void operator=(FILE_ITEM& f) {FILE_ITEM::operator=(f);} @@ -406,7 +406,7 @@ struct FILESET_ITEM { class DB_FILESET : public DB_BASE, public FILESET_ITEM { public: DB_FILESET(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); void operator=(FILESET_ITEM& f) {FILESET_ITEM::operator=(f);} @@ -444,7 +444,7 @@ struct SCHED_TRIGGER_ITEM { class DB_SCHED_TRIGGER : public DB_BASE, public SCHED_TRIGGER_ITEM { public: DB_SCHED_TRIGGER(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); void operator=(SCHED_TRIGGER_ITEM& t) {SCHED_TRIGGER_ITEM::operator=(t);} @@ -501,7 +501,7 @@ public: struct DB_VDA_FILE : public DB_BASE, public VDA_FILE { DB_VDA_FILE(DB_CONN* p=0); - int get_id(); + DB_ID_TYPE get_id(); void db_print(char*); void db_parse(MYSQL_ROW &row); }; @@ -514,7 +514,7 @@ struct DB_VDA_CHUNK_HOST : public DB_BASE, public VDA_CHUNK_HOST { struct DB_BADGE : public DB_BASE, public BADGE { DB_BADGE(DB_CONN* p=0); - int get_id() {return id;}; + DB_ID_TYPE get_id() {return id;}; void db_print(char*){}; void db_parse(MYSQL_ROW&); }; diff --git a/db/db_base.cpp b/db/db_base.cpp index 5e3c6df8c7..295261ef85 100644 --- a/db/db_base.cpp +++ b/db/db_base.cpp @@ -192,7 +192,7 @@ int DB_CONN::ping() { DB_BASE::DB_BASE(const char *tn, DB_CONN* p) : db(p), table_name(tn) { } -int DB_BASE::get_id() { return 0;} +DB_ID_TYPE DB_BASE::get_id() { return 0;} void DB_BASE::db_print(char*) {} void DB_BASE::db_parse(MYSQL_ROW&) {} @@ -241,7 +241,7 @@ int DB_BASE::lookup_id(DB_ID_TYPE id) { int DB_BASE::update() { char vals[MAX_QUERY_LEN], query[MAX_QUERY_LEN]; db_print(vals); - sprintf(query, "update %s set %s where id=%u", table_name, vals, get_id()); + sprintf(query, "update %s set %s where id=%lu", table_name, vals, get_id()); int retval = db->do_query(query); if (retval) return retval; if (db->affected_rows() != 1) return ERR_DB_NOT_FOUND; @@ -254,9 +254,13 @@ int DB_BASE::update() { int DB_BASE::update_field(const char* clause, const char* where_clause) { char query[MAX_QUERY_LEN]; if (where_clause) { - sprintf(query, "update %s set %s where id=%u and %s", table_name, clause, get_id(), where_clause); + sprintf(query, "update %s set %s where id=%lu and %s", + table_name, clause, get_id(), where_clause + ); } else { - sprintf(query, "update %s set %s where id=%u", table_name, clause, get_id()); + sprintf(query, "update %s set %s where id=%lu", + table_name, clause, get_id() + ); } return db->do_query(query); } @@ -265,7 +269,7 @@ int DB_BASE::update_field(const char* clause, const char* where_clause) { // int DB_BASE::delete_from_db() { char query[MAX_QUERY_LEN]; - sprintf(query, "delete from %s where id=%u", table_name, get_id()); + sprintf(query, "delete from %s where id=%lu", table_name, get_id()); return db->do_query(query); } @@ -282,7 +286,7 @@ int DB_BASE::get_field_ints(const char* fields, int nfields, int* vals) { MYSQL_RES* rp; sprintf(query, - "select %s from %s where id=%u", fields, table_name, get_id() + "select %s from %s where id=%lu", fields, table_name, get_id() ); retval = db->do_query(query); if (retval) return retval; @@ -306,7 +310,7 @@ int DB_BASE::get_field_str(const char* field, char* buf, int buflen) { MYSQL_RES* rp; sprintf(query, - "select %s from %s where id=%u", field, table_name, get_id() + "select %s from %s where id=%lu", field, table_name, get_id() ); retval = db->do_query(query); if (retval) return retval; diff --git a/db/db_base.h b/db/db_base.h index 11afa0c941..9a00ec1588 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -122,7 +122,7 @@ public: DB_CONN* db; const char *table_name; CURSOR cursor; - virtual int get_id(); + virtual DB_ID_TYPE get_id(); virtual void db_print(char*); virtual void db_parse(MYSQL_ROW&); }; diff --git a/sched/file_deleter.cpp b/sched/file_deleter.cpp index f5970c09e6..21367c3b00 100644 --- a/sched/file_deleter.cpp +++ b/sched/file_deleter.cpp @@ -64,7 +64,8 @@ #define DEFAULT_SLEEP_INTERVAL 5 #define RESULTS_PER_WU 4 // an estimate of redundancy -int id_modulus=0, id_remainder=0, appid=0; +int id_modulus=0, id_remainder=0; +DB_ID_TYPE appid=0; bool dont_retry_errors = false; bool dont_delete_batches = false; bool do_input_files = true; @@ -316,7 +317,7 @@ bool do_pass(bool retry_error) { strcat(clause, " and batch <= 0 "); } if (appid) { - sprintf(buf, " and appid = %d ", appid); + sprintf(buf, " and appid = %lu ", appid); strcat(clause, buf); } @@ -469,7 +470,7 @@ int main(int argc, char** argv) { usage(argv[0]); exit(1); } - appid = atoi(argv[i]); + appid = atol(argv[i]); } else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) { if (!argv[++i]) { log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]); @@ -588,8 +589,8 @@ int main(int argc, char** argv) { log_messages.printf(MSG_CRITICAL, "Can't find app\n"); exit(1); } - appid=app.id; - log_messages.printf(MSG_DEBUG, "Deleting files of appid %d\n",appid); + appid = app.id; + log_messages.printf(MSG_DEBUG, "Deleting files of appid %lu\n",appid); } install_stop_signal_handler();