mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Fix possible name collision in ALTER
This commit is contained in:
parent
2c8e42c232
commit
e6d8ab2270
@ -6,6 +6,7 @@
|
||||
#include <Common/escapeForFileName.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
#include <Common/Macros.h>
|
||||
#include <Common/randomSeed.h>
|
||||
|
||||
#include <Core/Defines.h>
|
||||
#include <Core/Settings.h>
|
||||
@ -362,7 +363,7 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription(
|
||||
if (col_decl.type)
|
||||
{
|
||||
const auto & final_column_name = col_decl.name;
|
||||
const auto tmp_column_name = final_column_name + "_tmp";
|
||||
const auto tmp_column_name = final_column_name + "_tmp_alter" + toString(randomSeed());
|
||||
const auto * data_type_ptr = column_names_and_types.back().type.get();
|
||||
|
||||
default_expr_list->children.emplace_back(
|
||||
|
@ -22,12 +22,11 @@
|
||||
#include <Parsers/ASTIndexDeclaration.h>
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTSetQuery.h>
|
||||
#include <Parsers/queryToString.h>
|
||||
#include <Storages/AlterCommands.h>
|
||||
#include <Storages/IStorage.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
|
||||
|
||||
#include <Parsers/queryToString.h>
|
||||
#include <Common/randomSeed.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -1117,7 +1116,7 @@ void AlterCommands::validate(const StorageInMemoryMetadata & metadata, const Con
|
||||
data_type_ptr = command.data_type;
|
||||
|
||||
const auto & final_column_name = column_name;
|
||||
const auto tmp_column_name = final_column_name + "_tmp";
|
||||
const auto tmp_column_name = final_column_name + "_tmp_alter" + toString(randomSeed());
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(
|
||||
addTypeConversionToAST(std::make_shared<ASTIdentifier>(tmp_column_name), data_type_ptr->getName()),
|
||||
@ -1133,7 +1132,7 @@ void AlterCommands::validate(const StorageInMemoryMetadata & metadata, const Con
|
||||
continue;
|
||||
|
||||
const auto & final_column_name = column_name;
|
||||
const auto tmp_column_name = final_column_name + "_tmp";
|
||||
const auto tmp_column_name = final_column_name + "_tmp_alter" + toString(randomSeed());
|
||||
const auto data_type_ptr = command.data_type;
|
||||
|
||||
default_expr_list->children.emplace_back(setAlias(
|
||||
|
3
tests/queries/0_stateless/01552_alter_name_collision.sql
Normal file
3
tests/queries/0_stateless/01552_alter_name_collision.sql
Normal file
@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test(test String DEFAULT 'test', test_tmp Int DEFAULT 1)ENGINE = Memory;
|
||||
DROP TABLE test;
|
Loading…
Reference in New Issue
Block a user