mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #13940 from hczhcz/patch-0821
Fix parser to reject create table as table function with engine
This commit is contained in:
commit
14400b5b41
@ -265,11 +265,6 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
|
||||
formatOnCluster(settings);
|
||||
}
|
||||
|
||||
if (as_table_function)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS " << (settings.hilite ? hilite_none : "");
|
||||
as_table_function->formatImpl(settings, state, frame);
|
||||
}
|
||||
if (to_table_id)
|
||||
{
|
||||
settings.ostr
|
||||
@ -285,6 +280,12 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
|
||||
<< (!as_database.empty() ? backQuoteIfNeed(as_database) + "." : "") << backQuoteIfNeed(as_table);
|
||||
}
|
||||
|
||||
if (as_table_function)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS " << (settings.hilite ? hilite_none : "");
|
||||
as_table_function->formatImpl(settings, state, frame);
|
||||
}
|
||||
|
||||
frame.expression_list_always_start_on_new_line = true;
|
||||
|
||||
if (columns_list)
|
||||
|
@ -427,7 +427,8 @@ bool ParserCreateTableQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expe
|
||||
|
||||
if (!select_p.parse(pos, select, expected)) /// AS SELECT ...
|
||||
{
|
||||
if (!table_function_p.parse(pos, as_table_function, expected))
|
||||
/// ENGINE can not be specified for table functions.
|
||||
if (storage || !table_function_p.parse(pos, as_table_function, expected))
|
||||
{
|
||||
/// AS [db.]table
|
||||
if (!name_p.parse(pos, as_table, expected))
|
||||
|
@ -4,9 +4,15 @@ DROP TABLE IF EXISTS t3;
|
||||
DROP TABLE IF EXISTS v;
|
||||
DROP TABLE IF EXISTS lv;
|
||||
|
||||
CREATE TABLE t1 (key Int) Engine=Memory();
|
||||
CREATE TABLE t1 (key Int) Engine=Memory;
|
||||
CREATE TABLE t2 AS t1;
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 Engine=Memory AS t1;
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t2 AS t1 Engine=Memory;
|
||||
DROP TABLE t2;
|
||||
CREATE TABLE t3 AS numbers(10);
|
||||
DROP TABLE t3;
|
||||
|
||||
-- live view
|
||||
SET allow_experimental_live_view=1;
|
||||
|
@ -0,0 +1,3 @@
|
||||
OK
|
||||
OK
|
||||
OK
|
10
tests/queries/0_stateless/01445_create_table_as_table_function.sh
Executable file
10
tests/queries/0_stateless/01445_create_table_as_table_function.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "CREATE TABLE system.columns AS numbers(10);" 2>&1 | grep -F "Code: 57" > /dev/null && echo 'OK' || echo 'FAIL'
|
||||
${CLICKHOUSE_CLIENT} --query "CREATE TABLE system.columns engine=Memory AS numbers(10);" 2>&1 | grep -F "Code: 62" > /dev/null && echo 'OK' || echo 'FAIL'
|
||||
${CLICKHOUSE_CLIENT} --query "CREATE TABLE system.columns AS numbers(10) engine=Memory;" 2>&1 | grep -F "Code: 62" > /dev/null && echo 'OK' || echo 'FAIL'
|
Loading…
Reference in New Issue
Block a user