Skip to content

Commit

Permalink
Fix sequence deletion after nextval call
Browse files Browse the repository at this point in the history
  • Loading branch information
Agaev Huseyn committed Sep 26, 2024
1 parent 83f82a4 commit 8cca8d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tarantool/src/schema/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use crate::space::{Space, SystemSpace};
pub fn drop_sequence(seq_id: u32) -> Result<(), Error> {
schema::revoke_object_privileges("sequence", seq_id)?;

let sys_sequence: Space = SystemSpace::Sequence.into();
sys_sequence.delete(&(seq_id,))?;

let sys_sequence_data: Space = SystemSpace::SequenceData.into();
sys_sequence_data.delete(&(seq_id,))?;

let sys_sequence: Space = SystemSpace::Sequence.into();
sys_sequence.delete(&(seq_id,))?;

Ok(())
}
1 change: 1 addition & 0 deletions tests/run_tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ box.once('bootstrap_tests', function()
box.schema.user.grant('test_user', 'read,write,execute,create,drop', 'universe')

box.schema.sequence.create('test_seq')
box.schema.sequence.create('test_drop_seq')

box.schema.func.create('test_stored_proc')
box.schema.func.create('test_schema_update')
Expand Down
8 changes: 8 additions & 0 deletions tests/src/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,14 @@ pub fn sequence_set() {
assert_eq!(seq.next().unwrap(), 100);
}

pub fn sequence_drop() {
let mut seq = Sequence::find("test_drop_seq").unwrap().unwrap();
assert_eq!(seq.next().unwrap(), 1);

tarantool::schema::sequence::drop_sequence(2).unwrap();
assert!(Sequence::find("test_drop_seq").unwrap().is_none())
}

pub fn space_create_opt_default() {
let opts = SpaceCreateOptions::default();

Expand Down
1 change: 1 addition & 0 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ fn run_tests(cfg: TestConfig) -> Result<bool, io::Error> {
r#box::sequence_get_by_name,
r#box::sequence_iterate,
r#box::sequence_set,
r#box::sequence_drop,
r#box::space_create_opt_default,
r#box::space_create_opt_if_not_exists,
r#box::space_create_id_increment,
Expand Down

0 comments on commit 8cca8d2

Please sign in to comment.