mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-25 11:10:49 +00:00
Merge pull request #8508 from azat/create-table-as-dict-fix
Avoid SIGSEGV on CREATE TABLE .. AS dictionary
This commit is contained in:
commit
50cc3092b6
@ -514,14 +514,21 @@ void InterpreterCreateQuery::setEngine(ASTCreateQuery & create) const
|
||||
ASTPtr as_create_ptr = context.getDatabase(as_database_name)->getCreateTableQuery(context, as_table_name);
|
||||
const auto & as_create = as_create_ptr->as<ASTCreateQuery &>();
|
||||
|
||||
const String qualified_name = backQuoteIfNeed(as_database_name) + "." + backQuoteIfNeed(as_table_name);
|
||||
|
||||
if (as_create.is_view)
|
||||
throw Exception(
|
||||
"Cannot CREATE a table AS " + as_database_name + "." + as_table_name + ", it is a View",
|
||||
"Cannot CREATE a table AS " + qualified_name + ", it is a View",
|
||||
ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
if (as_create.is_live_view)
|
||||
throw Exception(
|
||||
"Cannot CREATE a table AS " + as_database_name + "." + as_table_name + ", it is a Live View",
|
||||
"Cannot CREATE a table AS " + qualified_name + ", it is a Live View",
|
||||
ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
if (as_create.is_dictionary)
|
||||
throw Exception(
|
||||
"Cannot CREATE a table AS " + qualified_name + ", it is a Dictionary",
|
||||
ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
create.set(create.storage, as_create.storage->ptr());
|
||||
|
30
dbms/tests/queries/0_stateless/01056_create_table_as.sql
Normal file
30
dbms/tests/queries/0_stateless/01056_create_table_as.sql
Normal file
@ -0,0 +1,30 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (key Int) Engine=Memory();
|
||||
CREATE TABLE t2 AS t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
-- live view
|
||||
SET allow_experimental_live_view=1;
|
||||
CREATE LIVE VIEW v AS SELECT * FROM t1;
|
||||
CREATE TABLE t3 AS v; -- { serverError 80; }
|
||||
|
||||
-- view
|
||||
CREATE VIEW lv AS SELECT * FROM t1;
|
||||
CREATE TABLE t3 AS lv; -- { serverError 80; }
|
||||
|
||||
-- dictionary
|
||||
DROP DATABASE if exists test_01056_dict_data;
|
||||
CREATE DATABASE test_01056_dict_data;
|
||||
CREATE TABLE test_01056_dict_data.dict_data (key Int, value UInt16) Engine=Memory();
|
||||
CREATE DICTIONARY dict
|
||||
(
|
||||
`key` UInt64,
|
||||
`value` UInt16
|
||||
)
|
||||
PRIMARY KEY key
|
||||
SOURCE(CLICKHOUSE(
|
||||
HOST '127.0.0.1' PORT 9000
|
||||
TABLE 'dict_data' DB 'test_01056_dict_data' USER 'default' PASSWORD ''))
|
||||
LIFETIME(MIN 0 MAX 0)
|
||||
LAYOUT(SPARSE_HASHED());
|
||||
CREATE TABLE t3 AS dict; -- { serverError 80; }
|
Loading…
Reference in New Issue
Block a user