Merge pull request #63136 from ClickHouse/pufit/fix-dump-ast-with-sql-security

Format SQL security option only in `CREATE VIEW` queries.
This commit is contained in:
pufit 2024-04-30 14:11:18 +00:00 committed by GitHub
commit fe1a8ccae6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View File

@ -1077,7 +1077,7 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
String current_database = getContext()->getCurrentDatabase();
auto database_name = create.database ? create.getDatabase() : current_database;
if (!create.sql_security && !getContext()->getServerSettings().ignore_empty_sql_security_in_create_view_query)
if (!create.sql_security && create.supportSQLSecurity() && !getContext()->getServerSettings().ignore_empty_sql_security_in_create_view_query)
create.sql_security = std::make_shared<ASTSQLSecurity>();
if (create.sql_security)

View File

@ -485,7 +485,7 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
else if (is_create_empty)
settings.ostr << (settings.hilite ? hilite_keyword : "") << " EMPTY" << (settings.hilite ? hilite_none : "");
if (sql_security && sql_security->as<ASTSQLSecurity &>().type.has_value())
if (sql_security && supportSQLSecurity() && sql_security->as<ASTSQLSecurity &>().type.has_value())
{
settings.ostr << settings.nl_or_ws;
sql_security->formatImpl(settings, state, frame);

View File

@ -149,6 +149,8 @@ public:
bool isParameterizedView() const;
bool supportSQLSecurity() const { return is_ordinary_view || is_materialized_view; }
QueryKind getQueryKind() const override { return QueryKind::Create; }
struct UUIDs