-
Notifications
You must be signed in to change notification settings - Fork 525
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
feat: redact SqlOption in SHOW CREATE #14310
Changes from all commits
363a177
96036d8
9a44cbd
1ee23d6
f7fc8a5
ecb1ebe
0a9e681
009b4f5
e53346e
8091858
63cb4ee
006df4b
459c9d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ pub fn alter_definition_add_column(definition: &str, column: ColumnDef) -> Resul | |
_ => unreachable!(), | ||
} | ||
|
||
Ok(stmt.to_string()) | ||
Ok(stmt.to_unredacted_string()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I ask how you find all references of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Most of them are found by test failure 🥵
to_string or display are redacted by default.
Caller is responsible for explicitly using |
||
} | ||
|
||
#[cfg(test)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,7 +212,7 @@ impl HandlerArgs { | |
} | ||
_ => {} | ||
} | ||
stmt.to_string() | ||
stmt.to_unredacted_string() | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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 anyhow::Context; | ||
use risingwave_sqlparser::ast::REDACT_SQL_OPTION; | ||
|
||
use crate::error::Result; | ||
|
||
pub fn redact_definition(definition: &str) -> Result<String> { | ||
let [stmt]: [_; 1] = risingwave_sqlparser::parser::Parser::parse_sql(definition) | ||
.context("unable to parse definition")? | ||
.try_into() | ||
.unwrap(); | ||
Ok(REDACT_SQL_OPTION.sync_scope(true, || stmt.to_string())) | ||
} |
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'm wondering if this (only showing raw SQL if the user is the owner) is a common behavior in other DBMS? Even so, I guess it would be based on the permission system but not simply determined by the ownership. cc @yezizp2012
In my personal opinion I would suggest adding a new column of
redacted_definition
. Users are allowed to decide which form to reveal or share with us.