You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a5314e3
Browse filesBrowse the repository at this point in the historyBrowse files
Roll back failed OPTIMIZE TABLE and REPAIR TABLE rebuilds (#567)
`OPTIMIZE TABLE` and `REPAIR TABLE` report rebuild errors as result
rows. The surrounding transaction then commits the work completed before
the error, leaving hidden tables or a partly rebuilt table.
This change makes **each table administration operation atomic** with an
internal savepoint. A failed rebuild restores the original schema and
data, while successful rebuilds of other tables are preserved.
Regression tests cover failures while copying rows, dropping the old
table, and recreating indexes, including permanent and temporary tables,
repeated failures, and mixed results. They also verify committed data
when the command is issued inside a transaction.
Fixes#549.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Failed table maintenance operations, including `OPTIMIZE` and
`REPAIR`, now roll back changes for the affected table. This helps
preserve its schema and data after an error, including when an operation
fails while recreating indexes or dropping a table.
* When a statement affects multiple tables, successful operations can be
retained while failed operations are rolled back individually.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
$this->sqlite->query( "SELECT name FROM sqlite_master WHERE type = 'index' AND name IN ('good_before__k', 'good_after__k') ORDER BY name" )->fetchAll( PDO::FETCH_COLUMN )
676
+
);
677
+
$this->assertSame( array( null ), $this->sqlite->query( 'SELECT id FROM bad' )->fetchAll( PDO::FETCH_COLUMN ) );
678
+
$this->assertSame( array(), $this->sqlite->query( "SELECT name FROM sqlite_master WHERE name GLOB '_wp_sqlite_tmp_*'" )->fetchAll( PDO::FETCH_COLUMN ) );
679
+
680
+
// MySQL commits before table administration, so only check the committed result.
681
+
if ( $in_transaction ) {
682
+
$this->assertQuery( 'COMMIT' );
683
+
$this->assertEquals( array( (object) array( 'id' => '1' ) ), $this->assertQuery( 'SELECT id FROM good_before' ) );
0 commit comments