dextool.plugin.mutate.backend.database.schema

Members

Functions

getSchemaVersion
long getSchemaVersion(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
initializeDB
Miniorm initializeDB(string p)

Initialize or open an existing database.

makeUpgradeTable
UpgradeTable makeUpgradeTable()

Inspects a module for functions starting with upgradeV to create a table of functions that can be used to upgrade a database.

replaceTbl
void replaceTbl(Miniorm db, string src, string dst)
Undocumented in source. Be warned that the author may not have intended to support it.
updateSchemaVersion
void updateSchemaVersion(Miniorm db, long ver)
Undocumented in source. Be warned that the author may not have intended to support it.
upgrade
void upgrade(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV0
void upgradeV0(Miniorm db)

If the database start it version 0, not initialized, then initialize to the latest schema version.

upgradeV1
void upgradeV1(Miniorm db)

2018-04-08

upgradeV10
void upgradeV10(Miniorm db)

2018-11-25

upgradeV11
void upgradeV11(Miniorm db)

2019-04-06

upgradeV12
void upgradeV12(Miniorm db)

2019-08-28

upgradeV13
void upgradeV13(Miniorm db)

2019-11-12

upgradeV14
void upgradeV14(Miniorm db)

2020-01-12

upgradeV15
void upgradeV15(Miniorm db)

2020-01-21

upgradeV2
void upgradeV2(Miniorm db)

2018-04-22

upgradeV3
void upgradeV3(Miniorm db)

2018-09-01

upgradeV4
void upgradeV4(Miniorm db)

2018-09-24

upgradeV5
void upgradeV5(Miniorm db)

2018-09-30

upgradeV6
void upgradeV6(Miniorm db)

2018-10-11

upgradeV7
void upgradeV7(Miniorm db)

2018-10-15

upgradeV8
void upgradeV8(Miniorm db)

2018-10-20

upgradeV9
void upgradeV9(Miniorm db)

2018-11-10

Structs

AllTestCaseTbl
struct AllTestCaseTbl

Track all test cases that has been found by the test suite output analyzer. Useful to find test cases that has never killed any mutant. name should match test_case_killed_v2_tbl TODO: name should be the primary key. on a conflict a counter should be updated.

FilesTbl
struct FilesTbl

checksum is 128bit. Using a integer to better represent and search for them in queries.

MarkedMutantTbl
struct MarkedMutantTbl

The lower 64bit of the checksum should be good enough as the primary key. By doing it this way it is easier to update a marked mutant without "peeking" in the database ("insert or update").

MutantTimeoutCtxTbl
struct MutantTimeoutCtxTbl

The defaults for the schema is the state that the state machine start in.

MutantTimeoutWorklistTbl
struct MutantTimeoutWorklistTbl
Undocumented in source.
MutationPointTbl
struct MutationPointTbl

there shall never exist two mutations points for the same file+offset.

MutationStatusTbl
struct MutationStatusTbl

the status of a mutant. if it is killed or otherwise. multiple mutation operators can result in the same change of the source code. By coupling the mutant status to the checksum of the source code change it means that two mutations that have the same checksum will "cooperate". TODO: change the checksum to being NOT NULL in the future. Can't for now when migrating to schema version 5->6. time = ms spent on verifying the mutant timestamp = is when the status where last updated. Seconds at UTC+0. added_ts = when the mutant where added to the system. UTC+0. test_cnt = nr of times the mutant has been tested without being killed.

MutationTbl
struct MutationTbl
Undocumented in source.
NomutDataTbl
struct NomutDataTbl
Undocumented in source.
NomutTbl
struct NomutTbl
Undocumented in source.
RawSrcMetadata
struct RawSrcMetadata
Undocumented in source.
SrcMetadataTable
struct SrcMetadataTable
Undocumented in source.
TestCaseKilledTbl
struct TestCaseKilledTbl

This could use an intermediate adapter table to normalise the test_case data but I chose not to do that because it makes it harder to add test cases and do a cleanup.

UpgradeTable
struct UpgradeTable
Undocumented in source.
VersionTbl
struct VersionTbl
Undocumented in source.

Variables

allTestCaseTable
auto allTestCaseTable;
Undocumented in source.
filesTable
auto filesTable;
Undocumented in source.
killedTestCaseTable
auto killedTestCaseTable;
Undocumented in source.
markedMutantTable
auto markedMutantTable;
Undocumented in source.
mutantTimeoutCtxTable
auto mutantTimeoutCtxTable;
Undocumented in source.
mutantTimeoutWorklistTable
auto mutantTimeoutWorklistTable;
Undocumented in source.
mutationPointTable
auto mutationPointTable;
Undocumented in source.
mutationStatusTable
auto mutationStatusTable;
Undocumented in source.
mutationTable
auto mutationTable;
Undocumented in source.
nomutDataTable
auto nomutDataTable;
Undocumented in source.
nomutTable
auto nomutTable;
Undocumented in source.
rawSrcMetadataTable
auto rawSrcMetadataTable;
Undocumented in source.
schemaVersionTable
auto schemaVersionTable;
Undocumented in source.
srcMetadataTable
auto srcMetadataTable;
Undocumented in source.

Meta

License

MPL-2

Authors

Joakim Brännström (joakim.brannstrom@gmx.com)

This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

This module contains the schema to initialize the database.

To ensure that the upgrade path for a database always work a database is created at the "lowest supported" and upgraded to the latest.

How to add schema change

1. add an upgrade function, upgradeVX.

The function makeUpgradeTable will then automatically find it and use it. X **must** be the version upgrading FROM.

# Style A database schema upgrade path shall have a comment stating what date it was added. Each change to the database schema must have an equal upgrade added.

# Sqlite3 From the sqlite3 manual https://www.sqlite.org/datatype3.html: Each value stored in an SQLite database (or manipulated by the database engine) has one of the following storage classes:

NULL. The value is a NULL value.

INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.

REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number.

TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).

BLOB. The value is a blob of data, stored exactly as it was input.

A storage class is more general than a datatype. The INTEGER storage class, for example, includes 6 different integer datatypes of different lengths. This makes a difference on disk. But as soon as INTEGER values are read off of disk and into memory for processing, they are converted to the most general datatype (8-byte signed integer). And so for the most part, "storage class" is indistinguishable from "datatype" and the two terms can be used interchangeably.