fixed segfault when creating materialized views. [#METR-11886]

This commit is contained in:
Michael Kolupaev 2014-07-14 18:26:11 +04:00
parent bcc81b712d
commit dfb21bcaff
2 changed files with 10 additions and 1 deletions

View File

@ -131,7 +131,13 @@ StoragePtr InterpreterCreateQuery::execute(bool assume_metadata_exists)
/// Даже если в запросе был список столбцов, на всякий случай приведем его к стандартному виду (развернем Nested).
ASTPtr new_columns = formatColumns(*columns);
if (create.columns)
*std::find(create.children.begin(), create.children.end(), create.columns) = new_columns;
{
auto it = std::find(create.children.begin(), create.children.end(), create.columns);
if (it != create.children.end())
*it = new_columns;
else
create.children.push_back(new_columns);
}
else
create.children.push_back(new_columns);
create.columns = new_columns;

View File

@ -39,6 +39,7 @@ StorageMaterializedView::StorageMaterializedView(const String & table_name_, con
manual_create_query->database = database_name;
manual_create_query->table = getInnerTableName();
manual_create_query->columns = create.columns;
manual_create_query->children.push_back(manual_create_query->columns);
ASTPtr ast_create_query = manual_create_query;
/// Если не указан в запросе тип хранилища попробовать извлечь его из запроса Select.
@ -52,6 +53,8 @@ StorageMaterializedView::StorageMaterializedView(const String & table_name_, con
else
manual_create_query->storage = create.inner_storage;
manual_create_query->children.push_back(manual_create_query->storage);
/// Выполним запрос.
InterpreterCreateQuery create_interpreter(ast_create_query, context);
data = create_interpreter.execute();