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, UpgradeTable tbl)
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

upgradeV16
void upgradeV16(Miniorm db)

2020-02-12

upgradeV17
void upgradeV17(Miniorm db)

2020-02-12

upgradeV18
void upgradeV18(Miniorm db)

2020-03-21

upgradeV19
void upgradeV19(Miniorm db)

2020-04-01

upgradeV2
void upgradeV2(Miniorm db)

2018-04-22

upgradeV20
void upgradeV20(Miniorm db)

2020-06-01

upgradeV21
void upgradeV21(Miniorm db)

2020-11-28

upgradeV22
void upgradeV22(Miniorm db)

2020-11-28

upgradeV23
void upgradeV23(Miniorm db)

2020-12-06

upgradeV24
void upgradeV24(Miniorm db)

2020-12-06

upgradeV25
void upgradeV25(Miniorm db)

2020-12-25

upgradeV26
void upgradeV26(Miniorm db)

2020-12-25

upgradeV27
void upgradeV27(Miniorm db)

2020-12-25

upgradeV28
void upgradeV28(Miniorm db)

2020-12-25

upgradeV29
void upgradeV29(Miniorm db)

2020-12-27

upgradeV3
void upgradeV3(Miniorm db)

2018-09-01

upgradeV30
void upgradeV30(Miniorm db)

2020-12-29

upgradeV31
void upgradeV31(Miniorm db)

2020-12-29

upgradeV32
void upgradeV32(Miniorm db)

2021-01-02

upgradeV33
void upgradeV33(Miniorm db)

2021-01-15

upgradeV34
void upgradeV34(Miniorm db)

2021-03-14

upgradeV35
void upgradeV35(Miniorm db)

2021-03-28

upgradeV36
void upgradeV36(Miniorm db)

2021-03-29

upgradeV37
void upgradeV37(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV38
void upgradeV38(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV39
void upgradeV39(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV4
void upgradeV4(Miniorm db)

2018-09-24

upgradeV40
void upgradeV40(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV41
void upgradeV41(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV42
void upgradeV42(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV43
void upgradeV43(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV44
void upgradeV44(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV45
void upgradeV45(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
upgradeV46
void upgradeV46(Miniorm db)
Undocumented in source. Be warned that the author may not have intended to support it.
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.

CoverageCodeRegionTable
struct CoverageCodeRegionTable

All functions that has been discovered in the source code. The offset_begin is where instrumentation points can be injected.

CoverageInfoTable
struct CoverageInfoTable

Each coverage region that has a valid status has an entry in this table. It do mean that there can be region that do not exist in this table. That mean that something went wrong when gathering the data.

CoverageTimeTtampTable
struct CoverageTimeTtampTable

When the coverage information was gathered.

DependencyFileTable
struct DependencyFileTable

Files that roots are dependent on. They do not need to contain mutants.

DependencyRootTable
struct DependencyRootTable
Undocumented in source.
DextoolVersionTable
struct DextoolVersionTable
Undocumented in source.
FilesTbl
struct FilesTbl
Undocumented in source.
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

Timeout mutants that are re-tested until none of them change status from timeout.

MutantWorklistTbl
struct MutantWorklistTbl

Mutants that should be tested.

MutationPointTbl
struct MutationPointTbl

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

MutationScoreHistoryTable
struct MutationScoreHistoryTable
Undocumented in source.
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. compile_time_ms = time it took to compile the program for the mutant test_time_ms = time it took to run the test suite updated_ts = is when the status where last updated. Seconds at UTC+0. added_ts = when the mutant where added to the system. UTC+0.

MutationTbl
struct MutationTbl
Undocumented in source.
NomutDataTbl
struct NomutDataTbl
Undocumented in source.
NomutTbl
struct NomutTbl
Undocumented in source.
RawSrcMetadata
struct RawSrcMetadata
Undocumented in source.
RuntimeHistoryTable
struct RuntimeHistoryTable

The runtime of the test commands.

SchemaMutantKindQTable
struct SchemaMutantKindQTable
Undocumented in source.
SchemaSizeQTable
struct SchemaSizeQTable
Undocumented in source.
SchemataFragmentTable
struct SchemataFragmentTable
Undocumented in source.
SchemataMutantTable
struct SchemataMutantTable
Undocumented in source.
SchemataTable
struct SchemataTable
Undocumented in source.
SchemataUsedTable
struct SchemataUsedTable
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.

TestCmdMutatedTable
struct TestCmdMutatedTable
Undocumented in source.
TestCmdOriginalTable
struct TestCmdOriginalTable
Undocumented in source.
TestFilesTable
struct TestFilesTable
Undocumented in source.
UpgradeTable
struct UpgradeTable
Undocumented in source.
VersionTbl
struct VersionTbl
Undocumented in source.

Variables

allTestCaseTable
auto allTestCaseTable;
Undocumented in source.
depFileTable
auto depFileTable;
Undocumented in source.
depRootTable
auto depRootTable;
Undocumented in source.
dextoolVersionTable
auto dextoolVersionTable;
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.
mutantWorklistTable
auto mutantWorklistTable;
Undocumented in source.
mutationPointTable
auto mutationPointTable;
Undocumented in source.
mutationScoreHistoryTable
auto mutationScoreHistoryTable;
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.
runtimeHistoryTable
auto runtimeHistoryTable;
Undocumented in source.
schemaMutantQTable
auto schemaMutantQTable;
Undocumented in source.
schemaSizeQTable
auto schemaSizeQTable;
Undocumented in source.
schemaVersionTable
auto schemaVersionTable;
Undocumented in source.
schemataFragmentTable
auto schemataFragmentTable;
Undocumented in source.
schemataMutantTable
auto schemataMutantTable;
Undocumented in source.
schemataTable
auto schemataTable;
Undocumented in source.
schemataUsedTable
auto schemataUsedTable;
Undocumented in source.
srcCovInfoTable
auto srcCovInfoTable;
Undocumented in source.
srcCovTable
auto srcCovTable;
Undocumented in source.
srcCovTimeStampTable
auto srcCovTimeStampTable;
Undocumented in source.
srcMetadataTable
auto srcMetadataTable;
Undocumented in source.
testCmdMutatedTable
auto testCmdMutatedTable;
Undocumented in source.
testCmdOriginalTable
auto testCmdOriginalTable;
Undocumented in source.
testFilesTable
auto testFilesTable;
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.

ON DELETE CASCADE

when a ON DELETE CASCADE is added an index should be created too of the childs foreign key.

From the sqlite documentation:

Indices are not required for child key columns but they are almost always beneficial. […]

Each time an application deletes a row from the ... parent table, it performs [a query] to search for referencing rows in the ... child table.

If this query returns any rows at all, then SQLite concludes that deleting the row from the parent table would violate the foreign key constraint and returns an error. Similar queries may be run if the content of the parent key is modified or a new row is inserted into the parent table. If these queries cannot use an index, they are forced to do a linear scan of the entire child table. In a non-trivial database, this may be prohibitively expensive.

So, in most real systems, an index should be created on the child key columns of each foreign key constraint. The child key index does not have to be (and usually will not be) a UNIQUE index.