-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl alter database rename #4984
impl alter database rename #4984
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
@@ -451,6 +453,110 @@ impl StateMachine { | |||
Ok(AppliedState::DatabaseMeta(Change::new(None, None))) | |||
} | |||
|
|||
fn apply_rename_database_cmd( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reuse apply_drop_database_cmd
and apply_create_database_cmd
code? Like apply_rename_table_cmd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reuse
apply_drop_database_cmd
andapply_create_database_cmd
code? Likeapply_rename_table_cmd
.
I think renamed database should use old database's db_id.
create database old;
alter database old rename to new
not equal with:
create database old;
drop database old;
create database new;
But maybe we can try to extract the same part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think renamed database should use old database's db_id.
I'm not sure, it seems that the id and name are bound now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, actually in apply_rename_database_cmd
table_id is table_name's id and table_meta also from old table( &prev.as_ref().unwrap().data).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think renamed database should use old database's db_id.
I'm not sure, it seems that the id and name are bound now.
The db_id and table_id need to remain the same when changing the db/table meta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The db_id and table_id need to remain the same when changing the db/table meta
Thanks, I found it #4838
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TCeason It looks like there is no conflict between reusing the code and not changing the db_id, It can also be refactored in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TCeason It looks like there is no conflict between reusing the code and not changing the db_id, It can also be refactored in another PR.
Agree with you.
@TCeason |
@TCeason |
Got. By the way, does the refactor have PR or ISSUE? I want to link it here. |
@TCeason |
Okay, I got it |
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
Support alter database .
Changelog
Related Issues
Fixes #4839