Merge pull request #63193 from ClickHouse/backport/24.3/63136

Backport #63136 to 24.3: Format SQL security option only in `CREATE VIEW` queries.
This commit is contained in:
robot-clickhouse 2024-04-30 20:06:42 +02:00 committed by GitHub
commit 7e7f3bdd9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View File

@ -1076,7 +1076,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