From: Nathan Binkert Date: Sun, 23 May 2004 16:53:34 +0000 (-0400) Subject: make the interaction of the stats event stuff with the X-Git-Tag: m5_1.0_beta2~20 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a0dfc43d19255a04c74ef1b1017e978bc5b8796;p=gem5.git make the interaction of the stats event stuff with the database work better. base/stats/events.cc: properly connect to the database base/stats/mysql.cc: cleanup the event stuff too --HG-- extra : convert_revision : f05fd6456decc9c4f95beff5c12497439e45f886 --- diff --git a/base/stats/events.cc b/base/stats/events.cc index 3a858611f..b579981e9 100644 --- a/base/stats/events.cc +++ b/base/stats/events.cc @@ -66,11 +66,12 @@ __event(const string &stat) stat)); MySQL::Result result = mysql.store_result(); - if (result) { - assert(result.num_fields() == 1); - MySQL::Row row = result.fetch_row(); - if (!row) - panic("could not get a run\n%s\n", mysql.error); + if (!result) + panic("could not get a run\n%s\n", mysql.error); + + assert(result.num_fields() == 1); + MySQL::Row row = result.fetch_row(); + if (row) { if (!to_number(row[0], event)) panic("invalid event id: %s\n", row[0]); } else { @@ -85,7 +86,6 @@ __event(const string &stat) event = mysql.insert_id(); } - } else { event = (*i).second; } diff --git a/base/stats/mysql.cc b/base/stats/mysql.cc index 05808c211..77366beb0 100644 --- a/base/stats/mysql.cc +++ b/base/stats/mysql.cc @@ -134,6 +134,16 @@ MySqlRun::cleanup() "FROM bins " "LEFT JOIN data ON bn_id=dt_bin " "WHERE dt_bin IS NULL"); + + mysql.query("DELETE events" + "FROM events" + "LEFT JOIN runs ON ev_run=rn_id" + "WHERE rn_id IS NULL"); + + mysql.query("DELETE event_names" + "FROM event_names" + "LEFT JOIN events ON en_id=ev_event" + "WHERE ev_event IS NULL"); } void