From: Frank Ch. Eigler Date: Tue, 19 Apr 2022 17:49:25 +0000 (-0400) Subject: dejagnu parse: drop unique ddl X-Git-Tag: cauldron2022-demo~174 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=9f579bc9db183da15958454bd1b6cbee0b612102;p=bunsen.git dejagnu parse: drop unique ddl While unique() assertions in the table ddl are good for data hygiene, they also cost considerable storage. Since the pipeline manages analysis engine lifecycles carefully and non-concurrently, we don't really need them to assert desirable uniqueness properties in the tables. Instead, some ".eqp on" inspired indexes can do the job of accelerating queries, subject to easier further tuning. --- diff --git a/analysis/i-dejagnu-parser b/analysis/i-dejagnu-parser index 41ec023..58b1e04 100755 --- a/analysis/i-dejagnu-parser +++ b/analysis/i-dejagnu-parser @@ -36,8 +36,16 @@ def parse_dejagnu_log_sum(db, commit, trid, sumfile, logfile): logging.debug ("processing sumfile %s logfile %s tool %s", sumfile.path, logfile.path if logfile else None, tool) + # Drop preexisting rows in dejagnu_testsuite and dejagnu_testcase, + # so we can create new rows without risk of duplication, even without + # unique indexes. We save space by enforcing this constraint manually. + # This will drop foreign-key derived tables too, so other i-* engines + # need to run, which normally is automatic. + db.execute("delete from dejagnu_testsuite where tr=? and sumfile=?", (trid, sumfile.path)) + db.commit() + # create dejagnu testsuite record - db.execute("insert or ignore into dejagnu_testsuite (tr, logfile, sumfile) values (?, ?, ?);", + db.execute("insert into dejagnu_testsuite (tr, logfile, sumfile) values (?, ?, ?);", (trid, logfile.path if logfile else None, sumfile.path)) db.commit() # and fetch the testsuite record id right away @@ -163,7 +171,7 @@ def parse_dejagnu_log_sum(db, commit, trid, sumfile, logfile): logline_number += 1 # time to add the dejagnu_testcase record - db.execute("insert or ignore into dejagnu_testcase (testsuite, expfile, subtest, result, logcursor, logcursor2, sumcursor)"+ + db.execute("insert into dejagnu_testcase (testsuite, expfile, subtest, result, logcursor, logcursor2, sumcursor)"+ "values (?,?,?,?,?,?,?);", (tstid, expfileid, subtestid, resultid, logline_number_last if loglinefound else None, @@ -213,8 +221,9 @@ CREATE TABLE if not exists dejagnu_testsuite ( tr integer not null, /* testrun ref */ logfile string, /* e.g. testsuite/systemtap.log */ sumfile string not null, /* e.g. testsuite/systemtap.sum */ - unique (tr, sumfile), + /* unique (tr, sumfile), */ /* one sumfile per testsuite */ foreign key (tr) references testrun(id) on delete cascade); +CREATE INDEX if not exists dejagnu_ts_tr on dejagnu_testsuite(tr); CREATE TABLE if not exists dejagnu_string ( /* string interning table */ id integer primary key, name string unique); @@ -226,10 +235,11 @@ CREATE TABLE if not exists dejagnu_testcase ( logcursor integer, /* line# in logfile */ logcursor2 integer, /* line# in logfile */ sumcursor integer, /* line# in logfile */ - unique (testsuite, sumcursor), /* one test case record per sum file line; dupe subtests sometimes appear */ + /* unique (testsuite, sumcursor), */ /* one test case record per sum file line; dupe subtests sometimes appear */ foreign key (expfile) references dejagnu_string(id) on delete cascade, foreign key (subtest) references dejagnu_string(id) on delete cascade, foreign key (testsuite) references dejagnu_testsuite(id) on delete cascade); +CREATE INDEX if not exists dejagnu_testcase_te on dejagnu_testcase (testsuite, expfile); CREATE VIEW if not exists dejagnu_testcase_v (testsuite, expfile, subtest, result, logcursor, logcursor2, sumcursor) as select t.testsuite, es.name, ss.name, rs.name, t.logcursor, t.logcursor2, t.sumcursor from dejagnu_testcase t, dejagnu_string es, dejagnu_string ss, dejagnu_string rs