8 my $bin_dir = dirname
($0);
11 if (!defined($db_file)) {
12 print "usage: $0 <project> <db_file>\n";
15 my $insertions = "$bin_dir/$project.insert.return_states";
17 my $db = DBI
->connect("dbi:SQLite:$db_file", "", "", {AutoCommit
=> 0});
18 $db->do("PRAGMA cache_size = 800000");
19 $db->do("PRAGMA journal_mode = OFF");
20 $db->do("PRAGMA count_changes = OFF");
21 $db->do("PRAGMA temp_store = MEMORY");
22 $db->do("PRAGMA locking = EXCLUSIVE");
24 sub insert_record
($$$$$$$)
34 # print "file = '$file' func = '$func' ret = $ret\n";
35 # print "type = $type param = $param, key = $key, value = '$value'\n";
36 # print "select file, return_id, return, static from return_states where function = '$func' and return = '$ret' and type = 0;'\n";
40 $sth = $db->prepare("select file, return_id, call_id, static from return_states where file = ? and function = ? and return = ? and type = 0;");
41 $sth->execute($file, $func, $ret);
43 $sth = $db->prepare("select file, return_id, call_id, static from return_states where function = ? and return = ? and type = 0;");
44 $sth->execute($func, $ret);
47 my $exists = $db->prepare("select count(*) from return_states where file = ? and function = ? and return_id = ? and static = ? and return = ? and type = ? and parameter = ? and key = ? and value = ?;");
48 my $insert = $db->prepare("insert into return_states values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
49 while (my @row = $sth->fetchrow_array()) {
51 my $return_id = $row[1];
52 my $call_id = $row[2];
55 $exists->execute($file, $func, $return_id, $static, $ret, $type, $param, $key, $value);
56 my $count = $exists->fetchrow_array();
61 $insert->execute($file, $func, $call_id, $return_id, $ret, $static, $type, $param, $key, $value);
65 my ($ret, $insert, $file, $func, $type, $param, $key, $value);
67 open(FILE
, "<$insertions");
74 ($ret, $insert) = split(/\|/, $_);
76 if ($ret =~ /(.+),\W*(.+),\W*"(.*)"/) {
80 } elsif ($ret =~ /(.+),\W*"(.*)"/) {
88 ($type, $param, $key, $value) = split(/,/, $insert);
92 $key =~ s/^["\s]+|["\s]+$//g;
93 $value =~ s/^["\s]+|["\s]+$//g;
96 insert_record
($file, $func, $ret, $type, $param, $key, $value);