From e336ba10eb9cd27324041ffcf9ae85cb8ead3867 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 28 May 2016 18:56:51 +0300 Subject: [PATCH] Using std::shared_ptr for functions and AST [#METR-21503]. --- .../DB/Interpreters/InJoinSubqueriesPreprocessor.h | 2 +- dbms/include/DB/Parsers/ASTEnumElement.h | 2 +- dbms/src/Interpreters/ExpressionAnalyzer.cpp | 10 +++++----- dbms/src/Interpreters/InterpreterCreateQuery.cpp | 6 +++--- dbms/src/Interpreters/InterpreterSelectQuery.cpp | 2 +- dbms/src/Interpreters/reinterpretAsIdentifier.cpp | 4 ++-- dbms/src/Parsers/ExpressionElementParsers.cpp | 2 +- dbms/src/Storages/AlterCommands.cpp | 10 +++++----- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h b/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h index 9f50c4480d8..6a2f47f7a75 100644 --- a/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h +++ b/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h @@ -271,7 +271,7 @@ private: if (!sub_select_query.database) { - sub_select_query.database = std::make_shared({}, distributed_storage.getRemoteDatabaseName(), + sub_select_query.database = std::make_shared(StringRange(), distributed_storage.getRemoteDatabaseName(), ASTIdentifier::Database); /// Поскольку был создан новый узел для БД, необходимо его вставить в список diff --git a/dbms/include/DB/Parsers/ASTEnumElement.h b/dbms/include/DB/Parsers/ASTEnumElement.h index 7e147d4b756..6b4f3f3fdbc 100644 --- a/dbms/include/DB/Parsers/ASTEnumElement.h +++ b/dbms/include/DB/Parsers/ASTEnumElement.h @@ -21,7 +21,7 @@ public: ASTPtr clone() const override { - return std::make_shared({}, name, value); + return std::make_shared(StringRange(), name, value); } protected: diff --git a/dbms/src/Interpreters/ExpressionAnalyzer.cpp b/dbms/src/Interpreters/ExpressionAnalyzer.cpp index eba3fbb5bef..29af61c314a 100644 --- a/dbms/src/Interpreters/ExpressionAnalyzer.cpp +++ b/dbms/src/Interpreters/ExpressionAnalyzer.cpp @@ -437,7 +437,7 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name) Names column_names = external_storage->getColumnNamesList(); for (const auto & name : column_names) - exp_list->children.push_back(std::make_shared({}, name)); + exp_list->children.push_back(std::make_shared(StringRange(), name)); auto table_func = std::make_shared(); select->table = table_func; @@ -448,13 +448,13 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name) table_func->arguments = args; table_func->children.push_back(table_func->arguments); - auto address_lit = std::make_shared({}, host_port); + auto address_lit = std::make_shared(StringRange(), host_port); args->children.push_back(address_lit); - auto database_lit = std::make_shared({}, database); + auto database_lit = std::make_shared(StringRange(), database); args->children.push_back(database_lit); - auto table_lit = std::make_shared({}, external_table_name); + auto table_lit = std::make_shared(StringRange(), external_table_name); args->children.push_back(table_lit); } else @@ -768,7 +768,7 @@ static ASTPtr addTypeConversion(ASTLiteral * ast_, const String & type_name) func->arguments = exp_list; func->children.push_back(func->arguments); exp_list->children.emplace_back(ast.release()); - exp_list->children.emplace_back(std::make_shared({}, type_name)); + exp_list->children.emplace_back(std::make_shared(StringRange(), type_name)); return res; } diff --git a/dbms/src/Interpreters/InterpreterCreateQuery.cpp b/dbms/src/Interpreters/InterpreterCreateQuery.cpp index a189beb6fac..9125dc11050 100644 --- a/dbms/src/Interpreters/InterpreterCreateQuery.cpp +++ b/dbms/src/Interpreters/InterpreterCreateQuery.cpp @@ -195,8 +195,8 @@ static ColumnsAndDefaults parseColumns( const auto data_type_ptr = columns.back().type.get(); default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", std::make_shared({}, tmp_column_name), - std::make_shared({}, data_type_ptr->getName()), final_column_name)); + makeASTFunction("CAST", std::make_shared(StringRange(), tmp_column_name), + std::make_shared(StringRange(), data_type_ptr->getName()), final_column_name)); default_expr_list->children.emplace_back(setAlias(col_decl.default_expression->clone(), tmp_column_name)); } else @@ -229,7 +229,7 @@ static ColumnsAndDefaults parseColumns( if (explicit_type->getName() != deduced_type->getName()) { col_decl_ptr->default_expression = makeASTFunction("CAST", col_decl_ptr->default_expression, - std::make_shared({}, explicit_type->getName())); + std::make_shared(StringRange(), explicit_type->getName())); col_decl_ptr->children.clear(); col_decl_ptr->children.push_back(col_decl_ptr->type); diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 7b877fa4d59..600239d6df0 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -688,7 +688,7 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns() if (default_it != std::end(storage->column_defaults) && default_it->second.type == ColumnDefaultType::Alias) required_columns_expr_list->children.emplace_back(setAlias(default_it->second.expression->clone(), column)); else - required_columns_expr_list->children.emplace_back(std::make_shared({}, column)); + required_columns_expr_list->children.emplace_back(std::make_shared(StringRange(), column)); } alias_actions = ExpressionAnalyzer{required_columns_expr_list, context, storage, table_column_names}.getActions(true); diff --git a/dbms/src/Interpreters/reinterpretAsIdentifier.cpp b/dbms/src/Interpreters/reinterpretAsIdentifier.cpp index 2f0ecfc95e1..3a4f0306263 100644 --- a/dbms/src/Interpreters/reinterpretAsIdentifier.cpp +++ b/dbms/src/Interpreters/reinterpretAsIdentifier.cpp @@ -16,7 +16,7 @@ namespace { /// for string literal return its value if (const auto literal = typeid_cast(expr.get())) - return std::make_shared({}, safeGet(literal->value)); + return std::make_shared(StringRange(), safeGet(literal->value)); /// otherwise evaluate the expression Block block{}; @@ -33,7 +33,7 @@ namespace if (!typeid_cast(column_name_type.type.get())) throw Exception{"Expression must evaluate to a String"}; - return std::make_shared({}, column_name_type.column->getDataAt(0).toString()); + return std::make_shared(StringRange(), column_name_type.column->getDataAt(0).toString()); } } diff --git a/dbms/src/Parsers/ExpressionElementParsers.cpp b/dbms/src/Parsers/ExpressionElementParsers.cpp index 2bd98309955..c6ee4fcc86d 100644 --- a/dbms/src/Parsers/ExpressionElementParsers.cpp +++ b/dbms/src/Parsers/ExpressionElementParsers.cpp @@ -338,7 +338,7 @@ bool ParserCastExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & ma expr_list_args = std::make_shared(StringRange{contents_begin, end}); first_argument->setAlias({}); expr_list_args->children.push_back(first_argument); - expr_list_args->children.emplace_back(std::make_shared({}, type)); + expr_list_args->children.emplace_back(std::make_shared(StringRange(), type)); } else { diff --git a/dbms/src/Storages/AlterCommands.cpp b/dbms/src/Storages/AlterCommands.cpp index 0c96a53d793..6091e92bd22 100644 --- a/dbms/src/Storages/AlterCommands.cpp +++ b/dbms/src/Storages/AlterCommands.cpp @@ -239,8 +239,8 @@ void AlterCommands::validate(IStorage * table, const Context & context) const auto column_type_raw_ptr = command.data_type.get(); default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", std::make_shared({}, tmp_column_name), - std::make_shared({}, Field(column_type_raw_ptr->getName()))), + makeASTFunction("CAST", std::make_shared(StringRange(), tmp_column_name), + std::make_shared(StringRange(), Field(column_type_raw_ptr->getName()))), final_column_name)); default_expr_list->children.emplace_back(setAlias(command.default_expression->clone(), tmp_column_name)); @@ -293,8 +293,8 @@ void AlterCommands::validate(IStorage * table, const Context & context) const auto & column_type_ptr = column_it->type; default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", std::make_shared({}, tmp_column_name), - std::make_shared({}, Field(column_type_ptr->getName()))), + makeASTFunction("CAST", std::make_shared(StringRange(), tmp_column_name), + std::make_shared(StringRange(), Field(column_type_ptr->getName()))), column_name)); default_expr_list->children.emplace_back(setAlias(col_def.second.expression->clone(), tmp_column_name)); @@ -339,7 +339,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) } command_ptr->default_expression = makeASTFunction("CAST", command_ptr->default_expression->clone(), - std::make_shared({}, Field(explicit_type->getName()))); + std::make_shared(StringRange(), Field(explicit_type->getName()))); } } else