mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #18056 from zhangjmruc/master
Fix issue #17160 by adding show settings like '...'
This commit is contained in:
commit
b8250882ac
@ -79,6 +79,26 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
|
||||
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())
|
||||
throw Exception("The `FROM` and `TEMPORARY` cannot be used together in `SHOW TABLES`", ErrorCodes::SYNTAX_ERROR);
|
||||
|
||||
|
@ -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 << " " << backQuoteIfNeed(cluster_str);
|
||||
}
|
||||
else if (m_settings)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (changed ? "CHANGED " : "") << "SETTINGS" <<
|
||||
(settings.hilite ? hilite_none : "");
|
||||
formatLike(settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW " << (temporary ? "TEMPORARY " : "") <<
|
||||
|
@ -18,6 +18,8 @@ public:
|
||||
bool clusters{false};
|
||||
bool cluster{false};
|
||||
bool dictionaries{false};
|
||||
bool m_settings{false};
|
||||
bool changed{false};
|
||||
bool temporary{false};
|
||||
|
||||
String cluster_str;
|
||||
|
@ -24,6 +24,8 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
|
||||
ParserKeyword s_clusters("CLUSTERS");
|
||||
ParserKeyword s_cluster("CLUSTER");
|
||||
ParserKeyword s_dictionaries("DICTIONARIES");
|
||||
ParserKeyword s_settings("SETTINGS");
|
||||
ParserKeyword s_changed("CHANGED");
|
||||
ParserKeyword s_from("FROM");
|
||||
ParserKeyword s_in("IN");
|
||||
ParserKeyword s_not("NOT");
|
||||
@ -99,6 +101,29 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
|
||||
|
||||
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
|
||||
{
|
||||
if (s_temporary.ignore(pos))
|
||||
|
5
tests/queries/0_stateless/01293_show_settings.reference
Normal file
5
tests/queries/0_stateless/01293_show_settings.reference
Normal 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
|
3
tests/queries/0_stateless/01293_show_settings.sql
Normal file
3
tests/queries/0_stateless/01293_show_settings.sql
Normal file
@ -0,0 +1,3 @@
|
||||
show settings like 'send_timeout';
|
||||
SHOW SETTINGS ILIKE '%CONNECT_timeout%';
|
||||
SHOW CHANGED SETTINGS ILIKE '%MEMORY%';
|
Loading…
Reference in New Issue
Block a user