@@ -1857,13 +1857,13 @@ mod tests {
1857
1857
let mut tx = begin_mut_tx ( & datastore) ;
1858
1858
let schema = datastore. schema_for_table_mut_tx ( & tx, table_id) ?;
1859
1859
1860
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
1860
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
1861
1861
let mut dropped_indexes = 0 ;
1862
1862
for ( pos, index) in schema. indexes . iter ( ) . enumerate ( ) {
1863
1863
datastore. drop_index_mut_tx ( & mut tx, index. index_id ) ?;
1864
1864
dropped_indexes += 1 ;
1865
1865
1866
- let psc = & tx. tx_state . pending_schema_changes [ pos] ;
1866
+ let psc = & tx. pending_schema_changes ( ) [ pos] ;
1867
1867
let PendingSchemaChange :: IndexRemoved ( tid, iid, _, schema) = psc else {
1868
1868
panic ! ( "wrong pending schema change: {psc:?}" ) ;
1869
1869
} ;
@@ -1878,7 +1878,7 @@ mod tests {
1878
1878
datastore. commit_mut_tx ( tx) ?;
1879
1879
1880
1880
let mut tx = begin_mut_tx ( & datastore) ;
1881
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
1881
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
1882
1882
assert ! (
1883
1883
datastore. schema_for_table_mut_tx( & tx, table_id) ?. indexes. is_empty( ) ,
1884
1884
"no indexes should be left in the schema post-commit"
@@ -1897,7 +1897,7 @@ mod tests {
1897
1897
true ,
1898
1898
) ?;
1899
1899
assert_matches ! (
1900
- & * tx. tx_state . pending_schema_changes,
1900
+ tx. pending_schema_changes( ) ,
1901
1901
[ PendingSchemaChange :: IndexAdded ( tid, _, Some ( _) ) ]
1902
1902
if * tid == table_id
1903
1903
) ;
@@ -1920,7 +1920,7 @@ mod tests {
1920
1920
datastore. commit_mut_tx ( tx) ?;
1921
1921
1922
1922
let tx = begin_mut_tx ( & datastore) ;
1923
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
1923
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
1924
1924
assert_eq ! (
1925
1925
datastore. schema_for_table_mut_tx( & tx, table_id) ?. indexes,
1926
1926
expected_indexes,
@@ -1935,10 +1935,10 @@ mod tests {
1935
1935
#[ test]
1936
1936
fn test_schema_for_table_rollback ( ) -> ResultTest < ( ) > {
1937
1937
let ( datastore, tx, table_id) = setup_table ( ) ?;
1938
- assert_eq ! ( tx. tx_state . pending_schema_changes. len( ) , 6 ) ;
1938
+ assert_eq ! ( tx. pending_schema_changes( ) . len( ) , 6 ) ;
1939
1939
let _ = datastore. rollback_mut_tx ( tx) ;
1940
1940
let tx = begin_mut_tx ( & datastore) ;
1941
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
1941
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
1942
1942
let schema = datastore. schema_for_table_mut_tx ( & tx, table_id) ;
1943
1943
assert ! ( schema. is_err( ) ) ;
1944
1944
Ok ( ( ) )
@@ -2165,12 +2165,9 @@ mod tests {
2165
2165
commit ( & datastore, tx) ?;
2166
2166
2167
2167
let mut tx = begin_mut_tx ( & datastore) ;
2168
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2168
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2169
2169
create_foo_age_idx_btree ( & datastore, & mut tx, table_id) ?;
2170
- assert_matches ! (
2171
- & * tx. tx_state. pending_schema_changes,
2172
- [ PendingSchemaChange :: IndexAdded ( .., None ) ]
2173
- ) ;
2170
+ assert_matches ! ( tx. pending_schema_changes( ) , [ PendingSchemaChange :: IndexAdded ( .., None ) ] ) ;
2174
2171
assert_st_indices ( & tx, true ) ?;
2175
2172
let row = u32_str_u32 ( 0 , "Bar" , 18 ) ; // 0 will be ignored.
2176
2173
let result = insert ( & datastore, & mut tx, table_id, & row) ;
@@ -2195,7 +2192,7 @@ mod tests {
2195
2192
commit ( & datastore, tx) ?;
2196
2193
2197
2194
let mut tx = begin_mut_tx ( & datastore) ;
2198
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2195
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2199
2196
assert_st_indices ( & tx, true ) ?;
2200
2197
let row = u32_str_u32 ( 0 , "Bar" , 18 ) ; // 0 will be ignored.
2201
2198
let result = insert ( & datastore, & mut tx, table_id, & row) ;
@@ -2235,16 +2232,13 @@ mod tests {
2235
2232
// Start a transaction. Schema changes empty so far.
2236
2233
let datastore = get_datastore ( ) ?;
2237
2234
let mut tx = begin_mut_tx ( & datastore) ;
2238
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2235
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2239
2236
2240
2237
// Make the table and witness `TableAdded`. Commit.
2241
2238
let column = ColumnSchema :: for_test ( 0 , "id" , AlgebraicType :: I32 ) ;
2242
2239
let schema = user_public_table ( [ column] , [ ] , [ ] , [ ] , None , None ) ;
2243
2240
let table_id = datastore. create_table_mut_tx ( & mut tx, schema) ?;
2244
- assert_matches ! (
2245
- & * tx. tx_state. pending_schema_changes,
2246
- [ PendingSchemaChange :: TableAdded ( ..) ]
2247
- ) ;
2241
+ assert_matches ! ( tx. pending_schema_changes( ) , [ PendingSchemaChange :: TableAdded ( ..) ] ) ;
2248
2242
commit ( & datastore, tx) ?;
2249
2243
2250
2244
// Start a new tx. Insert a row and witness that a sequence isn't used.
@@ -2274,7 +2268,7 @@ mod tests {
2274
2268
} ;
2275
2269
let seq_id = datastore. create_sequence_mut_tx ( & mut tx, sequence. clone ( ) ) ?;
2276
2270
assert_matches ! (
2277
- & * tx. tx_state . pending_schema_changes,
2271
+ tx. pending_schema_changes( ) ,
2278
2272
[ PendingSchemaChange :: SequenceAdded ( _, added_seq_id) ]
2279
2273
if * added_seq_id == seq_id
2280
2274
) ;
@@ -2283,7 +2277,7 @@ mod tests {
2283
2277
// Drop the uncommitted sequence.
2284
2278
datastore. drop_sequence_mut_tx ( & mut tx, seq_id) ?;
2285
2279
assert_matches ! (
2286
- & * tx. tx_state . pending_schema_changes,
2280
+ tx. pending_schema_changes( ) ,
2287
2281
[
2288
2282
PendingSchemaChange :: SequenceAdded ( ..) ,
2289
2283
PendingSchemaChange :: SequenceRemoved ( .., schema) ,
@@ -2295,7 +2289,7 @@ mod tests {
2295
2289
// Add the sequence again and rollback, witnessing that this had no effect in the next tx.
2296
2290
let seq_id = datastore. create_sequence_mut_tx ( & mut tx, sequence. clone ( ) ) ?;
2297
2291
assert_matches ! (
2298
- & * tx. tx_state . pending_schema_changes,
2292
+ tx. pending_schema_changes( ) ,
2299
2293
[
2300
2294
PendingSchemaChange :: SequenceAdded ( ..) ,
2301
2295
PendingSchemaChange :: SequenceRemoved ( ..) ,
@@ -2305,45 +2299,39 @@ mod tests {
2305
2299
) ;
2306
2300
let _ = datastore. rollback_mut_tx ( tx) ;
2307
2301
let mut tx: MutTxId = begin_mut_tx ( & datastore) ;
2308
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2302
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2309
2303
insert_assert_and_remove ( & mut tx, & zero, & zero) ?;
2310
2304
2311
2305
// Add the sequence and this time actually commit. Check that it exists in next tx.
2312
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2306
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2313
2307
let seq_id = datastore. create_sequence_mut_tx ( & mut tx, sequence. clone ( ) ) ?;
2314
2308
assert_matches ! (
2315
- & * tx. tx_state . pending_schema_changes,
2309
+ tx. pending_schema_changes( ) ,
2316
2310
[ PendingSchemaChange :: SequenceAdded ( _, added_seq_id) ]
2317
2311
if * added_seq_id == seq_id
2318
2312
) ;
2319
2313
commit ( & datastore, tx) ?;
2320
2314
let mut tx = begin_mut_tx ( & datastore) ;
2321
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2315
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2322
2316
insert_assert_and_remove ( & mut tx, & zero, & one) ?;
2323
2317
2324
2318
// We have the sequence in committed state.
2325
2319
// Drop it and then rollback, so in the next tx the seq is still there.
2326
2320
datastore. drop_sequence_mut_tx ( & mut tx, seq_id) ?;
2327
- assert_matches ! (
2328
- & * tx. tx_state. pending_schema_changes,
2329
- [ PendingSchemaChange :: SequenceRemoved ( ..) ]
2330
- ) ;
2321
+ assert_matches ! ( tx. pending_schema_changes( ) , [ PendingSchemaChange :: SequenceRemoved ( ..) ] ) ;
2331
2322
insert_assert_and_remove ( & mut tx, & zero, & zero) ?;
2332
2323
let _ = datastore. rollback_mut_tx ( tx) ;
2333
2324
let mut tx = begin_mut_tx ( & datastore) ;
2334
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2325
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2335
2326
insert_assert_and_remove ( & mut tx, & zero, & product ! [ 2 ] ) ?;
2336
2327
2337
2328
// Drop the seq and commit this time around. In the next tx, we witness that there's no seq.
2338
2329
datastore. drop_sequence_mut_tx ( & mut tx, seq_id) ?;
2339
- assert_matches ! (
2340
- & * tx. tx_state. pending_schema_changes,
2341
- [ PendingSchemaChange :: SequenceRemoved ( ..) ]
2342
- ) ;
2330
+ assert_matches ! ( tx. pending_schema_changes( ) , [ PendingSchemaChange :: SequenceRemoved ( ..) ] ) ;
2343
2331
insert_assert_and_remove ( & mut tx, & zero, & zero) ?;
2344
2332
commit ( & datastore, tx) ?;
2345
2333
let mut tx = begin_mut_tx ( & datastore) ;
2346
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2334
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2347
2335
insert_assert_and_remove ( & mut tx, & zero, & zero) ?;
2348
2336
2349
2337
Ok ( ( ) )
@@ -2570,16 +2558,16 @@ mod tests {
2570
2558
fn test_update_no_such_index_because_deleted ( ) -> ResultTest < ( ) > {
2571
2559
// Setup and immediately commit.
2572
2560
let ( datastore, tx, table_id) = setup_table ( ) ?;
2573
- assert_eq ! ( tx. tx_state . pending_schema_changes. len( ) , 6 ) ;
2561
+ assert_eq ! ( tx. pending_schema_changes( ) . len( ) , 6 ) ;
2574
2562
commit ( & datastore, tx) ?;
2575
2563
2576
2564
// Remove index in tx state.
2577
2565
let mut tx = begin_mut_tx ( & datastore) ;
2578
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2566
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2579
2567
let index_id = extract_index_id ( & datastore, & tx, & basic_indices ( ) [ 0 ] ) ?;
2580
2568
tx. drop_index ( index_id) ?;
2581
2569
assert_matches ! (
2582
- & * tx. tx_state . pending_schema_changes,
2570
+ tx. pending_schema_changes( ) ,
2583
2571
[ PendingSchemaChange :: IndexRemoved ( tid, iid, _, _) ]
2584
2572
if * tid == table_id && * iid == index_id
2585
2573
) ;
@@ -2654,7 +2642,7 @@ mod tests {
2654
2642
fn test_update_no_such_row_because_deleted_new_index_in_tx ( ) -> ResultTest < ( ) > {
2655
2643
let ( datastore, mut tx, table_id) = setup_table_with_indices ( [ ] , [ ] ) ?;
2656
2644
assert_matches ! (
2657
- & * tx. tx_state . pending_schema_changes,
2645
+ tx. pending_schema_changes( ) ,
2658
2646
[
2659
2647
PendingSchemaChange :: TableAdded ( _) ,
2660
2648
PendingSchemaChange :: SequenceAdded ( ..) ,
@@ -2668,13 +2656,13 @@ mod tests {
2668
2656
2669
2657
// Now add the indices and then delete the row.
2670
2658
let mut tx = begin_mut_tx ( & datastore) ;
2671
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
2659
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
2672
2660
let mut indices = basic_indices ( ) ;
2673
2661
for ( pos, index) in indices. iter_mut ( ) . enumerate ( ) {
2674
2662
index. table_id = table_id;
2675
2663
index. index_id = datastore. create_index_mut_tx ( & mut tx, index. clone ( ) , true ) ?;
2676
2664
assert_matches ! (
2677
- & tx. tx_state . pending_schema_changes[ pos] ,
2665
+ & tx. pending_schema_changes( ) [ pos] ,
2678
2666
PendingSchemaChange :: IndexAdded ( _, iid, _)
2679
2667
if * iid == index. index_id
2680
2668
) ;
@@ -3087,10 +3075,10 @@ mod tests {
3087
3075
3088
3076
// Create a transaction and drop the table and roll back.
3089
3077
let mut tx = begin_mut_tx ( & datastore) ;
3090
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
3078
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
3091
3079
assert ! ( datastore. drop_table_mut_tx( & mut tx, table_id) . is_ok( ) ) ;
3092
3080
assert_matches ! (
3093
- & * tx. tx_state . pending_schema_changes,
3081
+ tx. pending_schema_changes( ) ,
3094
3082
[
3095
3083
PendingSchemaChange :: IndexRemoved ( ..) ,
3096
3084
PendingSchemaChange :: IndexRemoved ( ..) ,
@@ -3105,7 +3093,7 @@ mod tests {
3105
3093
3106
3094
// Ensure the table still exists in the next transaction.
3107
3095
let tx = begin_mut_tx ( & datastore) ;
3108
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
3096
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
3109
3097
assert ! (
3110
3098
datastore. table_id_exists_mut_tx( & tx, & table_id) ,
3111
3099
"Table should still exist" ,
@@ -3120,7 +3108,7 @@ mod tests {
3120
3108
// Create a table in a failed transaction.
3121
3109
let ( datastore, tx, table_id) = setup_table ( ) ?;
3122
3110
assert_matches ! (
3123
- & * tx. tx_state . pending_schema_changes,
3111
+ tx. pending_schema_changes( ) ,
3124
3112
[
3125
3113
PendingSchemaChange :: TableAdded ( added_table_id) ,
3126
3114
PendingSchemaChange :: IndexAdded ( .., Some ( _) ) ,
@@ -3135,7 +3123,7 @@ mod tests {
3135
3123
3136
3124
// Nothing should have happened.
3137
3125
let tx = begin_mut_tx ( & datastore) ;
3138
- assert_eq ! ( & * tx. tx_state . pending_schema_changes, [ ] ) ;
3126
+ assert_eq ! ( tx. pending_schema_changes( ) , [ ] ) ;
3139
3127
assert ! (
3140
3128
!datastore. table_id_exists_mut_tx( & tx, & table_id) ,
3141
3129
"Table should not exist"
@@ -3156,7 +3144,7 @@ mod tests {
3156
3144
assert_access ( & tx, StAccess :: Public ) ;
3157
3145
tx. alter_table_access ( table_id, StAccess :: Private ) ?;
3158
3146
assert_eq ! (
3159
- & * tx. tx_state . pending_schema_changes,
3147
+ tx. pending_schema_changes( ) ,
3160
3148
[ PendingSchemaChange :: TableAlterAccess ( table_id, StAccess :: Public ) ]
3161
3149
) ;
3162
3150
let _ = datastore. rollback_mut_tx ( tx) ;
@@ -3260,7 +3248,7 @@ mod tests {
3260
3248
let mut tx = begin_mut_tx ( & datastore) ;
3261
3249
datastore. alter_table_row_type_mut_tx ( & mut tx, table_id, columns. clone ( ) ) ?;
3262
3250
assert_eq ! (
3263
- & * tx. tx_state . pending_schema_changes,
3251
+ tx. pending_schema_changes( ) ,
3264
3252
[ PendingSchemaChange :: TableAlterRowType (
3265
3253
table_id,
3266
3254
columns_original. clone( )
0 commit comments