From 8cca8d2f0b09206d79fdd9d1d5a4743e1651a1ad Mon Sep 17 00:00:00 2001 From: Agaev Huseyn Date: Tue, 24 Sep 2024 15:39:49 +0300 Subject: [PATCH] Fix sequence deletion after nextval call --- tarantool/src/schema/sequence.rs | 6 +++--- tests/run_tests.lua | 1 + tests/src/box.rs | 8 ++++++++ tests/src/lib.rs | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tarantool/src/schema/sequence.rs b/tarantool/src/schema/sequence.rs index 9ea5df48..9051e860 100644 --- a/tarantool/src/schema/sequence.rs +++ b/tarantool/src/schema/sequence.rs @@ -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(()) } diff --git a/tests/run_tests.lua b/tests/run_tests.lua index e017e1b9..88fbb1cc 100755 --- a/tests/run_tests.lua +++ b/tests/run_tests.lua @@ -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') diff --git a/tests/src/box.rs b/tests/src/box.rs index 77f56e1d..896ddba0 100644 --- a/tests/src/box.rs +++ b/tests/src/box.rs @@ -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(); diff --git a/tests/src/lib.rs b/tests/src/lib.rs index cc0a4ecc..e58410f9 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -429,6 +429,7 @@ fn run_tests(cfg: TestConfig) -> Result { 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,