Backport #63136 to 24.3: Format SQL security option only in CREATE VIEW queries.

This commit is contained in:
robot-clickhouse 2024-04-30 15:06:25 +00:00
parent d2708667d8
commit f0d6c43046
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