unique names

This commit is contained in:
Nikita Vasilev 2019-01-08 12:38:46 +03:00
parent 541c641b24
commit 48e136f029
3 changed files with 28 additions and 4 deletions

View File

@ -27,8 +27,10 @@ public:
String getID(char) const override { return "Index"; }
ASTPtr clone() const override {
auto res = std::make_shared<ASTIndexDeclaration>(*this);
res->children.clear();
auto res = std::make_shared<ASTIndexDeclaration>();
res->name = name;
res->granularity = granularity;
if (expr)
res->set(res->expr, expr->clone());

View File

@ -47,6 +47,7 @@
#include <algorithm>
#include <iomanip>
#include <set>
#include <thread>
#include <typeinfo>
#include <typeindex>
@ -351,15 +352,27 @@ void MergeTreeData::setPrimaryKeyAndColumns(
void MergeTreeData::setSkipIndexes(const ASTs & indexes_asts, bool only_check)
{
if (!only_check) {
for (const auto &index_ast : indexes_asts) {
indexes.clear();
std::set<String> names;
if (!only_check)
{
for (const auto &index_ast : indexes_asts)
{
indexes.push_back(
std::move(MergeTreeIndexFactory::instance().get(
*this,
std::dynamic_pointer_cast<ASTIndexDeclaration>(index_ast),
global_context)));
if (names.find(indexes.back()->name) != names.end())
{
throw Exception(
"Index with name `" + indexes.back()->name + "` already exsists",
ErrorCodes::LOGICAL_ERROR);
}
LOG_DEBUG(log, "new index init : " << indexes.back()->name);
}
}
LOG_DEBUG(log, "Indexes size: " << indexes.size());
}

View File

@ -12,6 +12,12 @@
namespace DB {
namespace ErrorCodes
{
extern const int FILE_DOESNT_EXIST;
}
class MergeTreeTestIndex;
struct MergeTreeTestGranule : public MergeTreeIndexGranule {
@ -24,6 +30,9 @@ struct MergeTreeTestGranule : public MergeTreeIndexGranule {
void deserializeBinary(ReadBuffer &istr) override {
readIntBinary(emp, istr);
if (emp != 10) {
throw Exception("kek bad read", ErrorCodes::FILE_DOESNT_EXIST);
}
//std::cerr << "TESTINDEX: read " << emp << "\n";
}