SLIDE 1 The Impact of Equivalent, Redundant and Quasi Mutants on Database Schema Mutation Analysis
Chris J. Wright Gregory M. Kapfhammer Phil McMinn
SLIDE 2 The Impact of Equivalent, Redundant and Quasi Mutants on Database Schema Mutation Analysis
Chris J. Wright Gregory M. Kapfhammer Phil McMinn
SLIDE 3 The Impact of Equivalent, Redundant and Quasi Mutants on Database Schema Mutation Analysis
Chris J. Wright Gregory M. Kapfhammer Phil McMinn
SLIDE 4 The Impact of Equivalent, Redundant and Quasi Mutants on Database Schema Mutation Analysis
Chris J. Wright Gregory M. Kapfhammer Phil McMinn
SLIDE 5 The Impact of Equivalent, Redundant and Quasi Mutants on Database Schema Mutation Analysis
Chris J. Wright Gregory M. Kapfhammer Phil McMinn
SLIDE 6 The Impact of Equivalent, Redundant and Quasi Mutants on Database Schema Mutation Analysis
Chris J. Wright Gregory M. Kapfhammer Phil McMinn
SLIDE 7
SLIDE 8
Database Schema
SLIDE 9 Database Schema
1 CREATE TABLE T ( 2 A CHAR, B CHAR, C CHAR, 3 CONSTRAINT UniqueOnColsAandB UNIQUE (A, B) 4 ); 5 6 CREATE TABLE S ( 7 X CHAR, Y CHAR, Z CHAR, 8 CONSTRAINT RefToColsAandB FOREIGN KEY (X, Y) 9 REFERENCES T (A, B) 10 );
SLIDE 10 Database Schema
1 CREATE TABLE T ( 2 A CHAR, B CHAR, C CHAR, 3 CONSTRAINT UniqueOnColsAandB UNIQUE (A, B) 4 ); 5 6 CREATE TABLE S ( 7 X CHAR, Y CHAR, Z CHAR, 8 CONSTRAINT RefToColsAandB FOREIGN KEY (X, Y) 9 REFERENCES T (A, B) 10 );
Tables
SLIDE 11 Database Schema
1 CREATE TABLE T ( 2 A CHAR, B CHAR, C CHAR, 3 CONSTRAINT UniqueOnColsAandB UNIQUE (A, B) 4 ); 5 6 CREATE TABLE S ( 7 X CHAR, Y CHAR, Z CHAR, 8 CONSTRAINT RefToColsAandB FOREIGN KEY (X, Y) 9 REFERENCES T (A, B) 10 );
Columns
SLIDE 12 Database Schema
1 CREATE TABLE T ( 2 A CHAR, B CHAR, C CHAR, 3 CONSTRAINT UniqueOnColsAandB UNIQUE (A, B) 4 ); 5 6 CREATE TABLE S ( 7 X CHAR, Y CHAR, Z CHAR, 8 CONSTRAINT RefToColsAandB FOREIGN KEY (X, Y) 9 REFERENCES T (A, B) 10 );
Constraints
SLIDE 13
Why Test a Database Schema?
SLIDE 14 Why Test a Database Schema?
Database Schema
SLIDE 15 Why Test a Database Schema?
DBMS Database Schema
SLIDE 16 Why Test a Database Schema?
DBMS
Database Schema
SLIDE 17 Why Test a Database Schema?
DBMS Application Web Server Third Party
Database Schema
SLIDE 18 Why Test a Database Schema?
DBMS Application Web Server Third Party
Database Schema
✗ ✗ ✗ ✗
SLIDE 19
How to Test a Database Schema
SLIDE 20 How to Test a Database Schema
- Generate test data – SQL INSERT statements
SLIDE 21 How to Test a Database Schema
- Generate test data – SQL INSERT statements
INSERT INTO T(a, b) VALUES('a', 'b');
SLIDE 22 How to Test a Database Schema
- Generate test data – SQL INSERT statements
INSERT INTO T(a, b) VALUES('a', 'b');
SLIDE 23 How to Test a Database Schema
- Generate test data – SQL
- Execute the data against the database
INSERT INTO T(a, b) VALUES('a', 'b');
DBMS
SLIDE 24 How to Test a Database Schema
- Generate test data – SQL
- Execute the data against the database
- Examine the acceptance of statements
INSERT INTO T(a, b) VALUES('a', 'b');
DBMS
✗
✓/
SLIDE 25
Mutation Analysis
SLIDE 26 Mutation Analysis
Application
SLIDE 27 Mutation Analysis
Application
Mutation Operators
SLIDE 28 Mutation Analysis
Application Mutants
Mutation Operators
SLIDE 29 Mutation Analysis
Application Mutants
Mutation Operators Test suite
SLIDE 30 Mutation Analysis
Application Mutants
Mutation Operators Test suite
Test results
SLIDE 31 Mutation Analysis
Application Mutants
Mutation Operators Test suite Test suite
Test results
SLIDE 32 Mutation Analysis
Application Mutants
Mutation Operators Test suite Test suite
Test results Test results
SLIDE 33 Mutation Analysis
Application Mutants
Mutation Operators Test suite Test suite
Test results Test results
Comparison
SLIDE 34 Mutation Analysis
Application Mutants
Mutation Operators Test suite Test suite
Test results Test results
Comparison
Mutation Score
SLIDE 35 Mutation Analysis
Application Mutants
Mutation Operators Test suite Test suite
Test results Test results
Comparison
Mutation Score
SLIDE 36
Database Schema Mutation Operators
SLIDE 37 Database Schema Mutation Operators
Primary Key Foreign Key Unique Not Null Check
SLIDE 38 Database Schema Mutation Operators
Primary Key Foreign Key Unique Not Null Check
×
SLIDE 39 Database Schema Mutation Operators
Primary Key Foreign Key Unique Not Null Check Column Addition
×
SLIDE 40 Database Schema Mutation Operators
Primary Key Foreign Key Unique Not Null Check Column Addition Column Removal
×
SLIDE 41 Database Schema Mutation Operators
Primary Key Foreign Key Unique Not Null Check Column Addition Column Removal Column Exchange
×
SLIDE 42
Database Schema Mutation Operators
SLIDE 43 Database Schema Mutation Operators
Primary Key Column Addition
SLIDE 44 Database Schema Mutation Operators
Primary Key Column Addition
1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 PRIMARY KEY (A) 4 );
SLIDE 45 Database Schema Mutation Operators
Primary Key Column Addition
1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 PRIMARY KEY (A) 4 ); 1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 PRIMARY KEY (A, B) 4 );
SLIDE 46 Database Schema Mutation Operators
Primary Key Column Exchange
1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 PRIMARY KEY (A) 4 ); 1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 PRIMARY KEY (B) 4 );
SLIDE 47 Database Schema Mutation Operators
Primary Key Column Removal
1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 PRIMARY KEY (A) 4 ); 1 CREATE TABLE T ( 2 A CHAR, B CHAR, 3 4 );
SLIDE 48
Mutation Analysis – Challenges
SLIDE 49 Mutation Analysis – Challenges
- Special classes of mutants
SLIDE 50 Mutation Analysis – Challenges
- Special classes of mutants
- Equivalent
SLIDE 51 Mutation Analysis – Challenges
- Special classes of mutants
- Equivalent
- Redundant
SLIDE 52 Mutation Analysis – Challenges
- Special classes of mutants
- Equivalent
- Redundant
- Quasi-mutants
SLIDE 53 Mutation Analysis – Challenges
- Special classes of mutants
- Equivalent
- Redundant
- Quasi-mutants
SLIDE 54
Equivalent Mutants
SLIDE 55 Equivalent Mutants
- Functionally identical to non-mutant
SLIDE 56 Equivalent Mutants
- Functionally identical to non-mutant
- …but syntactically different
SLIDE 57 Equivalent Mutants
- Functionally identical to non-mutant
- …but syntactically different
- Cannot be ‘killed’
SLIDE 58 Equivalent Mutants
- Functionally identical to non-mutant
- …but syntactically different
- Cannot be ‘killed’
- Artificially decrease mutation score
SLIDE 59 Equivalent Mutants
- Functionally identical to non-mutant
- …but syntactically different
- Cannot be ‘killed’
- Artificially decrease mutation score
SLIDE 60
Equivalent Mutants
SLIDE 61 Equivalent Mutants
1 CREATE TABLE T ( 2 A CHAR, 3 PRIMARY KEY (A) 4 );
Original:
SLIDE 62 Equivalent Mutants
1 CREATE TABLE T ( 2 A CHAR, 3 PRIMARY KEY (A) 4 ); 1 CREATE TABLE T ( 2 A CHAR NOT NULL, 3 PRIMARY KEY (A) 4 );
Original: Mutant:
SLIDE 63
Redundant Mutants
SLIDE 64 Redundant Mutants
- Functionally identical to another mutant
SLIDE 65 Redundant Mutants
- Functionally identical to
- …but syntactically different
SLIDE 66 Redundant Mutants
- Functionally identical to
- …but syntactically different
- May be ‘killed’
SLIDE 67 Redundant Mutants
- Functionally identical to
- …but syntactically different
- May be ‘killed’
- Artificially alters mutation score
SLIDE 68 Redundant Mutants
- Functionally identical to
- …but syntactically different
- May be ‘killed’
- Artificially alters mutation score
- Reduces efficiency
SLIDE 69 Redundant Mutants
- Functionally identical to
- …but syntactically different
- May be ‘killed’
- Artificially alters mutation score
- Reduces efficiency
SLIDE 70
Types of Equivalence
SLIDE 71 Types of Equivalence
SLIDE 72 Types of Equivalence
- Structural
- Functionally irrelevant syntactic differences
SLIDE 73 Types of Equivalence
- Structural
- Functionally irrelevant syntactic differences
SLIDE 74 Types of Equivalence
- Structural
- Functionally irrelevant syntactic differences
- Behavioural
SLIDE 75 Types of Equivalence
- Structural
- Functionally irrelevant syntactic differences
- Behavioural
- Overlap within SQL features
SLIDE 76 Types of Equivalence
- Structural
- Functionally irrelevant syntactic differences
- Behavioural
- Overlap within SQL features
SLIDE 77
Behavioural Equivalence Patterns
SLIDE 78 Behavioural Equivalence Patterns
- NOT NULL in CHECK constraints
- NOT NULL ≅ CHECK(… IS NOT NULL)
SLIDE 79 Behavioural Equivalence Patterns
- NOT NULL in CHECK constraints
- NOT NULL ≅ CHECK(… IS NOT NULL)
1 CREATE TABLE T ( 2 A CHAR NOT NULL, 3 ); 1 CREATE TABLE T ( 2 A CHAR, 3 CHECK(A IS NOT NULL) 4 );
SLIDE 80
Behavioural Equivalence Patterns
SLIDE 81 Behavioural Equivalence Patterns
- NOT NULL on PRIMARY KEY columns
SLIDE 82 Behavioural Equivalence Patterns
- NOT NULL on PRIMARY KEY columns
- Implicit NOT NULL on PRIMARY KEY
SLIDE 83 Behavioural Equivalence Patterns
- NOT NULL on PRIMARY KEY columns
- Implicit NOT NULL on PRIMARY KEY
- (Only PostgreSQL and HyperSQL)
SLIDE 84 Behavioural Equivalence Patterns
- NOT NULL on PRIMARY KEY columns
SLIDE 85 Behavioural Equivalence Patterns
- NOT NULL on PRIMARY KEY columns
1 CREATE TABLE T ( 2 A CHAR, 3 PRIMARY KEY (A) 4 ); 1 CREATE TABLE T ( 2 A CHAR NOT NULL, 3 PRIMARY KEY (A) 4 );
SLIDE 86
Behavioural Equivalence Patterns
SLIDE 87 Behavioural Equivalence Patterns
- UNIQUE and PRIMARY KEY with shared
columns
SLIDE 88 Behavioural Equivalence Patterns
- UNIQUE and PRIMARY KEY with shared
columns
1 CREATE TABLE T ( 2 A CHAR, 3 PRIMARY KEY (A) 4 ); 1 CREATE TABLE T ( 2 A CHAR, 3 PRIMARY KEY (A), 4 UNIQUE (A) 5 );
SLIDE 89
Quasi-mutants
SLIDE 90 Quasi-mutants
- Operators produce DBMS-agnostic mutants
SLIDE 91 Quasi-mutants
- Operators produce DBMS-agnostic mutants
- Some DBMSs have implicit constraints
SLIDE 92 Quasi-mutants
- Operators produce DBMS-agnostic mutants
- Some DBMSs have implicit constraints
- Valid for some DBMSs, invalid for others
HyperSQL PostgreSQL SQLite✓
✗ ✗
SLIDE 93 Quasi-mutants
- Operators produce DBMS-agnostic mutants
- Some DBMSs have implicit constraints
- Valid for some DBMSs, invalid for others
- HyperSQL
PostgreSQL SQLite✓
✗ ✗
SLIDE 94 Quasi-mutants
SQLite✓ PostgreSQL
✗
HyperSQL✗
SLIDE 95 Quasi-mutants
- Cannot adversely affect mutation score
SQLite✓ PostgreSQL
✗
HyperSQL✗
SLIDE 96 Quasi-mutants
- Cannot adversely affect mutation score
- …but may preclude some optimisations
SQLite✓ PostgreSQL
✗
HyperSQL✗
SLIDE 97 Quasi-mutants
- Cannot adversely affect mutation score
- …but may preclude some optimisations
- Remove when DBMS will ‘reject’ them
SQLite✓ PostgreSQL
✗
HyperSQL✗
SLIDE 98
Types of Quasi-mutants
SLIDE 99 Types of Quasi-mutants
SLIDE 100 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
SLIDE 101 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
- ∀ FK(reference columns) ∃
(PK(reference columns) ∨
Unique(reference columns))
SLIDE 102 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
- ∀ FK(reference columns) ∃
(PK(reference columns) ∨
Unique(reference columns))
SLIDE 103 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
- ∀ FK(reference columns) ∃
(PK(reference columns) ∨
Unique(reference columns))
SLIDE 104 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
- ∀ FK(reference columns) ∃
(PK(reference columns) ∨
Unique(reference columns))
SLIDE 105 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
- ∀ FK(reference columns) ∃
(PK(reference columns) ∨
Unique(reference columns))
SLIDE 106 Types of Quasi-mutants
- Representative example
- DBMS: PostgreSQL, HyperSQL
- ∀
(PK(reference columns) Unique(reference
SLIDE 107
Detecting Quasi-mutants
SLIDE 108 Detecting Quasi-mutants
SLIDE 109 Detecting Quasi-mutants
- Submit to DBMS
- 100% accurate
SLIDE 110 Detecting Quasi-mutants
- Submit to DBMS
- 100% accurate
- Convert representation to SQL, submit to database,
inspect response
SLIDE 111 Detecting Quasi-mutants
- Submit to DBMS
- 100% accurate
- Convert representation to SQL, submit to database,
inspect response
SLIDE 112 Detecting Quasi-mutants
- Submit to DBMS
- 100% accurate
- Convert representation to SQL, submit to database,
inspect response
- Analyse statically
- Operates directly on representation
SLIDE 113 Detecting Quasi-mutants
- Submit to DBMS
- 100% accurate
- Convert representation to SQL, submit to database,
inspect response
- Analyse statically
- Operates directly on representation
- DBMS-specific implementation
SLIDE 114
Empirical Study
SLIDE 115 Empirical Study
- 1. Quasi-mutant detection – DBMS v Static Analysis
SLIDE 116 Empirical Study
- 1. Quasi-mutant detection – DBMS v Static Analysis
- 2. Equivalent, Redundant and Quasi-mutant
removal – Efficiency?
SLIDE 117 Empirical Study
- 1. Quasi-mutant detection – DBMS v Static Analysis
- 2. Equivalent, Redundant and Quasi-mutant
removal – Efficiency?
- 3. Equivalent, Redundant and Quasi-mutant
removal – Effectiveness?
SLIDE 118
Empirical Study
SLIDE 119 Empirical Study
SLIDE 120 Empirical Study
- 16 schemas
- 2 DBMSs – PostgreSQL, HyperSQL
SLIDE 121 Empirical Study
- 16 schemas
- 2 DBMSs – PostgreSQL, HyperSQL
- 15 repeat trials
SLIDE 122 Empirical Study
- 16 schemas
- 2 DBMSs – PostgreSQL, HyperSQL
- 15 repeat trials
SLIDE 123
Empirical Study – Quasi-mutants
SLIDE 124 Empirical Study – Quasi-mutants
SLIDE 125 Empirical Study – Quasi-mutants
- 5 conditions:
- Postgres (with/without transactions)
SLIDE 126 Empirical Study – Quasi-mutants
- 5 conditions:
- Postgres (with/without transactions)
- HyperSQL (with/without transactions)
SLIDE 127 Empirical Study – Quasi-mutants
- 5 conditions:
- Postgres (with/without transactions)
- HyperSQL (with/without transactions)
- Static analysis
SLIDE 128 Empirical Study – Quasi-mutants
- 5 conditions:
- Postgres (with/without transactions)
- HyperSQL (with/without transactions)
- Static analysis
SLIDE 129 Empirical Study – Quasi-mutants
0.25 0.50 0.75 1.00 1.25 HyperSQL HyperSQL Trans. Postgres Postgres Trans. Static
Approach Scaled Time Taken
SLIDE 130
Empirical Study – Mutant Removal
SLIDE 131 Empirical Study – Mutant Removal
- 2 conditions – with and without removal
SLIDE 132 Empirical Study – Mutant Removal
- 2 conditions – with and without removal
- 2 metrics –
SLIDE 133 Empirical Study – Mutant Removal
- 2 conditions – with and without removal
- 2 metrics –
- Time taken for mutation analysis
SLIDE 134 Empirical Study – Mutant Removal
- 2 conditions – with and without removal
- 2 metrics –
- Time taken for mutation analysis
- Mutation score
SLIDE 135
Empirical Study – Mutant Removal
SLIDE 136
- HyperSQL – Time saved
- Best case: 718ms (23.05%)
- Worst case: -824ms (-9.71%)
Empirical Study – Mutant Removal
SLIDE 137
Empirical Study – Mutant Removal
SLIDE 138
Empirical Study – Mutant Removal
SLIDE 139
- HyperSQL – Time saved
- 9/16 mean time decrease (p < 0.05)
Empirical Study – Mutant Removal
SLIDE 140
- HyperSQL – Time saved
- 9/16 mean time decrease (
- 7/16 mean time increase (p < 0.05)
Empirical Study – Mutant Removal
SLIDE 141
- HyperSQL – Time saved
- 9/16 mean time decrease (
- 7/16 mean time increase (
- Overall, decrease (1.6% mean, 1.4% median)
Empirical Study – Mutant Removal
SLIDE 142
Empirical Study – Mutant Removal
SLIDE 143
- PostgreSQL – Time saved
- Best case: 317,208ms (33.71%)
- Worst case: -3,086ms, (-0.33%)
Empirical Study – Mutant Removal
SLIDE 144
Empirical Study – Mutant Removal
SLIDE 145
Empirical Study – Mutant Removal
SLIDE 146
- PostgreSQL – Time saved
- 14/16 mean time decrease (p < 0.05)
Empirical Study – Mutant Removal
SLIDE 147
- PostgreSQL – Time saved
- 14/16 mean time decrease (
- 2/16 mean time increase (p < 0.05)
Empirical Study – Mutant Removal
SLIDE 148
- PostgreSQL – Time saved
- 14/16 mean time decrease (
- 2/16 mean time increase (
- Overall, decrease (12.7% mean, 11.8% median)
Empirical Study – Mutant Removal
SLIDE 149 Empirical Study – Mutant Removal
DBMS Time saved (ms) Median Mean
SLIDE 150 Empirical Study – Mutant Removal
DBMS Time saved (ms) Median Mean HyperSQL 36.2 7.5
SLIDE 151 Empirical Study – Mutant Removal
DBMS Time saved (ms) Median Mean HyperSQL 36.2 7.5 Postgres 8,071 50,880
SLIDE 152 Empirical Study – Mutant Removal
DBMS Time saved (ms) Median Mean HyperSQL 36.2 7.5 Postgres 8,071 50,880 Both 229.9 25,450
SLIDE 153 Empirical Study – Mutant Removal
DBMS Time saved (%) Median Mean HyperSQL 1.4 1.6 Postgres 12.7 11.8 Both 4.7 6.7
SLIDE 154
Empirical Study – Mutant Removal
SLIDE 155
- HyperSQL – Mutation score
- 75% Increased
- 44% Adequate
- 25% No change
Empirical Study – Mutant Removal
SLIDE 156
- PostgreSQL – Mutation score
- 75% Increased
- 44% Adequate
- 25% No change
Empirical Study – Mutant Removal
SLIDE 157 Empirical Study – Mutant Removal
DBMS Scores changed (%) Increased (adequate) No change HyperSQL 75 (44) 25 Postgres 75 (44) 25 Both 75 (44) 25
SLIDE 158 Conclusion
- 1. Quasi-mutant detection – DBMS v Static Analysis
- 2. Equivalent, Redundant and Quasi-mutant
removal – Efficiency?
- 3. Equivalent, Redundant and Quasi-mutant
removal – Effectiveness?
SLIDE 159 Conclusion
- 1. Quasi-mutant detection – DBMS v Static Analysis
- 2. Equivalent, Redundant and Quasi-mutant
removal – Efficiency?
- 3. Equivalent, Redundant and Quasi-mutant
removal – Effectiveness?
SLIDE 160 Conclusion
- 1. Quasi-mutant detection – DBMS v Static Analysis
- 2. Equivalent, Redundant and Quasi-mutant
removal – Efficiency?
- 3. Equivalent, Redundant and Quasi-mutant
removal – Effectiveness?
SLIDE 161 Conclusion
- 1. Quasi-mutant detection – Improved efficiency
- 2. Equivalent, Redundant and Quasi-mutant
removal – Improved efficiency
- 3. Equivalent, Redundant and Quasi-mutant
removal – Improved effectiveness
SLIDE 162 Conclusion
- 1. Quasi-mutant detection – Improved efficiency
- 2. Equivalent, Redundant and Quasi-mutant
removal – Improved efficiency
- 3. Equivalent, Redundant and Quasi-mutant
removal – Improved effectiveness
Chris J. Wright – aca08cw@sheffield.ac.uk