@@ -63,30 +63,12 @@ protected function createTables(): void
63
63
return ;
64
64
}
65
65
66
- $ this ->unsetStatsExpiry ();
67
66
$ this ->dropTables ();
68
67
$ this ->importSchema ();
69
68
70
69
define ('DB_TEST_TRAIT_INIT ' , 1 );
71
70
}
72
71
73
- /**
74
- * Workaround for MySQL 8: update_time not working.
75
- *
76
- * https://bugs.mysql.com/bug.php?id=95407
77
- *
78
- * @return void
79
- */
80
- private function unsetStatsExpiry ()
81
- {
82
- $ expiry = $ this ->getDatabaseVariable ('information_schema_stats_expiry ' );
83
- $ version = (string )$ this ->getDatabaseVariable ('version ' );
84
-
85
- if ($ expiry !== null && version_compare ($ version , '8.0.0 ' , '>= ' )) {
86
- $ this ->getConnection ()->exec ('SET information_schema_stats_expiry=0; ' );
87
- }
88
- }
89
-
90
72
/**
91
73
* Get database variable.
92
74
*
@@ -196,13 +178,24 @@ protected function truncateTables(): void
196
178
197
179
$ pdo ->exec ('SET unique_checks=0; SET foreign_key_checks=0; ' );
198
180
199
- // Truncate only changed tables
200
- $ statement = $ this ->createQueryStatement (
201
- 'SELECT TABLE_NAME
181
+ $ expiry = $ this ->getDatabaseVariable ('information_schema_stats_expiry ' );
182
+ if ($ expiry === null ) {
183
+ // MariaDB: Truncate only changed tables
184
+ $ statement = $ this ->createQueryStatement (
185
+ 'SELECT TABLE_NAME
202
186
FROM information_schema.tables
203
187
WHERE table_schema = database()
204
- AND update_time IS NOT NULL '
205
- );
188
+ AND (update_time IS NOT NULL OR auto_increment IS NOT NULL) '
189
+ );
190
+ } else {
191
+ // MySQL: Truncate all tables
192
+ // Workaround for MySQL 8: update_time not working.
193
+ // Even SET information_schema_stats_expiry=0; has no affect anymore.
194
+ // https://bugs.mysql.com/bug.php?id=95407
195
+ $ statement = $ this ->createQueryStatement (
196
+ 'SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = database() '
197
+ );
198
+ }
206
199
207
200
$ rows = (array )$ statement ->fetchAll (PDO ::FETCH_ASSOC );
208
201
0 commit comments