-
Notifications
You must be signed in to change notification settings - Fork 591
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
refactor: further clarify types of tables #19539
Conversation
@@ -62,7 +62,7 @@ pub async fn handle_drop_schema( | |||
}; | |||
match mode { | |||
Some(DropMode::Restrict) | None => { | |||
if let Some(table) = schema.iter_table().next() { | |||
if let Some(table) = schema.iter_user_table().next() { |
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.
This looks somehow wrong (but we prevented error somewhere else...)
dev=> create schema s;
dev=> create materialized view s.mv as select 1 as x;
dev=> drop schema s;
ERROR: Failed to run the query
Caused by:
Permission denied: PermissionDenied: The schema is not empty, try dropping them first
dev=> create table s.t (x int);
CREATE_TABLE
dev=> drop schema s;
ERROR: Failed to run the query
Caused by these errors (recent errors listed first):
1: Catalog error
2: cannot drop schema s because table t depend on it
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.
Handled on meta here
risingwave/src/meta/src/controller/utils.rs
Lines 620 to 634 in 08fb7d4
/// `ensure_schema_empty` ensures that the schema is empty, used by `DROP SCHEMA`. | |
pub async fn ensure_schema_empty<C>(schema_id: SchemaId, db: &C) -> MetaResult<()> | |
where | |
C: ConnectionTrait, | |
{ | |
let count = Object::find() | |
.filter(object::Column::SchemaId.eq(Some(schema_id))) | |
.count(db) | |
.await?; | |
if count != 0 { | |
return Err(MetaError::permission_denied("schema is not empty")); | |
} | |
Ok(()) | |
} |
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.
Can we simply remove the check on frontend? 🤔 cc @yezizp2012
ff91b0e
to
84cbacf
Compare
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 this name is not very cool, but cannot come up with a better one.
+1.
Shall we consider making it more type-safe, like, introducing wrappers such as UserTableCatalog
or MaterializedViewCatalog
and check the table_type
field when creating them.
Would you also help to review other methods within |
Signed-off-by: xxchan <[email protected]>
Signed-off-by: xxchan <[email protected]>
84cbacf
to
56ef3c2
Compare
Signed-off-by: xxchan <[email protected]>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
follow up of #19510.
We've commented that
TableCatalog
contains different kinds of tables. In this PR we highlightuser_tables
(I think this name is not very cool, but cannot come up with a better one.)Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.