Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Fix sequence deletion after nextval call - #26

Open
agscpp wants to merge 1 commit into
picodata:masterfrom
agscpp:fix-drop-sequence
Open

Fix sequence deletion after nextval call#26
agscpp wants to merge 1 commit into
picodata:masterfrom
agscpp:fix-drop-sequence

Conversation

@agscpp

@agscpp agscpp commented Sep 24, 2024

Copy link
Copy Markdown
CREATE SEQUENCE serial_01 CYCLE;
SELECT nextval('serial_01');
DROP SEQUENCE serial_01;
Tarantool error: DropSequence: Can't drop sequence 'serial_01': the sequence has data

@agscpp

agscpp commented Sep 24, 2024

Copy link
Copy Markdown
Author

Hi, @gmoshkin .

Can you please take a look at my pull request?

@gmoshkin

Copy link
Copy Markdown
Member

Hi, thanks for the patch!

Could you explain, how are the provided SQL commands related to the test?

CREATE SEQUENCE serial_01 CYCLE;
SELECT nextval('serial_01');
DROP SEQUENCE serial_01

The code in question will not be invoked when this SQL is executed.

Could you also add a test, so that we don't break the fix accidentally in the future.

@agscpp

agscpp commented Sep 26, 2024

Copy link
Copy Markdown
Author

This is an abstract example that I used to compare the behavior with other DBMSs.

Okay, I'll write tests for this logic.

@agscpp

agscpp commented Sep 26, 2024

Copy link
Copy Markdown
Author

@gmoshkin
I wrote the tests

@gmoshkin

Copy link
Copy Markdown
Member

Also please update CHANGELOG.md, we try keeping it up to date with every merge we make into the master branch.

@agscpp

agscpp commented Sep 30, 2024

Copy link
Copy Markdown
Author

@gmoshkin

Comment thread tests/src/box.rs Outdated
let mut seq = Sequence::find("test_drop_seq").unwrap().unwrap();
assert_eq!(seq.next().unwrap(), 1);

tarantool::schema::sequence::drop_sequence(2).unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the test! There's a problem though, this hard-coded id is volatile as it may change if another test is added (if someone adds another sequence). We could make it much more robust if we got the id from the Sequence struct. Unfortunately there's currently no method for this, but it's very easy to add it.

Do you mind adding fn id(&self) -> u32 for the Sequence struct and using it in this test?

This will also be potentially useful for other users of tarantool-module as it will allow explicit deletion of sequences, by adding the ability to get the id of the instance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I wrote this comment yesterday, but failed to submit the review

@agscpp agscpp Oct 1, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have corrected the code based on your comments. Please take a look again.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agscpp
agscpp force-pushed the fix-drop-sequence branch from f1187e6 to b45cd7c Compare October 1, 2024 14:03
@agscpp
agscpp requested a review from gmoshkin October 8, 2024 10:39
@agscpp

agscpp commented Oct 29, 2024

Copy link
Copy Markdown
Author

@gmoshkin
ping

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants