if (mysql.error)
panic("could not connect to database server\n%s\n", mysql.error);
- mysql.query("LOCK TABLES runs WRITE");
- if (mysql.error)
- panic("could not lock tables\n%s\n", mysql.error);
+ if (mysql.autocommit(false))
+ panic("could not set autocommit\n");
remove(name);
-// cleanup();
+ //cleanup();
setup(name, sample, user, project);
- mysql.query("UNLOCK TABLES");
- if (mysql.error)
- panic("could not unlock tables\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
}
void
if (!result)
panic("could not find stat\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
assert(result.num_fields() == 16);
MySQL::Row row = result.fetch_row();
Connection &mysql = MySqlDB.conn();
assert(mysql.connected());
- mysql.query("LOCK TABLES bins WRITE");
- if (mysql.error)
- panic("could not lock bin table\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
uint16_t bin_id;
binmap.insert(make_pair(bin, bin_id));
exit:
- mysql.query("UNLOCK TABLES");
- if (mysql.error)
- panic("could not unlock tables\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
return bin_id;
}
mysql.query(query);
if (mysql.error)
panic("could not insert data\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
}
query[0] = '\0';
mysql.query(insert);
// if (mysql.error)
// panic("could not insert subdata\n%s\n", mysql.error);
+
+ if (mysql.commit())
+ panic("could not commit transaction\n");
}
void
mysql.query(insert_ref);
// if (mysql.error)
// panic("could not insert formula reference\n%s\n", mysql.error);
+
+ if (mysql.commit())
+ panic("could not commit transaction\n");
}
void
mysql.query(update);
if (mysql.error)
panic("could not update prereq\n%s\n", mysql.error);
+
+ if (mysql.commit())
+ panic("could not commit transaction\n");
}
void
using namespace Database;
MySQL::Connection &mysql = MySqlDB.conn();
- mysql.query("LOCK TABLES "
- "stats WRITE, "
- "bins WRITE, "
- "subdata WRITE, "
- "formulas WRITE, "
- "formula_ref WRITE");
- if (mysql.error)
- panic("could not lock tables\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
stat_list_t::const_iterator i, end = stats().end();
- for (i = stats().begin(); i != end; ++i)
+ for (i = stats().begin(); i != end; ++i) {
(*i)->visit(*this);
+ }
for (i = stats().begin(); i != end; ++i) {
StatData *data = *i;
}
}
- mysql.query("UNLOCK TABLES");
- if (mysql.error)
- panic("could not unlock tables\n%s\n", mysql.error);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
configured = true;
}
void
MySql::output(MainBin *bin)
{
+ MySQL::Connection &mysql = MySqlDB.conn();
+
if (bin) {
bin->activate();
newdata.bin = SetupBin(bin->name());
Database::stat_list_t::const_iterator i, end = Database::stats().end();
for (i = Database::stats().begin(); i != end; ++i) {
StatData *stat = *i;
- if (bin && stat->binned() || !bin && !stat->binned())
+ if (bin && stat->binned() || !bin && !stat->binned()) {
stat->visit(*this);
+ if (mysql.commit())
+ panic("could not commit transaction\n");
+ }
}
}
MySQL::Connection mysql;
uint16_t run_id;
+ protected:
+ void setup(const std::string &name, const std::string &sample,
+ const std::string &user, const std::string &project);
+
+ void remove(const std::string &name);
+ void cleanup();
+
public:
bool connected() const { return mysql.connected(); }
void connect(const std::string &host, const std::string &user,
const std::string &name, const std::string &sample,
const std::string &project);
- void setup(const std::string &name, const std::string &sample,
- const std::string &user, const std::string &project);
-
- void remove(const std::string &name);
- void cleanup();
-
MySQL::Connection &conn() { return mysql; }
uint16_t run() const { return run_id; }
};