diff --git a/checkin_notes b/checkin_notes index 4b4a4d29d9..a282adc0d4 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1830,3 +1830,12 @@ Rom 17 Feb 2012 / configure.ac version.h + +David 17 Feb 2012 + - db_purge: when deleting a workunit record, + delete any assignments that refer to it + + db/ + db_base.cpp,h + sched/ + db_purge.cpp diff --git a/db/db_base.cpp b/db/db_base.cpp index 63ef6fff0f..4c5ec9d3e6 100644 --- a/db/db_base.cpp +++ b/db/db_base.cpp @@ -250,12 +250,17 @@ int DB_BASE::update_field(const char* clause, const char* where_clause) { // delete record // int DB_BASE::delete_from_db() { - char vals[MAX_QUERY_LEN], query[MAX_QUERY_LEN]; - db_print(vals); + char query[MAX_QUERY_LEN]; sprintf(query, "delete from %s where id=%u", table_name, get_id()); return db->do_query(query); } +int DB_BASE::delete_from_db_multi(const char* where_clause) { + char query[MAX_QUERY_LEN]; + sprintf(query, "delete from %s where %s", table_name, where_clause); + return db->do_query(query); +} + int DB_BASE::get_field_ints(const char* fields, int nfields, int* vals) { char query[MAX_QUERY_LEN]; int retval; diff --git a/db/db_base.h b/db/db_base.h index e8595f4b23..db895ad4ed 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -98,6 +98,7 @@ public: int update_field(const char*, const char* where_clause=NULL); int update_fields_noid(char* set_clause, char* where_clause); int delete_from_db(); + int delete_from_db_multi(const char* where_clause); int get_field_ints(const char*, int, int*); int get_field_str(const char*, char*, int); int lookup_id(int id); diff --git a/sched/db_purge.cpp b/sched/db_purge.cpp index 63dc60c9fb..4deed6e99c 100644 --- a/sched/db_purge.cpp +++ b/sched/db_purge.cpp @@ -549,6 +549,13 @@ bool do_pass() { "Purged workunit [%d] from database\n", wu.id ); + if (config.enable_assignment) { + DB_ASSIGNMENT asg; + char buf[256]; + sprintf(buf, "workunitid=%d", wu.id); + asg.delete_from_db_multi(buf); + } + purged_workunits++; do_pass_purged_workunits++; wu_stored_in_file++;