@@ -5665,12 +5665,57 @@ public function testDropIndex(): void {
56655665 $ this ->assertQuery ( 'CREATE TABLE t (id INT PRIMARY KEY, val_unique INT UNIQUE, val_index INT) ' );
56665666 $ this ->assertQuery ( 'CREATE INDEX idx_val_index ON t (val_index) ' );
56675667
5668+ // Verify that the indexes were saved in the information schema.
56685669 $ result = $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
56695670 $ this ->assertCount ( 3 , $ result );
56705671 $ this ->assertEquals ( 'PRIMARY ' , $ result [0 ]->Key_name );
56715672 $ this ->assertEquals ( 'val_unique ' , $ result [1 ]->Key_name );
56725673 $ this ->assertEquals ( 'idx_val_index ' , $ result [2 ]->Key_name );
56735674
5675+ // Verify that the indexes exist in the SQLite database.
5676+ $ result = $ this ->engine ->execute_sqlite_query ( "PRAGMA index_list('t') " )->fetchAll ( PDO ::FETCH_ASSOC );
5677+ $ this ->assertCount ( 3 , $ result );
5678+ $ this ->assertEquals ( 't__idx_val_index ' , $ result [0 ]['name ' ] );
5679+ $ this ->assertEquals ( 't__val_unique ' , $ result [1 ]['name ' ] );
5680+ $ this ->assertEquals ( 'sqlite_autoindex_t_1 ' , $ result [2 ]['name ' ] );
5681+
5682+ // DROP the explicitly named index.
56745683 $ this ->assertQuery ( 'DROP INDEX idx_val_index ON t ' );
5684+
5685+ // Verify that the index was removed from the information schema.
5686+ $ result = $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
5687+ $ this ->assertCount ( 2 , $ result );
5688+ $ this ->assertEquals ( 'PRIMARY ' , $ result [0 ]->Key_name );
5689+ $ this ->assertEquals ( 'val_unique ' , $ result [1 ]->Key_name );
5690+
5691+ // Verify that the index was removed from the SQLite database.
5692+ $ result = $ this ->engine ->execute_sqlite_query ( "PRAGMA index_list('t') " )->fetchAll ( PDO ::FETCH_ASSOC );
5693+ $ this ->assertCount ( 2 , $ result );
5694+ $ this ->assertEquals ( 't__val_unique ' , $ result [0 ]['name ' ] );
5695+ $ this ->assertEquals ( 'sqlite_autoindex_t_1 ' , $ result [1 ]['name ' ] );
5696+
5697+ // DROP the UNIQUE index.
5698+ $ this ->assertQuery ( 'DROP INDEX val_unique ON t ' );
5699+
5700+ // Verify that the index was removed from the information schema.
5701+ $ result = $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
5702+ $ this ->assertCount ( 1 , $ result );
5703+ $ this ->assertEquals ( 'PRIMARY ' , $ result [0 ]->Key_name );
5704+
5705+ // Verify that the index was removed from the SQLite database.
5706+ $ result = $ this ->engine ->execute_sqlite_query ( "PRAGMA index_list('t') " )->fetchAll ( PDO ::FETCH_ASSOC );
5707+ $ this ->assertCount ( 1 , $ result );
5708+ $ this ->assertEquals ( 'sqlite_autoindex_t_1 ' , $ result [0 ]['name ' ] );
5709+
5710+ // DROP the PRIMARY KEY index.
5711+ $ this ->assertQuery ( 'DROP INDEX `PRIMARY` ON t ' );
5712+
5713+ // Verify that the index was removed from the information schema.
5714+ $ result = $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
5715+ $ this ->assertCount ( 0 , $ result );
5716+
5717+ // Verify that the index was removed from the SQLite database.
5718+ $ result = $ this ->engine ->execute_sqlite_query ( "PRAGMA index_list('t') " )->fetchAll ( PDO ::FETCH_ASSOC );
5719+ $ this ->assertCount ( 0 , $ result );
56755720 }
56765721}
0 commit comments