File tree Expand file tree Collapse file tree
crates/datastore/src/locking_tx_datastore Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -551,7 +551,7 @@ impl MutTxId {
551551 self . sequence_state_lock
552552 . get_sequence_mut ( s. sequence_id )
553553 . expect ( "sequence just created" )
554- . value ,
554+ . get_value ( ) ,
555555 )
556556 } )
557557 . collect ( ) ;
@@ -597,9 +597,10 @@ impl MutTxId {
597597 . sequence_state_lock
598598 . get_sequence_mut ( seq. sequence_id )
599599 . expect ( "sequence just created" ) ;
600- new_seq . value = * seq_values
600+ let value = * seq_values
601601 . get ( & seq. sequence_name )
602602 . ok_or_else ( || SequenceError :: NotFound ( seq. sequence_id ) ) ?;
603+ new_seq. update_value ( value) ;
603604 }
604605
605606 Ok ( table_id)
Original file line number Diff line number Diff line change @@ -69,6 +69,23 @@ impl Sequence {
6969 }
7070 }
7171
72+ /// Update the current value of the sequence.
73+ /// This is used on very specific occasions,
74+ /// such as cloning a sequence
75+ pub ( super ) fn update_value ( & mut self , new_value : i128 ) {
76+ if new_value < self . schema . min_value || new_value > self . schema . max_value {
77+ panic ! (
78+ "Invalid sequence update: new value {} is out of bounds for sequence with min_value {} and max_value {}" ,
79+ new_value, self . schema. min_value, self . schema. max_value
80+ ) ;
81+ }
82+ self . value = new_value;
83+ }
84+
85+ pub ( super ) fn get_value ( & self ) -> i128 {
86+ self . value
87+ }
88+
7289 pub ( super ) fn id ( & self ) -> SequenceId {
7390 self . schema . sequence_id
7491 }
You can’t perform that action at this time.
0 commit comments