mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #12653 from zhang2014/feature/truncate_without_table
ISSUES-4006 support truncate table without table keyword
This commit is contained in:
commit
f75c242491
@ -11,7 +11,7 @@ namespace DB
|
||||
namespace
|
||||
{
|
||||
|
||||
bool parseDropQuery(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
bool parseDropQuery(IParser::Pos & pos, ASTPtr & node, Expected & expected, bool optional_table_keyword = false)
|
||||
{
|
||||
ParserKeyword s_temporary("TEMPORARY");
|
||||
ParserKeyword s_table("TABLE");
|
||||
@ -55,7 +55,7 @@ bool parseDropQuery(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
else if (s_temporary.ignore(pos, expected))
|
||||
temporary = true;
|
||||
|
||||
if (!is_view && !is_dictionary && !s_table.ignore(pos, expected))
|
||||
if (!is_view && !is_dictionary && (!s_table.ignore(pos, expected) && !optional_table_keyword))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -114,7 +114,7 @@ bool parseDetachQuery(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
|
||||
bool parseTruncateQuery(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
if (parseDropQuery(pos, node, expected))
|
||||
if (parseDropQuery(pos, node, expected, true))
|
||||
{
|
||||
auto * drop_query = node->as<ASTDropQuery>();
|
||||
drop_query->kind = ASTDropQuery::Kind::Truncate;
|
||||
|
@ -0,0 +1,3 @@
|
||||
1
|
||||
2
|
||||
3
|
@ -0,0 +1,12 @@
|
||||
DROP TABLE IF EXISTS truncate_test;
|
||||
|
||||
CREATE TABLE truncate_test(uint8 UInt8) ENGINE = Log;
|
||||
|
||||
INSERT INTO truncate_test VALUES(1), (2), (3);
|
||||
|
||||
SELECT * FROM truncate_test ORDER BY uint8;
|
||||
|
||||
TRUNCATE truncate_test;
|
||||
|
||||
SELECT * FROM truncate_test ORDER BY uint8;
|
||||
|
Loading…
Reference in New Issue
Block a user