27
27
28
28
os = isolate_module (os )
29
29
30
- SCHEMA_VERSION = 5
30
+ SCHEMA_VERSION = 6
31
31
32
32
SCHEMA = """
33
33
CREATE TABLE coverage_schema (
39
39
-- 3: Replaced line table with line_map table.
40
40
-- 4: Changed line_map.bitmap to line_map.numbits.
41
41
-- 5: Added foreign key declarations.
42
+ -- 6: Key-value in meta.
42
43
);
43
44
44
45
CREATE TABLE meta (
45
- -- One row, to record some metadata about the data
46
- has_lines boolean, -- Is this data recording lines?
47
- has_arcs boolean, -- .. or branches?
48
- sys_argv text -- The coverage command line that recorded the data.
46
+ -- Key-value pairs, to record metadata about the data
47
+ key text,
48
+ value text,
49
+ unique (key)
50
+ -- Keys:
51
+ -- 'has_arcs' boolean -- Is this data recording branches?
52
+ -- 'sys_argv' text -- The coverage command line that recorded the data.
49
53
);
50
54
51
55
CREATE TABLE file (
52
56
-- A row per file measured.
53
57
id integer primary key,
54
58
path text,
55
- unique(path)
59
+ unique (path)
56
60
);
57
61
58
62
CREATE TABLE context (
59
63
-- A row per context measured.
60
64
id integer primary key,
61
65
context text,
62
- unique(context)
66
+ unique (context)
63
67
);
64
68
65
69
CREATE TABLE line_map (
69
73
numbits blob, -- see the numbits functions in coverage.numbits
70
74
foreign key (file_id) references file (id),
71
75
foreign key (context_id) references context (id),
72
- unique(file_id, context_id)
76
+ unique (file_id, context_id)
73
77
);
74
78
75
79
CREATE TABLE arc (
80
84
tono integer, -- line number jumped to.
81
85
foreign key (file_id) references file (id),
82
86
foreign key (context_id) references context (id),
83
- unique(file_id, context_id, fromno, tono)
87
+ unique (file_id, context_id, fromno, tono)
84
88
);
85
89
86
90
CREATE TABLE tracer (
@@ -226,8 +230,8 @@ def _create_db(self):
226
230
db .executescript (SCHEMA )
227
231
db .execute ("insert into coverage_schema (version) values (?)" , (SCHEMA_VERSION ,))
228
232
db .execute (
229
- "insert into meta (has_lines, has_arcs, sys_argv ) values (?, ?, ?)" ,
230
- (self . _has_lines , self . _has_arcs , str (getattr (sys , 'argv' , None )))
233
+ "insert into meta (key, value ) values (?, ?)" ,
234
+ ('sys_argv' , str (getattr (sys , 'argv' , None )))
231
235
)
232
236
233
237
def _open_db (self ):
@@ -254,8 +258,9 @@ def _read_db(self):
254
258
)
255
259
)
256
260
257
- for row in db .execute ("select has_lines, has_arcs from meta" ):
258
- self ._has_lines , self ._has_arcs = row
261
+ for row in db .execute ("select value from meta where key = 'has_arcs'" ):
262
+ self ._has_arcs = bool (int (row [0 ]))
263
+ self ._has_lines = not self ._has_arcs
259
264
260
265
for path , id in db .execute ("select path, id from file" ):
261
266
self ._file_map [path ] = id
@@ -419,7 +424,10 @@ def _choose_lines_or_arcs(self, lines=False, arcs=False):
419
424
self ._has_lines = lines
420
425
self ._has_arcs = arcs
421
426
with self ._connect () as con :
422
- con .execute ("update meta set has_lines = ?, has_arcs = ?" , (lines , arcs ))
427
+ con .execute (
428
+ "insert into meta (key, value) values (?, ?)" ,
429
+ ('has_arcs' , str (int (arcs )))
430
+ )
423
431
424
432
def add_file_tracers (self , file_tracers ):
425
433
"""Add per-file plugin information.
0 commit comments