Merge pull request #18056 from zhangjmruc/master

Fix issue #17160 by adding show settings like '...'
This commit is contained in:
alexey-milovidov 2020-12-16 20:35:18 +03:00 committed by GitHub
commit b8250882ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 0 deletions

View File

@ -79,6 +79,26 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
return rewritten_query.str(); return rewritten_query.str();
} }
/// SHOW SETTINGS
if (query.m_settings)
{
WriteBufferFromOwnString rewritten_query;
rewritten_query << "SELECT name, type, value FROM system.settings";
if (query.changed)
rewritten_query << " WHERE changed = 1";
if (!query.like.empty())
{
rewritten_query
<< (query.changed ? " AND name " : " WHERE name ")
<< (query.case_insensitive_like ? "ILIKE " : "LIKE ")
<< DB::quote << query.like;
}
return rewritten_query.str();
}
if (query.temporary && !query.from.empty()) if (query.temporary && !query.from.empty())
throw Exception("The `FROM` and `TEMPORARY` cannot be used together in `SHOW TABLES`", ErrorCodes::SYNTAX_ERROR); throw Exception("The `FROM` and `TEMPORARY` cannot be used together in `SHOW TABLES`", ErrorCodes::SYNTAX_ERROR);

View File

@ -55,6 +55,12 @@ void ASTShowTablesQuery::formatQueryImpl(const FormatSettings & settings, Format
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW CLUSTER" << (settings.hilite ? hilite_none : ""); settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW CLUSTER" << (settings.hilite ? hilite_none : "");
settings.ostr << " " << backQuoteIfNeed(cluster_str); settings.ostr << " " << backQuoteIfNeed(cluster_str);
} }
else if (m_settings)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (changed ? "CHANGED " : "") << "SETTINGS" <<
(settings.hilite ? hilite_none : "");
formatLike(settings);
}
else else
{ {
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (temporary ? "TEMPORARY " : "") << settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (temporary ? "TEMPORARY " : "") <<

View File

@ -18,6 +18,8 @@ public:
bool clusters{false}; bool clusters{false};
bool cluster{false}; bool cluster{false};
bool dictionaries{false}; bool dictionaries{false};
bool m_settings{false};
bool changed{false};
bool temporary{false}; bool temporary{false};
String cluster_str; String cluster_str;

View File

@ -24,6 +24,8 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
ParserKeyword s_clusters("CLUSTERS"); ParserKeyword s_clusters("CLUSTERS");
ParserKeyword s_cluster("CLUSTER"); ParserKeyword s_cluster("CLUSTER");
ParserKeyword s_dictionaries("DICTIONARIES"); ParserKeyword s_dictionaries("DICTIONARIES");
ParserKeyword s_settings("SETTINGS");
ParserKeyword s_changed("CHANGED");
ParserKeyword s_from("FROM"); ParserKeyword s_from("FROM");
ParserKeyword s_in("IN"); ParserKeyword s_in("IN");
ParserKeyword s_not("NOT"); ParserKeyword s_not("NOT");
@ -99,6 +101,29 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
query->cluster_str = std::move(cluster_str); query->cluster_str = std::move(cluster_str);
} }
else if (bool changed = s_changed.ignore(pos); changed || s_settings.ignore(pos))
{
query->m_settings = true;
if (changed)
{
query->changed = true;
if (!s_settings.ignore(pos, expected))
return false;
}
/// Not expected due to "SHOW SETTINGS PROFILES"
if (bool insensitive = s_ilike.ignore(pos); insensitive || s_like.ignore(pos))
{
if (insensitive)
query->case_insensitive_like = true;
if (!like_p.parse(pos, like, expected))
return false;
}
else
return false;
}
else else
{ {
if (s_temporary.ignore(pos)) if (s_temporary.ignore(pos))

View File

@ -0,0 +1,5 @@
send_timeout Seconds 300
connect_timeout Seconds 10
connect_timeout_with_failover_ms Milliseconds 50
connect_timeout_with_failover_secure_ms Milliseconds 100
max_memory_usage UInt64 10000000000

View File

@ -0,0 +1,3 @@
show settings like 'send_timeout';
SHOW SETTINGS ILIKE '%CONNECT_timeout%';
SHOW CHANGED SETTINGS ILIKE '%MEMORY%';