Skip to content

Commit

Permalink
sql: Fix bug with multiple dumps.
Browse files Browse the repository at this point in the history
The statistic ids are unique, so they will create primary key conflicts
on multiple dumps. The solution is to use both the stat id and the dump
id as primary keys.

Change-Id: I9b8e5cf6b0ca5f96f4e09302f9ceb517232b43af
  • Loading branch information
xyzsam committed Sep 24, 2017
1 parent 7719786 commit 850f7da
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/base/stats/sql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,23 @@ bool OutputSQL::create_tables() {
std::string scalar_value_sql =
"drop table if exists scalarValue;"
"create table scalarValue ("
"id int primary key,"
"id int,"
"dump int,"
"value real);";
"value real,"
"primary key (id, dump));";

std::string vector_value_sql =
"drop table if exists vectorValue;"
"create table vectorValue ("
"id int primary key,"
"id int,"
"dump int,"
"value blob);";
"value blob,"
"primary key (id, dump));";

std::string dist_value_sql =
"drop table if exists distValue;"
"create table distValue ("
"id int primary key,"
"id int,"
"dump int,"
"sum real,"
"squares real,"
Expand All @@ -121,7 +123,8 @@ bool OutputSQL::create_tables() {
"min_val real,"
"max_val real,"
"underflow real,"
"overflow real);";
"overflow real,"
"primary key (id, dump));";

std::string dump_desc_sql =
"drop table if exists dumpDesc;"
Expand Down

0 comments on commit 850f7da

Please sign in to comment.