@@ -2892,6 +2892,44 @@ mod tests {
2892
2892
Ok ( ( ) )
2893
2893
}
2894
2894
2895
+ #[ test]
2896
+ fn test_drop_table_is_transactional ( ) -> ResultTest < ( ) > {
2897
+ let ( datastore, mut tx, table_id) = setup_table ( ) ?;
2898
+
2899
+ // Insert a row and commit.
2900
+ insert ( & datastore, & mut tx, table_id, & random_row ( ) ) ?;
2901
+ commit ( & datastore, tx) ?;
2902
+
2903
+ // Create a transaction and drop the table and roll back.
2904
+ let mut tx = begin_mut_tx ( & datastore) ;
2905
+ assert ! ( datastore. drop_table_mut_tx( & mut tx, table_id) . is_ok( ) ) ;
2906
+ datastore. rollback_mut_tx ( tx) ;
2907
+
2908
+ // Ensure the table still exists in the next transaction.
2909
+ let tx = begin_mut_tx ( & datastore) ;
2910
+ assert ! (
2911
+ datastore. table_id_exists_mut_tx( & tx, & table_id) ,
2912
+ "Table should still exist" ,
2913
+ ) ;
2914
+
2915
+ Ok ( ( ) )
2916
+ }
2917
+
2918
+ #[ test]
2919
+ fn test_create_table_is_transactional ( ) -> ResultTest < ( ) > {
2920
+ // Create a table in a failed transaction.
2921
+ let ( datastore, tx, table_id) = setup_table ( ) ?;
2922
+ datastore. rollback_mut_tx ( tx) ;
2923
+
2924
+ // Nothing should have happened.
2925
+ let tx = begin_mut_tx ( & datastore) ;
2926
+ assert ! (
2927
+ !datastore. table_id_exists_mut_tx( & tx, & table_id) ,
2928
+ "Table should not exist"
2929
+ ) ;
2930
+ Ok ( ( ) )
2931
+ }
2932
+
2895
2933
// TODO: Add the following tests
2896
2934
// - Create index with unique constraint and immediately insert a row that violates the constraint before committing.
2897
2935
// - Create a tx that inserts 2000 rows with an auto_inc column
0 commit comments