-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support information_schema.schemata (#18709)
- Loading branch information
Showing
4 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
// limitations under the License. | ||
|
||
mod columns; | ||
mod schemata; | ||
mod tables; | ||
mod views; |
44 changes: 44 additions & 0 deletions
44
src/frontend/src/catalog/system_catalog/information_schema/schemata.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2024 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use risingwave_common::types::Fields; | ||
use risingwave_frontend_macro::system_catalog; | ||
|
||
/// The view schemata contains all schemas in the current database that the current user has access to (by way of being the owner or having some privilege). | ||
/// Ref: [`https://www.postgresql.org/docs/current/infoschema-schemata.html`] | ||
#[system_catalog( | ||
view, | ||
"information_schema.schemata", | ||
"SELECT CURRENT_DATABASE() AS catalog_name, | ||
s.name AS schema_name, | ||
u.name AS schema_owner, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL | ||
FROM rw_catalog.rw_schemas s | ||
JOIN rw_catalog.rw_users u ON s.owner = u.id | ||
WHERE has_schema_privilege(s.name, 'CREATE, USAGE') | ||
ORDER BY catalog_name, schema_name" | ||
)] | ||
#[derive(Fields)] | ||
struct Schemata { | ||
catalog_name: String, | ||
schema_name: String, | ||
schema_owner: String, | ||
default_character_set_catalog: String, | ||
default_character_set_schema: String, | ||
default_character_set_name: String, | ||
sql_path: String, | ||
} |