From 7ddc267dd6485f1622c9f3c7d697f1e2c7738c54 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 7 Dec 2015 19:25:42 +0300 Subject: [PATCH 01/66] zkutil: add ZooKeeperHolder to hold one instance of zookeeper and reinit session if there is no reference on it [#METR-18346] --- .../include/zkutil/ZooKeeperHolder.h | 71 +++++++++++++++++++ libs/libzkutil/src/ZooKeeperHolder.cpp | 42 +++++++++++ .../src/tests/zkutil_zookeeper_holder.cpp | 23 ++++++ 3 files changed, 136 insertions(+) create mode 100644 libs/libzkutil/include/zkutil/ZooKeeperHolder.h create mode 100644 libs/libzkutil/src/ZooKeeperHolder.cpp create mode 100644 libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp diff --git a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h new file mode 100644 index 00000000000..c988aec6881 --- /dev/null +++ b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h @@ -0,0 +1,71 @@ +#pragma once + +#include +#include + +namespace zkutil +{ + +class ZooKeeperHolder +{ +protected: + class UnstorableZookeeperHandler; + +public: + /// вызывать из одного потока - не thread safe + template + static void create(Args&&... args); + + static ZooKeeperHolder & getInstance(); + + static UnstorableZookeeperHandler getZooKeeper(); + static bool replaceZooKeeperSessionToNewOne(); + + static bool isSessionExpired(); + +protected: + /** Хендлер для подсчета количества используемых ссылок на ZooKeeper + * + * Специально поддерживает только хранение на стеке. + * Что вынуждает перед каждым использованием явно запросить хэндлер у ZooKeeperHolder + */ + class UnstorableZookeeperHandler + { + public: + UnstorableZookeeperHandler(ZooKeeper::Ptr zk_ptr_); + + ZooKeeper * operator->() { return zk_ptr.get(); } + const ZooKeeper * operator->() const { return zk_ptr.get(); } + ZooKeeper & operator*() { return *zk_ptr; } + const ZooKeeper & operator*() const { return *zk_ptr; } + + private: + ZooKeeper::Ptr zk_ptr; + }; + +protected: + template + ZooKeeperHolder(Args&&... args); + +private: + static std::unique_ptr instance; + + mutable std::mutex mutex; + ZooKeeper::Ptr ptr; +}; + +template +ZooKeeperHolder::ZooKeeperHolder(Args&&... args) + : ptr(std::make_shared(std::forward(args)...)) +{ +} + +template +void ZooKeeperHolder::create(Args&&... args) +{ + if (instance) + throw DB::Exception("Initialization is called twice"); + instance.reset(new ZooKeeperHolder(std::forward(args)...)); +} + +}; /*namespace zkutil*/ \ No newline at end of file diff --git a/libs/libzkutil/src/ZooKeeperHolder.cpp b/libs/libzkutil/src/ZooKeeperHolder.cpp new file mode 100644 index 00000000000..66851efc85c --- /dev/null +++ b/libs/libzkutil/src/ZooKeeperHolder.cpp @@ -0,0 +1,42 @@ +#include + +using namespace zkutil; + +std::unique_ptr ZooKeeperHolder::instance; + +ZooKeeperHolder & ZooKeeperHolder::getInstance() +{ + if (!instance) + throw DB::Exception("ZooKeeperHolder should be initialized before getInstance is called."); + return *instance; +} + +ZooKeeperHolder::UnstorableZookeeperHandler ZooKeeperHolder::getZooKeeper() +{ + auto & inst = getInstance(); + std::unique_lock lock(inst.mutex); + return UnstorableZookeeperHandler(inst.ptr); +} + +bool ZooKeeperHolder::replaceZooKeeperSessionToNewOne() +{ + auto & inst = getInstance(); + std::unique_lock lock(inst.mutex); + + if (inst.ptr.unique()) + { + inst.ptr = inst.ptr->startNewSession(); + return true; + } + return false; +} + +bool ZooKeeperHolder::isSessionExpired() +{ + return getZooKeeper()->expired(); +} + +ZooKeeperHolder::UnstorableZookeeperHandler::UnstorableZookeeperHandler(ZooKeeper::Ptr zk_ptr_) +: zk_ptr(zk_ptr_) +{ +} \ No newline at end of file diff --git a/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp b/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp new file mode 100644 index 00000000000..fac96231d60 --- /dev/null +++ b/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp @@ -0,0 +1,23 @@ +#include +#include + +int main() +{ + zkutil::ZooKeeperHolder::create("localhost:2181"); + + { + auto zk_handler = zkutil::ZooKeeperHolder::getInstance().getZooKeeper(); + bool started_new_session = zkutil::ZooKeeperHolder::getInstance().replaceZooKeeperSessionToNewOne(); + std::cerr << "Started new session: " << started_new_session << "\n"; + std::cerr << "get / " << zk_handler->get("/") << "\n"; + } + + { + bool started_new_session = zkutil::ZooKeeperHolder::getInstance().replaceZooKeeperSessionToNewOne(); + std::cerr << "Started new session: " << started_new_session << "\n"; + auto zk_handler = zkutil::ZooKeeperHolder::getInstance().getZooKeeper(); + std::cerr << "get / " << zk_handler->get("/") << "\n"; + } + + return 0; +} \ No newline at end of file From d3be463a7d59187c59c1bac1dbb0903ded2384fe Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Tue, 8 Dec 2015 13:48:40 +0300 Subject: [PATCH 02/66] ZooKeeperHolder: add comparison to nullptr [#METR-18346] --- .../include/zkutil/ZooKeeperHolder.h | 34 +++++++------------ libs/libzkutil/src/ZooKeeperHolder.cpp | 25 ++++---------- .../src/tests/zkutil_zookeeper_holder.cpp | 28 ++++++++++----- 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h index c988aec6881..a692f80ee22 100644 --- a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h +++ b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h @@ -12,16 +12,16 @@ protected: class UnstorableZookeeperHandler; public: + ZooKeeperHolder() = default; + /// вызывать из одного потока - не thread safe template - static void create(Args&&... args); + void init(Args&&... args); - static ZooKeeperHolder & getInstance(); + UnstorableZookeeperHandler getZooKeeper(); + bool replaceZooKeeperSessionToNewOne(); - static UnstorableZookeeperHandler getZooKeeper(); - static bool replaceZooKeeperSessionToNewOne(); - - static bool isSessionExpired(); + bool isSessionExpired() const; protected: /** Хендлер для подсчета количества используемых ссылок на ZooKeeper @@ -34,6 +34,10 @@ protected: public: UnstorableZookeeperHandler(ZooKeeper::Ptr zk_ptr_); + explicit operator bool() const { return bool(zk_ptr); } + bool operator==(nullptr_t) const { return zk_ptr == nullptr; } + bool operator!=(nullptr_t) const { return !(*this == nullptr); } + ZooKeeper * operator->() { return zk_ptr.get(); } const ZooKeeper * operator->() const { return zk_ptr.get(); } ZooKeeper & operator*() { return *zk_ptr; } @@ -43,29 +47,15 @@ protected: ZooKeeper::Ptr zk_ptr; }; -protected: - template - ZooKeeperHolder(Args&&... args); - private: - static std::unique_ptr instance; - mutable std::mutex mutex; ZooKeeper::Ptr ptr; }; template -ZooKeeperHolder::ZooKeeperHolder(Args&&... args) - : ptr(std::make_shared(std::forward(args)...)) +void ZooKeeperHolder::init(Args&&... args) { -} - -template -void ZooKeeperHolder::create(Args&&... args) -{ - if (instance) - throw DB::Exception("Initialization is called twice"); - instance.reset(new ZooKeeperHolder(std::forward(args)...)); + ptr = std::make_shared(std::forward(args)...); } }; /*namespace zkutil*/ \ No newline at end of file diff --git a/libs/libzkutil/src/ZooKeeperHolder.cpp b/libs/libzkutil/src/ZooKeeperHolder.cpp index 66851efc85c..582cc14d307 100644 --- a/libs/libzkutil/src/ZooKeeperHolder.cpp +++ b/libs/libzkutil/src/ZooKeeperHolder.cpp @@ -2,38 +2,27 @@ using namespace zkutil; -std::unique_ptr ZooKeeperHolder::instance; - -ZooKeeperHolder & ZooKeeperHolder::getInstance() -{ - if (!instance) - throw DB::Exception("ZooKeeperHolder should be initialized before getInstance is called."); - return *instance; -} - ZooKeeperHolder::UnstorableZookeeperHandler ZooKeeperHolder::getZooKeeper() { - auto & inst = getInstance(); - std::unique_lock lock(inst.mutex); - return UnstorableZookeeperHandler(inst.ptr); + std::unique_lock lock(mutex); + return UnstorableZookeeperHandler(ptr); } bool ZooKeeperHolder::replaceZooKeeperSessionToNewOne() { - auto & inst = getInstance(); - std::unique_lock lock(inst.mutex); + std::unique_lock lock(mutex); - if (inst.ptr.unique()) + if (ptr.unique()) { - inst.ptr = inst.ptr->startNewSession(); + ptr = ptr->startNewSession(); return true; } return false; } -bool ZooKeeperHolder::isSessionExpired() +bool ZooKeeperHolder::isSessionExpired() const { - return getZooKeeper()->expired(); + return ptr ? ptr->expired() : false; } ZooKeeperHolder::UnstorableZookeeperHandler::UnstorableZookeeperHandler(ZooKeeper::Ptr zk_ptr_) diff --git a/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp b/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp index fac96231d60..a6a8fda93a1 100644 --- a/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp +++ b/libs/libzkutil/src/tests/zkutil_zookeeper_holder.cpp @@ -1,23 +1,33 @@ #include #include +#include + +#include int main() { - zkutil::ZooKeeperHolder::create("localhost:2181"); + Test::initLogger(); + + zkutil::ZooKeeperHolder zk_holder; + zk_holder.init("localhost:2181"); { - auto zk_handler = zkutil::ZooKeeperHolder::getInstance().getZooKeeper(); - bool started_new_session = zkutil::ZooKeeperHolder::getInstance().replaceZooKeeperSessionToNewOne(); - std::cerr << "Started new session: " << started_new_session << "\n"; - std::cerr << "get / " << zk_handler->get("/") << "\n"; + auto zk_handler = zk_holder.getZooKeeper(); + if (zk_handler) + { + bool started_new_session = zk_holder.replaceZooKeeperSessionToNewOne(); + std::cerr << "Started new session: " << started_new_session << "\n"; + std::cerr << "get / " << zk_handler->get("/") << "\n"; + } } { - bool started_new_session = zkutil::ZooKeeperHolder::getInstance().replaceZooKeeperSessionToNewOne(); + bool started_new_session = zk_holder.replaceZooKeeperSessionToNewOne(); std::cerr << "Started new session: " << started_new_session << "\n"; - auto zk_handler = zkutil::ZooKeeperHolder::getInstance().getZooKeeper(); - std::cerr << "get / " << zk_handler->get("/") << "\n"; + auto zk_handler = zk_holder.getZooKeeper(); + if (zk_handler != nullptr) + std::cerr << "get / " << zk_handler->get("/") << "\n"; } return 0; -} \ No newline at end of file +} From ad29c8c42c13a5d3a212aca6577ce3a8ffecf95c Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Thu, 10 Dec 2015 16:35:41 +0300 Subject: [PATCH 03/66] ZooKeeperHolder: changed interface [#METR-18346] --- .../include/zkutil/ZooKeeperHolder.h | 19 ++++++++--- libs/libzkutil/src/ZooKeeperHolder.cpp | 34 +++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h index a692f80ee22..9778f6ce4e5 100644 --- a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h +++ b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h @@ -2,11 +2,12 @@ #include #include +#include namespace zkutil { -class ZooKeeperHolder +class ZooKeeperHolder : public boost::noncopyable { protected: class UnstorableZookeeperHandler; @@ -17,6 +18,8 @@ public: /// вызывать из одного потока - не thread safe template void init(Args&&... args); + /// был ли класс инициализирован + bool isInitialized() const { return ptr != nullptr; } UnstorableZookeeperHandler getZooKeeper(); bool replaceZooKeeperSessionToNewOne(); @@ -38,10 +41,12 @@ protected: bool operator==(nullptr_t) const { return zk_ptr == nullptr; } bool operator!=(nullptr_t) const { return !(*this == nullptr); } - ZooKeeper * operator->() { return zk_ptr.get(); } - const ZooKeeper * operator->() const { return zk_ptr.get(); } - ZooKeeper & operator*() { return *zk_ptr; } - const ZooKeeper & operator*() const { return *zk_ptr; } + /// в случае nullptr методы разыменования кидают исключение, + /// с более подробным текстом, чем просто nullptr + ZooKeeper * operator->(); + const ZooKeeper * operator->() const; + ZooKeeper & operator*(); + const ZooKeeper & operator*() const; private: ZooKeeper::Ptr zk_ptr; @@ -50,6 +55,8 @@ protected: private: mutable std::mutex mutex; ZooKeeper::Ptr ptr; + + static std::string nullptr_exception_message; }; template @@ -58,4 +65,6 @@ void ZooKeeperHolder::init(Args&&... args) ptr = std::make_shared(std::forward(args)...); } +using ZooKeeperHolderPtr = std::shared_ptr; + }; /*namespace zkutil*/ \ No newline at end of file diff --git a/libs/libzkutil/src/ZooKeeperHolder.cpp b/libs/libzkutil/src/ZooKeeperHolder.cpp index 582cc14d307..80639fe589e 100644 --- a/libs/libzkutil/src/ZooKeeperHolder.cpp +++ b/libs/libzkutil/src/ZooKeeperHolder.cpp @@ -25,7 +25,41 @@ bool ZooKeeperHolder::isSessionExpired() const return ptr ? ptr->expired() : false; } + +std::string ZooKeeperHolder::nullptr_exception_message = + "UnstorableZookeeperHandler::zk_ptr is nullptr. " + "ZooKeeperHolder should be initialized before sending any request to ZooKeeper"; + ZooKeeperHolder::UnstorableZookeeperHandler::UnstorableZookeeperHandler(ZooKeeper::Ptr zk_ptr_) : zk_ptr(zk_ptr_) { +} + +ZooKeeper * ZooKeeperHolder::UnstorableZookeeperHandler::operator->() +{ + if (zk_ptr == nullptr) + throw DB::Exception(nullptr_exception_message); + + return zk_ptr.get(); +} + +const ZooKeeper * ZooKeeperHolder::UnstorableZookeeperHandler::operator->() const +{ + if (zk_ptr == nullptr) + throw DB::Exception(nullptr_exception_message); + return zk_ptr.get(); +} + +ZooKeeper & ZooKeeperHolder::UnstorableZookeeperHandler::operator*() +{ + if (zk_ptr == nullptr) + throw DB::Exception(nullptr_exception_message); + return *zk_ptr; +} + +const ZooKeeper & ZooKeeperHolder::UnstorableZookeeperHandler::operator*() const +{ + if (zk_ptr == nullptr) + throw DB::Exception(nullptr_exception_message); + return *zk_ptr; } \ No newline at end of file From 4afceba26c7cc22cb34fb5a973f547f5c2454640 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Thu, 10 Dec 2015 17:58:13 +0300 Subject: [PATCH 04/66] zkutil::Lock: use ZooKeeperHolder [#METR-18346] --- libs/libzkutil/include/zkutil/Lock.h | 26 +++++++++++++++++++------- libs/libzkutil/src/Lock.cpp | 7 +++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/libs/libzkutil/include/zkutil/Lock.h b/libs/libzkutil/include/zkutil/Lock.h index aa8e579b686..e9cbfcd5c26 100644 --- a/libs/libzkutil/include/zkutil/Lock.h +++ b/libs/libzkutil/include/zkutil/Lock.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -11,13 +11,22 @@ namespace zkutil public: /// lock_prefix - относительный путь до блокировки в ZK. Начинается со слеша /// lock_name - имя ноды блокировки в ZK - Lock(zkutil::ZooKeeperPtr zk, const std::string & lock_prefix_, const std::string & lock_name_, const std::string & lock_message_ = "", - bool create_parent_path = false) : - zookeeper(zk), lock_path(lock_prefix_ + "/" + lock_name_), lock_message(lock_message_), log(&Logger::get("zkutil::Lock")) + Lock( + zkutil::ZooKeeperHolderPtr zookeeper_holder_, + const std::string & lock_prefix_, + const std::string & lock_name_, + const std::string & lock_message_ = "", + bool create_parent_path_ = false) + : + zookeeper_holder(zookeeper_holder_), + lock_path(lock_prefix_ + "/" + lock_name_), + lock_message(lock_message_), + log(&Logger::get("zkutil::Lock")) { - if (create_parent_path) + auto zookeeper = zookeeper_holder->getZooKeeper(); + if (create_parent_path_) zookeeper->createAncestors(lock_prefix_); - + zookeeper->createIfNotExists(lock_prefix_, ""); } @@ -59,7 +68,10 @@ namespace zkutil private: Status checkImpl(); - zkutil::ZooKeeperPtr zookeeper; + + private: + zkutil::ZooKeeperHolderPtr zookeeper_holder; + std::string lock_path; std::string lock_message; Logger * log; diff --git a/libs/libzkutil/src/Lock.cpp b/libs/libzkutil/src/Lock.cpp index 2eda4a97dc3..73c391796af 100644 --- a/libs/libzkutil/src/Lock.cpp +++ b/libs/libzkutil/src/Lock.cpp @@ -4,6 +4,8 @@ using namespace zkutil; bool Lock::tryLock() { + auto zookeeper = zookeeper_holder->getZooKeeper(); + if (locked) { /// проверим, что нода создана и я ее владелец @@ -43,6 +45,8 @@ bool Lock::tryLock() void Lock::unlock() { + auto zookeeper = zookeeper_holder->getZooKeeper(); + if (locked) { /// проверим, что до сих пор мы владельцы ноды @@ -76,6 +80,8 @@ Lock::Status Lock::check() Lock::Status Lock::checkImpl() { + auto zookeeper = zookeeper_holder->getZooKeeper(); + Stat stat; std::string dummy; bool result = zookeeper->tryGet(lock_path, dummy, &stat); @@ -101,3 +107,4 @@ std::string Lock::status2String(Status status) static const char * names[] = {"Unlocked", "Locked by me", "Locked by other"}; return names[status]; } + From 9c064a1440b1bae22033845ea533219518a2ec79 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 14 Dec 2015 14:49:50 +0300 Subject: [PATCH 05/66] zookeeper: use ZookeeperHolder in statdaemons [#METR-18346] --- libs/libzkutil/include/zkutil/Increment.h | 17 +++++++++-------- libs/libzkutil/src/tests/zkutil_test_lock.cpp | 5 ++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libs/libzkutil/include/zkutil/Increment.h b/libs/libzkutil/include/zkutil/Increment.h index 37b698d0290..decb71c287f 100644 --- a/libs/libzkutil/include/zkutil/Increment.h +++ b/libs/libzkutil/include/zkutil/Increment.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace zkutil { @@ -8,10 +8,10 @@ namespace zkutil class Increment { public: - Increment(ZooKeeperPtr zk_, const std::string & path_) - : zk(zk_), path(path_) + Increment(ZooKeeperHolderPtr zk_holder_, const std::string & path_) + : zookeeper_holder(zk_holder_), path(path_) { - zk->createAncestors(path); + zookeeper_holder->getZooKeeper()->createAncestors(path); } size_t get() @@ -23,16 +23,17 @@ public: zkutil::Stat stat; bool success = false; + auto zookeeper = zookeeper_holder->getZooKeeper(); do { - if (zk->tryGet(path, result_str, &stat)) + if (zookeeper->tryGet(path, result_str, &stat)) { result = std::stol(result_str) + 1; - success = zk->trySet(path, std::to_string(result), stat.version) == ZOK; + success = zookeeper->trySet(path, std::to_string(result), stat.version) == ZOK; } else { - success = zk->tryCreate(path, std::to_string(result), zkutil::CreateMode::Persistent) == ZOK; + success = zookeeper->tryCreate(path, std::to_string(result), zkutil::CreateMode::Persistent) == ZOK; } } while (!success); @@ -40,7 +41,7 @@ public: return result; } private: - zkutil::ZooKeeperPtr zk; + zkutil::ZooKeeperHolderPtr zookeeper_holder; std::string path; Logger * log = &Logger::get("zkutil::Increment"); }; diff --git a/libs/libzkutil/src/tests/zkutil_test_lock.cpp b/libs/libzkutil/src/tests/zkutil_test_lock.cpp index 6acaeaac4a7..6da1a827829 100644 --- a/libs/libzkutil/src/tests/zkutil_test_lock.cpp +++ b/libs/libzkutil/src/tests/zkutil_test_lock.cpp @@ -6,7 +6,10 @@ int main() try { - zkutil::Lock l(std::make_shared("localhost:2181"), "/test", "test_lock"); + auto zookeeper_holder = std::make_shared(); + zookeeper_holder->init("localhost:2181"); + + zkutil::Lock l(zookeeper_holder, "/test", "test_lock"); std::cout << "check " << l.check() << std::endl; std::cout << "lock tryLock() " << l.tryLock() << std::endl; std::cout << "check " << l.check() << std::endl; From 3dd3eca4098ebeecc5952ba131926a780045024b Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 14 Dec 2015 18:29:12 +0300 Subject: [PATCH 06/66] zkutil::Lock: add tryCheck method which down't throw if lock was stolen [#METR-18346] --- libs/libzkutil/include/zkutil/Lock.h | 7 +--- libs/libzkutil/src/Lock.cpp | 59 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/libs/libzkutil/include/zkutil/Lock.h b/libs/libzkutil/include/zkutil/Lock.h index e9cbfcd5c26..c78797120e1 100644 --- a/libs/libzkutil/include/zkutil/Lock.h +++ b/libs/libzkutil/include/zkutil/Lock.h @@ -55,9 +55,7 @@ namespace zkutil std::string status2String(Status status); /// проверяет создана ли эфемерная нода и кто ее владелец. - /// если мы сами создавали эфемерную ноду, то надо вызывать этот метод, чтобы убедится, - /// что сессия с зукипером не порвалось - Status check(); + Status tryCheck() const; void unlock(); @@ -66,9 +64,6 @@ namespace zkutil /// путь к ноде блокировки в zookeeper const std::string & getPath() { return lock_path; } - private: - Status checkImpl(); - private: zkutil::ZooKeeperHolderPtr zookeeper_holder; diff --git a/libs/libzkutil/src/Lock.cpp b/libs/libzkutil/src/Lock.cpp index 73c391796af..89fbda5db73 100644 --- a/libs/libzkutil/src/Lock.cpp +++ b/libs/libzkutil/src/Lock.cpp @@ -5,13 +5,14 @@ using namespace zkutil; bool Lock::tryLock() { auto zookeeper = zookeeper_holder->getZooKeeper(); - if (locked) { /// проверим, что нода создана и я ее владелец - check(); + if (tryCheck() != Status::LOCKED_BY_ME) + locked = false; } - else + + if (!locked) { size_t attempt; std::string dummy; @@ -49,55 +50,53 @@ void Lock::unlock() if (locked) { - /// проверим, что до сих пор мы владельцы ноды - check(); - - size_t attempt; - int32_t code = zookeeper->tryRemoveWithRetries(lock_path, -1, &attempt); - if (attempt) + if (tryCheck() == Status::LOCKED_BY_ME) { - if (code != ZOK) - throw zkutil::KeeperException(code); - } - else - { - if (code == ZNONODE) - LOG_ERROR(log, "Node " << lock_path << " has been already removed. Probably due to network error."); - else if (code != ZOK) - throw zkutil::KeeperException(code); + size_t attempt; + int32_t code = zookeeper->tryRemoveWithRetries(lock_path, -1, &attempt); + if (attempt) + { + if (code != ZOK) + throw zkutil::KeeperException(code); + } + else + { + if (code == ZNONODE) + LOG_ERROR(log, "Node " << lock_path << " has been already removed. Probably due to network error."); + else if (code != ZOK) + throw zkutil::KeeperException(code); + } } locked = false; } } -Lock::Status Lock::check() -{ - Status status = checkImpl(); - if ((locked && status != LOCKED_BY_ME) || (!locked && (status != UNLOCKED && status != LOCKED_BY_OTHER))) - throw zkutil::KeeperException(std::string("Incompability of local state and state in zookeeper. Local is ") + (locked ? "locked" : "unlocked") + ". Zookeeper state is " + status2String(status)); - return status; -} - -Lock::Status Lock::checkImpl() +Lock::Status Lock::tryCheck() const { auto zookeeper = zookeeper_holder->getZooKeeper(); + Status lock_status; Stat stat; std::string dummy; bool result = zookeeper->tryGet(lock_path, dummy, &stat); if (!result) - return UNLOCKED; + lock_status = UNLOCKED; else { if (stat.ephemeralOwner == zookeeper->getClientID()) { - return LOCKED_BY_ME; + lock_status = LOCKED_BY_ME; } else { - return LOCKED_BY_OTHER; + lock_status = LOCKED_BY_OTHER; } } + + if (locked && lock_status != LOCKED_BY_ME) + LOG_WARNING(log, "Lock is lost. It is normal if session was reinitialized. Path: " << lock_path << "/" << lock_message); + + return lock_status; } std::string Lock::status2String(Status status) From 75142c5d4103c280a998e405d736c660476b1db5 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 14 Dec 2015 18:30:38 +0300 Subject: [PATCH 07/66] daemons: use zkutil::Lock::tryCheck [#METR-18346] --- libs/libzkutil/src/tests/zkutil_test_lock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libzkutil/src/tests/zkutil_test_lock.cpp b/libs/libzkutil/src/tests/zkutil_test_lock.cpp index 6da1a827829..52f8943a2e1 100644 --- a/libs/libzkutil/src/tests/zkutil_test_lock.cpp +++ b/libs/libzkutil/src/tests/zkutil_test_lock.cpp @@ -10,9 +10,9 @@ int main() zookeeper_holder->init("localhost:2181"); zkutil::Lock l(zookeeper_holder, "/test", "test_lock"); - std::cout << "check " << l.check() << std::endl; + std::cout << "check " << l.tryCheck() << std::endl; std::cout << "lock tryLock() " << l.tryLock() << std::endl; - std::cout << "check " << l.check() << std::endl; + std::cout << "check " << l.tryCheck() << std::endl; } catch (const Poco::Exception & e) { From c8bc21d0324963a4a5bf6f31b078a1c3d5494b67 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Tue, 15 Dec 2015 13:09:06 +0300 Subject: [PATCH 08/66] ZooKeeperHolder: add debug message [#METR-18346] --- libs/libzkutil/include/zkutil/ZooKeeperHolder.h | 2 ++ libs/libzkutil/src/ZooKeeperHolder.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h index 9778f6ce4e5..a18214eb315 100644 --- a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h +++ b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h @@ -56,6 +56,8 @@ private: mutable std::mutex mutex; ZooKeeper::Ptr ptr; + Logger * log = &Logger::get("ZooKeeperHolder"); + static std::string nullptr_exception_message; }; diff --git a/libs/libzkutil/src/ZooKeeperHolder.cpp b/libs/libzkutil/src/ZooKeeperHolder.cpp index 80639fe589e..e55446c41b3 100644 --- a/libs/libzkutil/src/ZooKeeperHolder.cpp +++ b/libs/libzkutil/src/ZooKeeperHolder.cpp @@ -17,7 +17,11 @@ bool ZooKeeperHolder::replaceZooKeeperSessionToNewOne() ptr = ptr->startNewSession(); return true; } + else + { + LOG_ERROR(log, "replaceZooKeeperSessionToNewOne(): Fail to replace zookeeper session to new one because handlers for old zookeeper session still exists."); return false; + } } bool ZooKeeperHolder::isSessionExpired() const From 915fbd16a652a72f9a3e22126665738b06e09de4 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Fri, 18 Dec 2015 14:22:03 +0300 Subject: [PATCH 09/66] zkutil::Lock: store ZooKeeperHandler if lock is locked to prevent reinitialization of zookeeper session [#METR-18346] --- libs/libzkutil/include/zkutil/Lock.h | 5 ++++- libs/libzkutil/include/zkutil/ZooKeeperHolder.h | 14 ++++++++++++-- libs/libzkutil/src/Lock.cpp | 12 ++++++------ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/libs/libzkutil/include/zkutil/Lock.h b/libs/libzkutil/include/zkutil/Lock.h index c78797120e1..31486b86c3d 100644 --- a/libs/libzkutil/include/zkutil/Lock.h +++ b/libs/libzkutil/include/zkutil/Lock.h @@ -66,10 +66,13 @@ namespace zkutil private: zkutil::ZooKeeperHolderPtr zookeeper_holder; + /// пока храним указатель на хендлер, никто не может переиницализировать сессию с zookeeper + using ZooKeeperHandler = zkutil::ZooKeeperHolder::UnstorableZookeeperHandler; + std::unique_ptr locked; std::string lock_path; std::string lock_message; Logger * log; - bool locked = false; + }; } diff --git a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h index a18214eb315..c2e009f0094 100644 --- a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h +++ b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h @@ -9,6 +9,8 @@ namespace zkutil class ZooKeeperHolder : public boost::noncopyable { + friend class zkutil::Lock; + protected: class UnstorableZookeeperHandler; @@ -29,8 +31,16 @@ public: protected: /** Хендлер для подсчета количества используемых ссылок на ZooKeeper * - * Специально поддерживает только хранение на стеке. - * Что вынуждает перед каждым использованием явно запросить хэндлер у ZooKeeperHolder + * Запрещается переинициализировать ZooKeeper пока, хранится хотя бы один хендлер на него. + * Большинство классов должны хранить хендлер на стеке и не хранить как член класса. + * Т.е. хранить holder и запрашивать хендлер перед каждым использованием. + * Поэтому класс специально объявлен, как protected. + * + * Исключение - классы, работающие с эфимерными нодами. Пример: zkutil::Lock + * + * Как использовать: + * auto zookeeper = zookeeper_holder->getZooKeeper(); + * zookeeper->get(path); */ class UnstorableZookeeperHandler { diff --git a/libs/libzkutil/src/Lock.cpp b/libs/libzkutil/src/Lock.cpp index 89fbda5db73..aea62ca00af 100644 --- a/libs/libzkutil/src/Lock.cpp +++ b/libs/libzkutil/src/Lock.cpp @@ -9,7 +9,7 @@ bool Lock::tryLock() { /// проверим, что нода создана и я ее владелец if (tryCheck() != Status::LOCKED_BY_ME) - locked = false; + locked.reset(nullptr); } if (!locked) @@ -21,20 +21,20 @@ bool Lock::tryLock() if (code == ZNODEEXISTS) { if (attempt == 0) - locked = false; + locked.reset(nullptr); else { zkutil::Stat stat; zookeeper->get(lock_path, &stat); if (stat.ephemeralOwner == zookeeper->getClientID()) - locked = true; + locked.reset(new ZooKeeperHandler(zookeeper)); else - locked = false; + locked.reset(nullptr); } } else if (code == ZOK) { - locked = true; + locked.reset(new ZooKeeperHandler(zookeeper)); } else { @@ -67,7 +67,7 @@ void Lock::unlock() throw zkutil::KeeperException(code); } } - locked = false; + locked.reset(nullptr); } } From a910893edc1667fb3f2c453c43c30089e0583bc1 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 21 Dec 2015 12:54:08 +0300 Subject: [PATCH 10/66] zkutil::Lock: unlock doesn't throw if zookeeper in unrecoverable state [#METR-18346] --- libs/libzkutil/src/Lock.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/libs/libzkutil/src/Lock.cpp b/libs/libzkutil/src/Lock.cpp index aea62ca00af..6dc397155bf 100644 --- a/libs/libzkutil/src/Lock.cpp +++ b/libs/libzkutil/src/Lock.cpp @@ -50,23 +50,33 @@ void Lock::unlock() if (locked) { - if (tryCheck() == Status::LOCKED_BY_ME) + try { - size_t attempt; - int32_t code = zookeeper->tryRemoveWithRetries(lock_path, -1, &attempt); - if (attempt) + if (tryCheck() == Status::LOCKED_BY_ME) { - if (code != ZOK) - throw zkutil::KeeperException(code); - } - else - { - if (code == ZNONODE) - LOG_ERROR(log, "Node " << lock_path << " has been already removed. Probably due to network error."); - else if (code != ZOK) - throw zkutil::KeeperException(code); + size_t attempt; + int32_t code = zookeeper->tryRemoveWithRetries(lock_path, -1, &attempt); + if (attempt) + { + if (code != ZOK) + throw zkutil::KeeperException(code); + } + else + { + if (code == ZNONODE) + LOG_ERROR(log, "Node " << lock_path << " has been already removed. Probably due to network error."); + else if (code != ZOK) + throw zkutil::KeeperException(code); + } } } + catch (const zkutil::KeeperException & e) + { + /// если сессия находится в невостанавливаемом состоянии, то эфимерные ноды нам больше не принадлежат + /// и лок через таймаут будет отпущен + if (!e.isUnrecoverable()) + throw; + } locked.reset(nullptr); } } From db6e6a28425a94bbb3d0b2724f18c726dc71b7ed Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 21 Dec 2015 12:55:56 +0300 Subject: [PATCH 11/66] zkutil::KeeperException: add isHardwareError [#METR-18346] --- libs/libzkutil/include/zkutil/KeeperException.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/libzkutil/include/zkutil/KeeperException.h b/libs/libzkutil/include/zkutil/KeeperException.h index 96fae823c36..4044fe6ed91 100644 --- a/libs/libzkutil/include/zkutil/KeeperException.h +++ b/libs/libzkutil/include/zkutil/KeeperException.h @@ -34,6 +34,13 @@ public: return code == ZINVALIDSTATE || code == ZSESSIONEXPIRED || code == ZSESSIONMOVED; } + /// любая ошибка связанная с работой сети, перевыбором мастера + /// при этих ошибках надо либо повторить запрос повторно, либо переинициализировать сессию (см. isUnrecoverable()) + bool isHardwareError() const + { + return isUnrecoverable() || code == ZCONNECTIONLOSS || code == ZOPERATIONTIMEOUT; + } + const int32_t code; private: From 74bf0583791d2225f9dcb318cd86d2aeaa635625 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Fri, 25 Dec 2015 12:10:17 +0300 Subject: [PATCH 12/66] zkutil: build fix [#METR-18346] --- libs/libzkutil/include/zkutil/ZooKeeperHolder.h | 1 + libs/libzkutil/src/Lock.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h index c2e009f0094..d82b74ea68e 100644 --- a/libs/libzkutil/include/zkutil/ZooKeeperHolder.h +++ b/libs/libzkutil/include/zkutil/ZooKeeperHolder.h @@ -6,6 +6,7 @@ namespace zkutil { +class Lock; class ZooKeeperHolder : public boost::noncopyable { diff --git a/libs/libzkutil/src/Lock.cpp b/libs/libzkutil/src/Lock.cpp index 6dc397155bf..d10a3a10f28 100644 --- a/libs/libzkutil/src/Lock.cpp +++ b/libs/libzkutil/src/Lock.cpp @@ -41,7 +41,7 @@ bool Lock::tryLock() throw zkutil::KeeperException(code); } } - return locked; + return bool(locked); } void Lock::unlock() From a6b01ee987c44a8291c616ffdedb63677ef0780a Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 30 Dec 2015 18:39:11 +0300 Subject: [PATCH 13/66] dbms: multiple MemoryTrackers: development [#METR-19561]. --- dbms/include/DB/Common/MemoryTracker.h | 27 ++++++++-- dbms/include/DB/Interpreters/ProcessList.h | 12 ++++- dbms/src/Common/MemoryTracker.cpp | 57 +++++++++++++++++++--- dbms/src/Interpreters/ProcessList.cpp | 4 ++ 4 files changed, 88 insertions(+), 12 deletions(-) diff --git a/dbms/include/DB/Common/MemoryTracker.h b/dbms/include/DB/Common/MemoryTracker.h index bce58353c27..7b975a59529 100644 --- a/dbms/include/DB/Common/MemoryTracker.h +++ b/dbms/include/DB/Common/MemoryTracker.h @@ -16,6 +16,12 @@ class MemoryTracker /// В целях тестирования exception safety - кидать исключение при каждом выделении памяти с указанной вероятностью. double fault_probability = 0; + /// Односвязный список. Вся информация будет передаваться в следующие MemoryTracker-ы тоже. + MemoryTracker * next = nullptr; + + /// Если задано (например, "for user") - в сообщениях в логе будет указываться это описание. + const char * description = nullptr; + public: MemoryTracker(Int64 limit_) : limit(limit_) {} @@ -32,10 +38,7 @@ public: /** А эту функцию имеет смысл вызывать после освобождения памяти. */ - void free(Int64 size) - { - __sync_sub_and_fetch(&amount, size); - } + void free(Int64 size); Int64 get() const { @@ -51,6 +54,22 @@ public: { fault_probability = value; } + + void setNext(MemoryTracker * next_) + { + next = next_; + } + + void setDescription(const char * description_) + { + description = description_; + } + + /// Обнулить накопленные данные. + void reset(); + + /// Вывести в лог информацию о пиковом потреблении памяти. + void logPeakMemoryUsage() const; }; diff --git a/dbms/include/DB/Interpreters/ProcessList.h b/dbms/include/DB/Interpreters/ProcessList.h index 0cb48c91318..0deaefa3ef4 100644 --- a/dbms/include/DB/Interpreters/ProcessList.h +++ b/dbms/include/DB/Interpreters/ProcessList.h @@ -48,7 +48,8 @@ struct ProcessListElement ProcessListElement(const String & query_, const String & user_, const String & query_id_, const Poco::Net::IPAddress & ip_address_, - size_t max_memory_usage, double memory_tracker_fault_probability, QueryPriorities::Handle && priority_handle_) + size_t max_memory_usage, double memory_tracker_fault_probability, + QueryPriorities::Handle && priority_handle_) : query(query_), user(user_), query_id(query_id_), ip_address(ip_address_), memory_tracker(max_memory_usage), priority_handle(std::move(priority_handle_)) { @@ -75,6 +76,15 @@ struct ProcessListElement }; +/// Данные о запросах одного пользователя. +struct ProcessListForUser +{ + /// Query_id -> ProcessListElement * + using QueryToElement = std::unordered_map; + QueryToElement queries; +}; + + class ProcessList; diff --git a/dbms/src/Common/MemoryTracker.cpp b/dbms/src/Common/MemoryTracker.cpp index 8b50006b43a..8b738ce41a8 100644 --- a/dbms/src/Common/MemoryTracker.cpp +++ b/dbms/src/Common/MemoryTracker.cpp @@ -10,9 +10,18 @@ MemoryTracker::~MemoryTracker() { - LOG_DEBUG(&Logger::get("MemoryTracker"), "Peak memory usage for query: " << formatReadableSizeWithBinarySuffix(peak) << "."); + logPeakMemoryUsage(); } + +void MemoryTracker::logPeakMemoryUsage() const +{ + LOG_DEBUG(&Logger::get("MemoryTracker"), + "Peak memory usage" << (description ? " " + std::string(description) : "") + << ": " << formatReadableSizeWithBinarySuffix(peak) << "."); +} + + void MemoryTracker::alloc(Int64 size) { Int64 will_be = __sync_add_and_fetch(&amount, size); @@ -22,21 +31,55 @@ void MemoryTracker::alloc(Int64 size) if (unlikely(fault_probability && drand48() < fault_probability)) { free(size); - throw DB::Exception("Memory tracker: fault injected. Would use " + formatReadableSizeWithBinarySuffix(will_be) + "" - " (attempt to allocate chunk of " + DB::toString(size) + " bytes)" - ", maximum: " + formatReadableSizeWithBinarySuffix(limit), DB::ErrorCodes::MEMORY_LIMIT_EXCEEDED); + + std::stringstream message; + message << "Memory tracker"; + if (description) + message << " " << description; + message << ": fault injected. Would use " << formatReadableSizeWithBinarySuffix(will_be) + << " (attempt to allocate chunk of " << size << " bytes)" + << ", maximum: " << formatReadableSizeWithBinarySuffix(limit); + + throw DB::Exception(message.str(), DB::ErrorCodes::MEMORY_LIMIT_EXCEEDED); } if (unlikely(limit && will_be > limit)) { free(size); - throw DB::Exception("Memory limit exceeded: would use " + formatReadableSizeWithBinarySuffix(will_be) + "" - " (attempt to allocate chunk of " + DB::toString(size) + " bytes)" - ", maximum: " + formatReadableSizeWithBinarySuffix(limit), DB::ErrorCodes::MEMORY_LIMIT_EXCEEDED); + + std::stringstream message; + message << "Memory limit"; + if (description) + message << " " << description; + message << " exceeded: would use " << formatReadableSizeWithBinarySuffix(will_be) + << " (attempt to allocate chunk of " << size << " bytes)" + << ", maximum: " << formatReadableSizeWithBinarySuffix(limit); + + throw DB::Exception(message.str(), DB::ErrorCodes::MEMORY_LIMIT_EXCEEDED); } if (will_be > peak) peak = will_be; + + if (next) + next->alloc(size); +} + + +void MemoryTracker::free(Int64 size) +{ + __sync_sub_and_fetch(&amount, size); + + if (next) + next->free(size); +} + + +void MemoryTracker::reset() +{ + amount = 0; + peak = 0; + limit = 0; } diff --git a/dbms/src/Interpreters/ProcessList.cpp b/dbms/src/Interpreters/ProcessList.cpp index 505aaf35934..c0dcabee134 100644 --- a/dbms/src/Interpreters/ProcessList.cpp +++ b/dbms/src/Interpreters/ProcessList.cpp @@ -70,6 +70,10 @@ ProcessListEntry::~ProcessListEntry() ProcessList::QueryToElement::iterator element = queries->second.find(it->query_id); if (element != queries->second.end()) queries->second.erase(element); + + /// Если запросов для пользователя больше нет, то удаляем запись + if (queries->second.empty()) + parent.user_to_queries.erase(queries); } } From 13c7d0983ae9bedbfdf8021253f7c24591c49361 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 12 Jan 2016 00:46:36 +0300 Subject: [PATCH 14/66] dbms: cutting dependency [#METR-2944].. --- .../AggregateFunctions/IAggregateFunction.h | 9 +- .../DB/Client/ConnectionPoolWithFailover.h | 8 + .../DB/Columns/ColumnAggregateFunction.h | 6 + dbms/include/DB/Columns/ColumnArray.h | 8 +- dbms/include/DB/Columns/ColumnConst.h | 9 +- dbms/include/DB/Columns/ColumnFixedString.h | 9 + dbms/include/DB/Columns/ColumnString.h | 7 + dbms/include/DB/Columns/ColumnTuple.h | 6 + dbms/include/DB/Columns/ColumnVector.h | 7 +- dbms/include/DB/Columns/IColumn.h | 7 +- dbms/include/DB/Common/AIO.h | 8 +- dbms/include/DB/Common/Allocator.h | 13 +- dbms/include/DB/Common/Collator.h | 14 +- dbms/include/DB/Common/CompactArray.h | 7 +- dbms/include/DB/Common/HashTable/HashTable.h | 11 +- .../DB/Common/HyperLogLogBiasEstimator.h | 1 - dbms/include/DB/Common/HyperLogLogCounter.h | 11 +- dbms/include/DB/Common/LRUCache.h | 1 - dbms/include/DB/Common/PODArray.h | 1 - dbms/include/DB/Common/PoolWithFailoverBase.h | 11 +- dbms/include/DB/Common/RadixSort.h | 1 + dbms/include/DB/Common/SmallObjectPool.h | 1 - dbms/include/DB/Common/Throttler.h | 6 + dbms/include/DB/Core/Block.h | 1 - dbms/include/DB/Core/BlockInfo.h | 6 +- dbms/include/DB/Core/ErrorCodes.h | 318 --------- dbms/include/DB/Core/Field.h | 8 +- dbms/include/DB/Core/FieldVisitors.h | 5 + .../MergingSortedBlockInputStream.h | 6 + .../ProhibitColumnsBlockOutputStream.h | 5 + .../DB/DataStreams/RemoteBlockOutputStream.h | 7 + .../SummingSortedBlockInputStream.h | 43 +- .../DB/DataTypes/DataTypeAggregateFunction.h | 7 + dbms/include/DB/DataTypes/DataTypeEnum.h | 7 + .../DB/DataTypes/DataTypeFixedString.h | 5 + dbms/include/DB/DataTypes/FieldToDataType.h | 7 +- .../DB/Dictionaries/DictionaryStructure.h | 8 +- dbms/include/DB/Functions/FunctionsArray.h | 8 + .../DB/Functions/FunctionsMiscellaneous.h | 7 + dbms/include/DB/Functions/IFunction.h | 7 + dbms/include/DB/IO/BufferWithOwnMemory.h | 1 - dbms/include/DB/IO/CompressedReadBufferBase.h | 10 +- .../DB/IO/CompressedReadBufferFromFile.h | 6 + dbms/include/DB/IO/CompressedWriteBuffer.h | 7 + dbms/include/DB/IO/ReadBuffer.h | 7 +- dbms/include/DB/IO/ReadBufferFromFile.h | 8 + .../DB/IO/ReadBufferFromFileDescriptor.h | 9 +- dbms/include/DB/IO/ReadBufferFromHTTP.h | 6 + dbms/include/DB/IO/ReadBufferFromIStream.h | 7 +- dbms/include/DB/IO/ReadHelpers.h | 8 +- dbms/include/DB/IO/WriteBuffer.h | 7 +- dbms/include/DB/IO/WriteBufferFromFile.h | 8 + .../DB/IO/WriteBufferFromFileDescriptor.h | 9 +- .../DB/IO/WriteBufferFromHTTPServerResponse.h | 6 +- dbms/include/DB/IO/WriteBufferFromOStream.h | 6 +- dbms/include/DB/IO/WriteHelpers.h | 6 +- dbms/include/DB/Interpreters/Aggregator.h | 5 + .../DB/Interpreters/ExpressionActions.h | 9 +- .../DB/Interpreters/ExternalDictionaries.h | 1 - .../InJoinSubqueriesPreprocessor.h | 5 + .../DB/Interpreters/InterpreterSetQuery.h | 5 + .../DB/Interpreters/InterserverIOHandler.h | 7 + dbms/include/DB/Interpreters/ProcessList.h | 1 - dbms/include/DB/Interpreters/Quota.h | 1 - dbms/include/DB/Interpreters/SettingsCommon.h | 19 +- dbms/include/DB/Interpreters/Users.h | 11 +- dbms/include/DB/Parsers/ASTAlterQuery.h | 5 + dbms/include/DB/Parsers/IAST.h | 18 +- .../DB/Storages/CompressionMethodSelector.h | 8 +- .../Storages/Distributed/DirectoryMonitor.h | 8 + dbms/include/DB/Storages/IStorage.h | 5 + .../DB/Storages/MergeTree/DiskSpaceMonitor.h | 8 +- .../MergeTree/MergeTreeBlockInputStream.h | 6 + .../DB/Storages/MergeTree/MergeTreeData.h | 18 + .../DB/Storages/MergeTree/MergeTreeReader.h | 7 + .../ReplicatedMergeTreeBlockOutputStream.h | 10 + .../MergeTree/ReplicatedMergeTreeLogEntry.h | 8 +- dbms/include/DB/Storages/StorageLog.h | 6 + .../DB/TableFunctions/TableFunctionMerge.h | 7 + .../DB/TableFunctions/TableFunctionRemote.h | 8 +- dbms/src/Client/Connection.cpp | 11 +- dbms/src/Client/InterruptListener.h | 10 +- dbms/src/Columns/ColumnsCommon.cpp | 6 + dbms/src/Common/Exception.cpp | 9 + dbms/src/Common/Macros.cpp | 6 +- dbms/src/Common/MemoryTracker.cpp | 9 + dbms/src/Common/ShellCommand.cpp | 15 +- dbms/src/Common/localBackup.cpp | 12 +- dbms/src/Core/Block.cpp | 9 +- dbms/src/Core/ErrorCodes.cpp | 314 +++++++++ dbms/src/Core/NamesAndTypes.cpp | 6 + .../BlockInputStreamFromRowInputStream.cpp | 6 +- .../CollapsingSortedBlockInputStream.cpp | 5 + .../CreatingSetsBlockInputStream.cpp | 7 + .../DataStreams/DistinctBlockInputStream.cpp | 6 + .../DataStreams/FilterBlockInputStream.cpp | 5 + dbms/src/DataStreams/FormatFactory.cpp | 7 + dbms/src/DataStreams/IBlockInputStream.cpp | 5 + .../IProfilingBlockInputStream.cpp | 12 +- .../MergingSortedBlockInputStream.cpp | 7 + .../DataStreams/NativeBlockInputStream.cpp | 7 + .../DataStreams/RemoteBlockInputStream.cpp | 7 + .../SummingSortedBlockInputStream.cpp | 38 ++ .../TabSeparatedRowInputStream.cpp | 6 + .../TotalsHavingBlockInputStream.cpp | 7 + dbms/src/DataTypes/DataTypeArray.cpp | 5 + dbms/src/DataTypes/DataTypeFactory.cpp | 9 + dbms/src/DataTypes/DataTypeFixedString.cpp | 5 + dbms/src/DataTypes/DataTypeNested.cpp | 5 + dbms/src/DataTypes/FieldToDataType.cpp | 7 + dbms/src/IO/ReadBufferAIO.cpp | 11 +- dbms/src/IO/ReadBufferFromPocoSocket.cpp | 9 +- dbms/src/IO/ReadHelpers.cpp | 7 + dbms/src/IO/WriteBufferAIO.cpp | 16 +- dbms/src/IO/WriteBufferFromPocoSocket.cpp | 9 +- dbms/src/Interpreters/Aggregator.cpp | 8 + dbms/src/Interpreters/Context.cpp | 11 + dbms/src/Interpreters/ExpressionActions.cpp | 11 + dbms/src/Interpreters/ExpressionAnalyzer.cpp | 17 + .../src/Interpreters/ExternalDictionaries.cpp | 7 + .../Interpreters/InterpreterAlterQuery.cpp | 11 +- .../Interpreters/InterpreterCheckQuery.cpp | 7 + .../Interpreters/InterpreterCreateQuery.cpp | 11 + .../src/Interpreters/InterpreterDropQuery.cpp | 6 + dbms/src/Interpreters/InterpreterFactory.cpp | 6 + .../Interpreters/InterpreterInsertQuery.cpp | 5 + .../Interpreters/InterpreterSelectQuery.cpp | 12 + .../LogicalExpressionsOptimizer.cpp | 9 +- dbms/src/Interpreters/ProcessList.cpp | 6 + dbms/src/Interpreters/Quota.cpp | 8 + dbms/src/Interpreters/executeQuery.cpp | 6 + dbms/src/Interpreters/loadMetadata.cpp | 7 + dbms/src/Interpreters/sortBlock.cpp | 8 +- dbms/src/Interpreters/tests/hash_map3.cpp | 1 - dbms/src/Parsers/ASTSelectQuery.cpp | 8 + dbms/src/Parsers/ExpressionElementParsers.cpp | 5 + dbms/src/Parsers/IParserBase.cpp | 6 + dbms/src/Parsers/ParserInsertQuery.cpp | 5 + dbms/src/Parsers/ParserJoin.cpp | 5 + dbms/src/Parsers/parseQuery.cpp | 8 +- dbms/src/Server/HTTPHandler.cpp | 8 +- dbms/src/Server/OLAPQueryParser.cpp | 17 +- dbms/src/Server/TCPHandler.cpp | 13 +- dbms/src/Storages/AlterCommands.cpp | 603 +++++++++--------- dbms/src/Storages/ColumnsDescription.cpp | 5 + dbms/src/Storages/ITableDeclaration.cpp | 11 + .../Storages/MergeTree/ActiveDataPartSet.cpp | 6 + .../MergeTree/BackgroundProcessingPool.cpp | 1 - .../MergeTree/MergeTreeDataMerger.cpp | 5 + .../MergeTree/MergeTreeDataSelectExecutor.cpp | 6 + .../MergeTree/MergeTreePartChecker.cpp | 9 + .../ReplicatedMergeTreeCleanupThread.cpp | 6 + .../ReplicatedMergeTreePartsExchange.cpp | 6 + .../ReplicatedMergeTreeRestartingThread.cpp | 6 + dbms/src/Storages/StorageBuffer.cpp | 6 + dbms/src/Storages/StorageChunkMerger.cpp | 24 +- dbms/src/Storages/StorageChunkRef.cpp | 6 + dbms/src/Storages/StorageChunks.cpp | 8 + dbms/src/Storages/StorageDistributed.cpp | 6 + dbms/src/Storages/StorageFactory.cpp | 10 + dbms/src/Storages/StorageJoin.cpp | 6 + dbms/src/Storages/StorageLog.cpp | 9 +- dbms/src/Storages/StorageMaterializedView.cpp | 6 + dbms/src/Storages/StorageMemory.cpp | 1 - dbms/src/Storages/StorageMerge.cpp | 6 + dbms/src/Storages/StorageMergeTree.cpp | 8 + .../Storages/StorageReplicatedMergeTree.cpp | 24 + dbms/src/Storages/StorageStripeLog.cpp | 7 +- dbms/src/Storages/StorageTinyLog.cpp | 9 +- dbms/src/Storages/StorageView.cpp | 5 + .../Storages/System/StorageSystemClusters.cpp | 1 + .../Storages/System/StorageSystemNumbers.cpp | 1 - dbms/src/Storages/System/StorageSystemOne.cpp | 1 - .../Storages/System/StorageSystemTables.cpp | 5 + dbms/src/Storages/VirtualColumnFactory.cpp | 6 + .../TableFunctions/TableFunctionFactory.cpp | 6 + .../include/zkutil/KeeperException.h | 11 +- 177 files changed, 1847 insertions(+), 750 deletions(-) delete mode 100644 dbms/include/DB/Core/ErrorCodes.h create mode 100644 dbms/src/Core/ErrorCodes.cpp diff --git a/dbms/include/DB/AggregateFunctions/IAggregateFunction.h b/dbms/include/DB/AggregateFunctions/IAggregateFunction.h index 6326c8359e1..cf195d18239 100644 --- a/dbms/include/DB/AggregateFunctions/IAggregateFunction.h +++ b/dbms/include/DB/AggregateFunctions/IAggregateFunction.h @@ -12,9 +12,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS; + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; +} -typedef char * AggregateDataPtr; -typedef const char * ConstAggregateDataPtr; +using AggregateDataPtr = char *; +using ConstAggregateDataPtr = const char *; /** Интерфейс для агрегатных функций. diff --git a/dbms/include/DB/Client/ConnectionPoolWithFailover.h b/dbms/include/DB/Client/ConnectionPoolWithFailover.h index 9b6fac6af85..4b611ff0601 100644 --- a/dbms/include/DB/Client/ConnectionPoolWithFailover.h +++ b/dbms/include/DB/Client/ConnectionPoolWithFailover.h @@ -12,6 +12,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NETWORK_ERROR; + extern const int SOCKET_TIMEOUT; + extern const int LOGICAL_ERROR; +} + + /** Пул соединений с отказоустойчивостью. * Инициализируется несколькими другими IConnectionPool-ами. * При получении соединения, пытается создать или выбрать живое соединение из какого-нибудь пула, diff --git a/dbms/include/DB/Columns/ColumnAggregateFunction.h b/dbms/include/DB/Columns/ColumnAggregateFunction.h index cce96eb80d8..03027fbdaed 100644 --- a/dbms/include/DB/Columns/ColumnAggregateFunction.h +++ b/dbms/include/DB/Columns/ColumnAggregateFunction.h @@ -16,6 +16,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int PARAMETER_OUT_OF_BOUND; + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; +} + /** Столбец состояний агрегатных функций. * Представлен в виде массива указателей на состояния агрегатных функций (data). diff --git a/dbms/include/DB/Columns/ColumnArray.h b/dbms/include/DB/Columns/ColumnArray.h index 14e683006b5..e6cf6ee7c4b 100644 --- a/dbms/include/DB/Columns/ColumnArray.h +++ b/dbms/include/DB/Columns/ColumnArray.h @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -16,6 +15,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_COLUMN; + extern const int NOT_IMPLEMENTED; + extern const int BAD_ARGUMENTS; +} + using Poco::SharedPtr; /** Cтолбeц значений типа массив. diff --git a/dbms/include/DB/Columns/ColumnConst.h b/dbms/include/DB/Columns/ColumnConst.h index cd05f1d72f6..7fcbaf8f32e 100644 --- a/dbms/include/DB/Columns/ColumnConst.h +++ b/dbms/include/DB/Columns/ColumnConst.h @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -14,6 +13,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN; + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; + extern const int NOT_IMPLEMENTED; + extern const int LOGICAL_ERROR; +} + using Poco::SharedPtr; diff --git a/dbms/include/DB/Columns/ColumnFixedString.h b/dbms/include/DB/Columns/ColumnFixedString.h index 693cbed9668..7453e4bfbdd 100644 --- a/dbms/include/DB/Columns/ColumnFixedString.h +++ b/dbms/include/DB/Columns/ColumnFixedString.h @@ -6,11 +6,20 @@ #include #include #include +#include namespace DB { +namespace ErrorCodes +{ + extern const int TOO_LARGE_STRING_SIZE; + extern const int SIZE_OF_ARRAY_DOESNT_MATCH_SIZE_OF_FIXEDARRAY_COLUMN; + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; + extern const int PARAMETER_OUT_OF_BOUND; +} + /** Cтолбeц значений типа "строка фиксированной длины". * Если вставить строку меньшей длины, то она будет дополнена нулевыми байтами. */ diff --git a/dbms/include/DB/Columns/ColumnString.h b/dbms/include/DB/Columns/ColumnString.h index 9c706d2bd40..3bd47a32da0 100644 --- a/dbms/include/DB/Columns/ColumnString.h +++ b/dbms/include/DB/Columns/ColumnString.h @@ -14,6 +14,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int PARAMETER_OUT_OF_BOUND; + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; +} + + /** Cтолбeц значений типа "строка". */ class ColumnString final : public IColumn diff --git a/dbms/include/DB/Columns/ColumnTuple.h b/dbms/include/DB/Columns/ColumnTuple.h index c35a9c61cb5..5ecad4c342a 100644 --- a/dbms/include/DB/Columns/ColumnTuple.h +++ b/dbms/include/DB/Columns/ColumnTuple.h @@ -8,6 +8,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NOT_IMPLEMENTED; + extern const int CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE; +} + /** Столбец, который всего лишь группирует вместе несколько других столбцов. */ diff --git a/dbms/include/DB/Columns/ColumnVector.h b/dbms/include/DB/Columns/ColumnVector.h index 97983f5517a..9b81aac4451 100644 --- a/dbms/include/DB/Columns/ColumnVector.h +++ b/dbms/include/DB/Columns/ColumnVector.h @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -15,6 +14,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int PARAMETER_OUT_OF_BOUND; + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; +} + /** Штука для сравнения чисел. * Целые числа сравниваются как обычно. diff --git a/dbms/include/DB/Columns/IColumn.h b/dbms/include/DB/Columns/IColumn.h index b64caf4d8f1..ce6a7379cc3 100644 --- a/dbms/include/DB/Columns/IColumn.h +++ b/dbms/include/DB/Columns/IColumn.h @@ -7,13 +7,18 @@ #include #include -#include #include namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_GET_SIZE_OF_FIELD; + extern const int NOT_IMPLEMENTED; +} + using Poco::SharedPtr; class IColumn; diff --git a/dbms/include/DB/Common/AIO.h b/dbms/include/DB/Common/AIO.h index 5512ac053cf..77344179763 100644 --- a/dbms/include/DB/Common/AIO.h +++ b/dbms/include/DB/Common/AIO.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -59,9 +58,16 @@ struct AIOContext : private boost::noncopyable } }; + namespace DB { +namespace ErrorCodes +{ + extern const int AIO_COMPLETION_ERROR; + extern const int AIO_SUBMIT_ERROR; +} + class AIOContextPool : public Singleton { diff --git a/dbms/include/DB/Common/Allocator.h b/dbms/include/DB/Common/Allocator.h index 3185e5ecd6e..4f977c0816b 100644 --- a/dbms/include/DB/Common/Allocator.h +++ b/dbms/include/DB/Common/Allocator.h @@ -6,7 +6,18 @@ #include #include -#include + + +namespace DB +{ +namespace ErrorCodes +{ + extern const int BAD_ARGUMENTS; + extern const int CANNOT_ALLOCATE_MEMORY; + extern const int CANNOT_MUNMAP; + extern const int CANNOT_MREMAP; +} +} /** При использовании AllocatorWithStackMemory, размещённом на стеке, diff --git a/dbms/include/DB/Common/Collator.h b/dbms/include/DB/Common/Collator.h index c4fd0b3f788..6d5d405b5fc 100644 --- a/dbms/include/DB/Common/Collator.h +++ b/dbms/include/DB/Common/Collator.h @@ -2,7 +2,6 @@ #include -#include #include #include @@ -12,6 +11,17 @@ #include + +namespace DB +{ + namespace ErrorCodes + { + extern const int UNSUPPORTED_COLLATION_LOCALE; + extern const int COLLATION_COMPARISON_FAILED; + } +} + + class Collator : private boost::noncopyable { public: @@ -61,4 +71,4 @@ public: private: std::string locale; UCollator * collator; -}; \ No newline at end of file +}; diff --git a/dbms/include/DB/Common/CompactArray.h b/dbms/include/DB/Common/CompactArray.h index fb7ecb5bf28..d5fb1bf9de4 100644 --- a/dbms/include/DB/Common/CompactArray.h +++ b/dbms/include/DB/Common/CompactArray.h @@ -5,11 +5,16 @@ #include #include #include -#include namespace DB { +namespace ErrorCodes +{ + extern const int NO_AVAILABLE_DATA; +} + + /** Компактный массив для хранения данных, размер content_width, в битах, которых составляет * меньше одного байта. Вместо того, чтобы хранить каждое значение в отдельный * байт, что приводит к растрате 37.5% пространства для content_width=5, CompactArray хранит diff --git a/dbms/include/DB/Common/HashTable/HashTable.h b/dbms/include/DB/Common/HashTable/HashTable.h index da591b9ce2b..8b3128b4ae0 100644 --- a/dbms/include/DB/Common/HashTable/HashTable.h +++ b/dbms/include/DB/Common/HashTable/HashTable.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -31,6 +30,16 @@ #endif +namespace DB +{ +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int NO_AVAILABLE_DATA; +} +} + + /** Состояние хэш-таблицы, которое влияет на свойства её ячеек. * Используется в качестве параметра шаблона. * Например, существует реализация мгновенно-очищаемой хэш-таблицы - ClearableHashMap. diff --git a/dbms/include/DB/Common/HyperLogLogBiasEstimator.h b/dbms/include/DB/Common/HyperLogLogBiasEstimator.h index c19a1a8c350..23b03a1bd5d 100644 --- a/dbms/include/DB/Common/HyperLogLogBiasEstimator.h +++ b/dbms/include/DB/Common/HyperLogLogBiasEstimator.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/dbms/include/DB/Common/HyperLogLogCounter.h b/dbms/include/DB/Common/HyperLogLogCounter.h index a837cbcad4f..7935527335e 100644 --- a/dbms/include/DB/Common/HyperLogLogCounter.h +++ b/dbms/include/DB/Common/HyperLogLogCounter.h @@ -10,11 +10,20 @@ #include #include #include -#include #include #include + +namespace DB +{ +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} +} + + namespace details { diff --git a/dbms/include/DB/Common/LRUCache.h b/dbms/include/DB/Common/LRUCache.h index de00ea816a4..6b3e02cdaa5 100644 --- a/dbms/include/DB/Common/LRUCache.h +++ b/dbms/include/DB/Common/LRUCache.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/dbms/include/DB/Common/PODArray.h b/dbms/include/DB/Common/PODArray.h index 21c9fa7c38a..655db8e07a2 100644 --- a/dbms/include/DB/Common/PODArray.h +++ b/dbms/include/DB/Common/PODArray.h @@ -13,7 +13,6 @@ #include #include -#include namespace DB diff --git a/dbms/include/DB/Common/PoolWithFailoverBase.h b/dbms/include/DB/Common/PoolWithFailoverBase.h index c856f2853fc..02104cd1050 100644 --- a/dbms/include/DB/Common/PoolWithFailoverBase.h +++ b/dbms/include/DB/Common/PoolWithFailoverBase.h @@ -5,10 +5,19 @@ #include #include #include -#include #include +namespace DB +{ +namespace ErrorCodes +{ + extern const int ALL_CONNECTION_TRIES_FAILED; + extern const int CANNOT_CLOCK_GETTIME; +} +} + + namespace { /** Класс, который употребляется для того, чтобы оптимизировать выделение diff --git a/dbms/include/DB/Common/RadixSort.h b/dbms/include/DB/Common/RadixSort.h index fc151e17b81..12401b10194 100644 --- a/dbms/include/DB/Common/RadixSort.h +++ b/dbms/include/DB/Common/RadixSort.h @@ -40,6 +40,7 @@ struct RadixSortMallocAllocator * что отношение порядка над ключами будет соответствовать отношению порядка над полученными беззнаковыми числами. * Для float-ов это преобразование делает следующее: * если выставлен знаковый бит, то переворачивает все остальные биты. + * При этом, NaN-ы оказываются больше всех нормальных чисел. */ template struct RadixSortFloatTransform diff --git a/dbms/include/DB/Common/SmallObjectPool.h b/dbms/include/DB/Common/SmallObjectPool.h index 7948ae42626..5b0fe4b055f 100644 --- a/dbms/include/DB/Common/SmallObjectPool.h +++ b/dbms/include/DB/Common/SmallObjectPool.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/dbms/include/DB/Common/Throttler.h b/dbms/include/DB/Common/Throttler.h index 63bb51280a3..fec62e41889 100644 --- a/dbms/include/DB/Common/Throttler.h +++ b/dbms/include/DB/Common/Throttler.h @@ -10,6 +10,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LIMIT_EXCEEDED; +} + + /** Позволяет ограничить скорость чего либо (в штуках в секунду) с помощью sleep. * Особенности работы: * - считается только средняя скорость, от момента первого вызова функции add; diff --git a/dbms/include/DB/Core/Block.h b/dbms/include/DB/Core/Block.h index 54e4e3a9de1..239b19bd8c4 100644 --- a/dbms/include/DB/Core/Block.h +++ b/dbms/include/DB/Core/Block.h @@ -9,7 +9,6 @@ #include #include #include -#include #include "ColumnsWithTypeAndName.h" diff --git a/dbms/include/DB/Core/BlockInfo.h b/dbms/include/DB/Core/BlockInfo.h index 49d7be5c579..026861d3a4c 100644 --- a/dbms/include/DB/Core/BlockInfo.h +++ b/dbms/include/DB/Core/BlockInfo.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -13,6 +12,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_BLOCK_INFO_FIELD; +} + /** Дополнительная информация о блоке. */ struct BlockInfo diff --git a/dbms/include/DB/Core/ErrorCodes.h b/dbms/include/DB/Core/ErrorCodes.h deleted file mode 100644 index 34e25e7968c..00000000000 --- a/dbms/include/DB/Core/ErrorCodes.h +++ /dev/null @@ -1,318 +0,0 @@ -#pragma once - - -namespace DB -{ - -namespace ErrorCodes -{ - enum ErrorCodes - { - UNSUPPORTED_METHOD = 1, - UNSUPPORTED_PARAMETER = 2, - UNEXPECTED_END_OF_FILE = 3, - EXPECTED_END_OF_FILE = 4, - CANNOT_PARSE_TEXT = 6, - INCORRECT_NUMBER_OF_COLUMNS = 7, - THERE_IS_NO_COLUMN = 8, - SIZES_OF_COLUMNS_DOESNT_MATCH = 9, - NOT_FOUND_COLUMN_IN_BLOCK = 10, - POSITION_OUT_OF_BOUND = 11, - PARAMETER_OUT_OF_BOUND = 12, - SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH = 13, - DUPLICATE_COLUMN = 15, - NO_SUCH_COLUMN_IN_TABLE = 16, - DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH = 17, - CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN = 18, - SIZE_OF_ARRAY_DOESNT_MATCH_SIZE_OF_FIXEDARRAY_COLUMN = 19, - NUMBER_OF_COLUMNS_DOESNT_MATCH = 20, - CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT = 21, - CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT = 22, - CANNOT_READ_FROM_ISTREAM = 23, - CANNOT_WRITE_TO_OSTREAM = 24, - CANNOT_PARSE_ESCAPE_SEQUENCE = 25, - CANNOT_PARSE_QUOTED_STRING = 26, - CANNOT_PARSE_INPUT_ASSERTION_FAILED = 27, - CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER = 28, - CANNOT_PRINT_INTEGER = 29, - CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK = 30, - CANNOT_READ_COMPRESSED_CHUNK = 31, - ATTEMPT_TO_READ_AFTER_EOF = 32, - CANNOT_READ_ALL_DATA = 33, - TOO_MUCH_ARGUMENTS_FOR_FUNCTION = 34, - TOO_LESS_ARGUMENTS_FOR_FUNCTION = 35, - BAD_ARGUMENTS = 36, - UNKNOWN_ELEMENT_IN_AST = 37, - CANNOT_PARSE_DATE = 38, - TOO_LARGE_SIZE_COMPRESSED = 39, - CHECKSUM_DOESNT_MATCH = 40, - CANNOT_PARSE_DATETIME = 41, - NUMBER_OF_ARGUMENTS_DOESNT_MATCH = 42, - ILLEGAL_TYPE_OF_ARGUMENT = 43, - ILLEGAL_COLUMN = 44, - ILLEGAL_NUMBER_OF_RESULT_COLUMNS = 45, - UNKNOWN_FUNCTION = 46, - UNKNOWN_IDENTIFIER = 47, - NOT_IMPLEMENTED = 48, - LOGICAL_ERROR = 49, - UNKNOWN_TYPE = 50, - EMPTY_LIST_OF_COLUMNS_QUERIED = 51, - COLUMN_QUERIED_MORE_THAN_ONCE = 52, - TYPE_MISMATCH = 53, - STORAGE_DOESNT_ALLOW_PARAMETERS = 54, - STORAGE_REQUIRES_PARAMETER = 55, - UNKNOWN_STORAGE = 56, - TABLE_ALREADY_EXISTS = 57, - TABLE_METADATA_ALREADY_EXISTS = 58, - ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER = 59, - UNKNOWN_TABLE = 60, - ONLY_FILTER_COLUMN_IN_BLOCK = 61, - SYNTAX_ERROR = 62, - UNKNOWN_AGGREGATE_FUNCTION = 63, - CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT = 64, - CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT = 65, - NOT_A_COLUMN = 66, - ILLEGAL_KEY_OF_AGGREGATION = 67, - CANNOT_GET_SIZE_OF_FIELD = 68, - ARGUMENT_OUT_OF_BOUND = 69, - CANNOT_CONVERT_TYPE = 70, - CANNOT_WRITE_AFTER_END_OF_BUFFER = 71, - CANNOT_PARSE_NUMBER = 72, - UNKNOWN_FORMAT = 73, - CANNOT_READ_FROM_FILE_DESCRIPTOR = 74, - CANNOT_WRITE_TO_FILE_DESCRIPTOR = 75, - CANNOT_OPEN_FILE = 76, - CANNOT_CLOSE_FILE = 77, - UNKNOWN_TYPE_OF_QUERY = 78, - INCORRECT_FILE_NAME = 79, - INCORRECT_QUERY = 80, - UNKNOWN_DATABASE = 81, - DATABASE_ALREADY_EXISTS = 82, - DIRECTORY_DOESNT_EXIST = 83, - DIRECTORY_ALREADY_EXISTS = 84, - FORMAT_IS_NOT_SUITABLE_FOR_INPUT = 85, - RECEIVED_ERROR_FROM_REMOTE_IO_SERVER = 86, - CANNOT_SEEK_THROUGH_FILE = 87, - CANNOT_TRUNCATE_FILE = 88, - UNKNOWN_COMPRESSION_METHOD = 89, - EMPTY_LIST_OF_COLUMNS_PASSED = 90, - SIZES_OF_MARKS_FILES_ARE_INCONSISTENT = 91, - EMPTY_DATA_PASSED = 92, - UNKNOWN_AGGREGATED_DATA_VARIANT = 93, - CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS = 94, - CANNOT_READ_FROM_SOCKET = 95, - CANNOT_WRITE_TO_SOCKET = 96, - CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT = 97, - CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM = 98, - UNKNOWN_PACKET_FROM_CLIENT = 99, - UNKNOWN_PACKET_FROM_SERVER = 100, - UNEXPECTED_PACKET_FROM_CLIENT = 101, - UNEXPECTED_PACKET_FROM_SERVER = 102, - RECEIVED_DATA_FOR_WRONG_QUERY_ID = 103, - TOO_SMALL_BUFFER_SIZE = 104, - CANNOT_READ_HISTORY = 105, - CANNOT_APPEND_HISTORY = 106, - FILE_DOESNT_EXIST = 107, - NO_DATA_TO_INSERT = 108, - CANNOT_BLOCK_SIGNAL = 109, - CANNOT_UNBLOCK_SIGNAL = 110, - CANNOT_MANIPULATE_SIGSET = 111, - CANNOT_WAIT_FOR_SIGNAL = 112, - THERE_IS_NO_SESSION = 113, - CANNOT_CLOCK_GETTIME = 114, - UNKNOWN_SETTING = 115, - THERE_IS_NO_DEFAULT_VALUE = 116, - INCORRECT_DATA = 117, - TABLE_METADATA_DOESNT_EXIST = 118, - ENGINE_REQUIRED = 119, - CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE = 120, - UNKNOWN_SET_DATA_VARIANT = 121, - INCOMPATIBLE_COLUMNS = 122, - UNKNOWN_TYPE_OF_AST_NODE = 123, - INCORRECT_ELEMENT_OF_SET = 124, - INCORRECT_RESULT_OF_SCALAR_SUBQUERY = 125, - CANNOT_GET_RETURN_TYPE = 126, - ILLEGAL_INDEX = 127, - TOO_LARGE_ARRAY_SIZE = 128, - FUNCTION_IS_SPECIAL = 129, - CANNOT_READ_ARRAY_FROM_TEXT = 130, - TOO_LARGE_STRING_SIZE = 131, - CANNOT_CREATE_TABLE_FROM_METADATA = 132, - AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS = 133, - PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS = 134, - ZERO_ARRAY_OR_TUPLE_INDEX = 135, - UNKNOWN_ELEMENT_IN_CONFIG = 137, - EXCESSIVE_ELEMENT_IN_CONFIG = 138, - NO_ELEMENTS_IN_CONFIG = 139, - ALL_REQUESTED_COLUMNS_ARE_MISSING = 140, - SAMPLING_NOT_SUPPORTED = 141, - NOT_FOUND_NODE = 142, - FOUND_MORE_THAN_ONE_NODE = 143, - FIRST_DATE_IS_BIGGER_THAN_LAST_DATE = 144, - UNKNOWN_OVERFLOW_MODE = 145, - QUERY_SECTION_DOESNT_MAKE_SENSE = 146, - NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE = 147, - NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION = 148, - NOT_FOUND_RHS_ELEMENT_FOR_CONDITION = 149, - NO_ATTRIBUTES_LISTED = 150, - INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE = 151, - UNKNOWN_DIRECTION_OF_SORTING = 152, - ILLEGAL_DIVISION = 153, - AGGREGATE_FUNCTION_NOT_APPLICABLE = 154, - UNKNOWN_RELATION = 155, - DICTIONARIES_WAS_NOT_LOADED = 156, - ILLEGAL_OVERFLOW_MODE = 157, - TOO_MUCH_ROWS = 158, - TIMEOUT_EXCEEDED = 159, - TOO_SLOW = 160, - TOO_MUCH_COLUMNS = 161, - TOO_DEEP_SUBQUERIES = 162, - TOO_DEEP_PIPELINE = 163, - READONLY = 164, - TOO_MUCH_TEMPORARY_COLUMNS = 165, - TOO_MUCH_TEMPORARY_NON_CONST_COLUMNS = 166, - TOO_DEEP_AST = 167, - TOO_BIG_AST = 168, - BAD_TYPE_OF_FIELD = 169, - BAD_GET = 170, - BLOCKS_HAS_DIFFERENT_STRUCTURE = 171, - CANNOT_CREATE_DIRECTORY = 172, - CANNOT_ALLOCATE_MEMORY = 173, - CYCLIC_ALIASES = 174, - CHUNK_NOT_FOUND = 176, - DUPLICATE_CHUNK_NAME = 177, - MULTIPLE_ALIASES_FOR_EXPRESSION = 178, - MULTIPLE_EXPRESSIONS_FOR_ALIAS = 179, - THERE_IS_NO_PROFILE = 180, - ILLEGAL_FINAL = 181, - ILLEGAL_PREWHERE = 182, - UNEXPECTED_EXPRESSION = 183, - ILLEGAL_AGGREGATION = 184, - UNSUPPORTED_MYISAM_BLOCK_TYPE = 185, - UNSUPPORTED_COLLATION_LOCALE = 186, - COLLATION_COMPARISON_FAILED = 187, - UNKNOWN_ACTION = 188, - TABLE_MUST_NOT_BE_CREATED_MANUALLY = 189, - SIZES_OF_ARRAYS_DOESNT_MATCH = 190, - SET_SIZE_LIMIT_EXCEEDED = 191, - UNKNOWN_USER = 192, - WRONG_PASSWORD = 193, - REQUIRED_PASSWORD = 194, - IP_ADDRESS_NOT_ALLOWED = 195, - UNKNOWN_ADDRESS_PATTERN_TYPE = 196, - SERVER_REVISION_IS_TOO_OLD = 197, - DNS_ERROR = 198, - UNKNOWN_QUOTA = 199, - QUOTA_DOESNT_ALLOW_KEYS = 200, - QUOTA_EXPIRED = 201, - TOO_MUCH_SIMULTANEOUS_QUERIES = 202, - NO_FREE_CONNECTION = 203, - CANNOT_FSYNC = 204, - NESTED_TYPE_TOO_DEEP = 205, - ALIAS_REQUIRED = 206, - AMBIGUOUS_IDENTIFIER = 207, - EMPTY_NESTED_TABLE = 208, - SOCKET_TIMEOUT = 209, - NETWORK_ERROR = 210, - EMPTY_QUERY = 211, - UNKNOWN_LOAD_BALANCING = 212, - UNKNOWN_TOTALS_MODE = 213, - CANNOT_STATVFS = 214, - NOT_AN_AGGREGATE = 215, - QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING = 216, - CLIENT_HAS_CONNECTED_TO_WRONG_PORT = 217, - TABLE_IS_DROPPED = 218, - DATABASE_NOT_EMPTY = 219, - DUPLICATE_INTERSERVER_IO_ENDPOINT = 220, - NO_SUCH_INTERSERVER_IO_ENDPOINT = 221, - ADDING_REPLICA_TO_NON_EMPTY_TABLE = 222, - UNEXPECTED_AST_STRUCTURE = 223, - REPLICA_IS_ALREADY_ACTIVE = 224, - NO_ZOOKEEPER = 225, - NO_FILE_IN_DATA_PART = 226, - UNEXPECTED_FILE_IN_DATA_PART = 227, - BAD_SIZE_OF_FILE_IN_DATA_PART = 228, - QUERY_IS_TOO_LARGE = 229, - NOT_FOUND_EXPECTED_DATA_PART = 230, - TOO_MANY_UNEXPECTED_DATA_PARTS = 231, - NO_SUCH_DATA_PART = 232, - BAD_DATA_PART_NAME = 233, - NO_REPLICA_HAS_PART = 234, - DUPLICATE_DATA_PART = 235, - ABORTED = 236, - NO_REPLICA_NAME_GIVEN = 237, - FORMAT_VERSION_TOO_OLD = 238, - CANNOT_MUNMAP = 239, - CANNOT_MREMAP = 240, - MEMORY_LIMIT_EXCEEDED = 241, - TABLE_IS_READ_ONLY = 242, - NOT_ENOUGH_SPACE = 243, - UNEXPECTED_ZOOKEEPER_ERROR = 244, - INVALID_NESTED_NAME = 245, - CORRUPTED_DATA = 246, - INCORRECT_MARK = 247, - INVALID_PARTITION_NAME = 248, - NOT_ENOUGH_BLOCK_NUMBERS = 250, - NO_SUCH_REPLICA = 251, - TOO_MUCH_PARTS = 252, - REPLICA_IS_ALREADY_EXIST = 253, - NO_ACTIVE_REPLICAS = 254, - TOO_MUCH_RETRIES_TO_FETCH_PARTS = 255, - PARTITION_ALREADY_EXISTS = 256, - PARTITION_DOESNT_EXIST = 257, - UNION_ALL_RESULT_STRUCTURES_MISMATCH = 258, - UNION_ALL_COLUMN_ALIAS_MISMATCH = 259, - CLIENT_OUTPUT_FORMAT_SPECIFIED = 260, - UNKNOWN_BLOCK_INFO_FIELD = 261, - BAD_COLLATION = 262, - CANNOT_COMPILE_CODE = 263, - INCOMPATIBLE_TYPE_OF_JOIN = 264, - NO_AVAILABLE_REPLICA = 265, - MISMATCH_REPLICAS_DATA_SOURCES = 266, - STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS = 267, - CPUID_ERROR = 268, - INFINITE_LOOP = 269, - CANNOT_COMPRESS = 270, - CANNOT_DECOMPRESS = 271, - AIO_SUBMIT_ERROR = 272, - AIO_COMPLETION_ERROR = 273, - AIO_READ_ERROR = 274, - AIO_WRITE_ERROR = 275, - INDEX_NOT_USED = 277, - LEADERSHIP_LOST = 278, - ALL_CONNECTION_TRIES_FAILED = 279, - NO_AVAILABLE_DATA = 280, - DICTIONARY_IS_EMPTY = 281, - INCORRECT_INDEX = 282, - UNKNOWN_DISTRIBUTED_PRODUCT_MODE = 283, - UNKNOWN_GLOBAL_SUBQUERIES_METHOD = 284, - TOO_LESS_LIVE_REPLICAS = 285, - UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE = 286, - UNKNOWN_FORMAT_VERSION = 287, - DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED = 288, - REPLICA_IS_NOT_IN_QUORUM = 289, - LIMIT_EXCEEDED = 290, - DATABASE_ACCESS_DENIED = 291, - LEADERSHIP_CHANGED = 292, - MONGODB_INIT_FAILED = 293, - INVALID_BLOCK_EXTRA_INFO = 294, - RECEIVED_EMPTY_DATA = 295, - NO_REMOTE_SHARD_FOUND = 296, - SHARD_HAS_NO_CONNECTIONS = 297, - CANNOT_PIPE = 298, - CANNOT_FORK = 299, - CANNOT_DLSYM = 300, - CANNOT_CREATE_CHILD_PROCESS = 301, - CHILD_WAS_NOT_EXITED_NORMALLY = 302, - CANNOT_SELECT = 303, - CANNOT_WAITPID = 304, - TABLE_WAS_NOT_DROPPED = 305, - - KEEPER_EXCEPTION = 999, - POCO_EXCEPTION = 1000, - STD_EXCEPTION = 1001, - UNKNOWN_EXCEPTION = 1002, - }; -} - -} diff --git a/dbms/include/DB/Core/Field.h b/dbms/include/DB/Core/Field.h index cd76d03bf9a..735ef128666 100644 --- a/dbms/include/DB/Core/Field.h +++ b/dbms/include/DB/Core/Field.h @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -15,6 +14,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int BAD_TYPE_OF_FIELD; + extern const int BAD_GET; + extern const int NOT_IMPLEMENTED; +} + class Field; using Array = std::vector; /// Значение типа "массив" using TupleBackend = std::vector; diff --git a/dbms/include/DB/Core/FieldVisitors.h b/dbms/include/DB/Core/FieldVisitors.h index 2711264cfd7..6fd57fcb4ba 100644 --- a/dbms/include/DB/Core/FieldVisitors.h +++ b/dbms/include/DB/Core/FieldVisitors.h @@ -13,6 +13,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_CONVERT_TYPE; +} + /** StaticVisitor (его наследники) - класс с перегруженными для разных типов операторами (). * Вызвать visitor для field можно с помощью функции apply_visitor. diff --git a/dbms/include/DB/DataStreams/MergingSortedBlockInputStream.h b/dbms/include/DB/DataStreams/MergingSortedBlockInputStream.h index 2cfda8c2a06..51fa2bd4aa8 100644 --- a/dbms/include/DB/DataStreams/MergingSortedBlockInputStream.h +++ b/dbms/include/DB/DataStreams/MergingSortedBlockInputStream.h @@ -13,6 +13,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CORRUPTED_DATA; +} + + /** Соединяет несколько сортированных потоков в один. */ class MergingSortedBlockInputStream : public IProfilingBlockInputStream diff --git a/dbms/include/DB/DataStreams/ProhibitColumnsBlockOutputStream.h b/dbms/include/DB/DataStreams/ProhibitColumnsBlockOutputStream.h index 71a6a495e8e..ebd2040e7bd 100644 --- a/dbms/include/DB/DataStreams/ProhibitColumnsBlockOutputStream.h +++ b/dbms/include/DB/DataStreams/ProhibitColumnsBlockOutputStream.h @@ -6,6 +6,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_COLUMN; +} + /// Throws exception on encountering prohibited column in block class ProhibitColumnsBlockOutputStream : public IBlockOutputStream diff --git a/dbms/include/DB/DataStreams/RemoteBlockOutputStream.h b/dbms/include/DB/DataStreams/RemoteBlockOutputStream.h index 0dd5fbd3777..896c7ab1922 100644 --- a/dbms/include/DB/DataStreams/RemoteBlockOutputStream.h +++ b/dbms/include/DB/DataStreams/RemoteBlockOutputStream.h @@ -10,6 +10,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNEXPECTED_PACKET_FROM_SERVER; + extern const int LOGICAL_ERROR; +} + + /** Позволяет выполнить запрос INSERT на удалённом сервере и отправить данные. */ class RemoteBlockOutputStream : public IBlockOutputStream diff --git a/dbms/include/DB/DataStreams/SummingSortedBlockInputStream.h b/dbms/include/DB/DataStreams/SummingSortedBlockInputStream.h index 8b8c90f8f53..9f7d84b18e8 100644 --- a/dbms/include/DB/DataStreams/SummingSortedBlockInputStream.h +++ b/dbms/include/DB/DataStreams/SummingSortedBlockInputStream.h @@ -14,6 +14,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + + /** Соединяет несколько сортированных потоков в один. * При этом, для каждой группы идущих подряд одинаковых значений первичного ключа (столбцов, по которым сортируются данные), * схлопывает их в одну строку, суммируя все числовые столбцы кроме первичного ключа. @@ -33,22 +39,7 @@ public: String getName() const override { return "SummingSorted"; } - String getID() const override - { - std::stringstream res; - res << "SummingSorted(inputs"; - - for (size_t i = 0; i < children.size(); ++i) - res << ", " << children[i]->getID(); - - res << ", description"; - - for (size_t i = 0; i < description.size(); ++i) - res << ", " << description[i].getID(); - - res << ")"; - return res.str(); - } + String getID() const override; protected: /// Может возвращаться на 1 больше записей, чем max_block_size. @@ -105,26 +96,6 @@ private: /// Вставить в результат просуммированную строку для текущей группы. void insertCurrentRow(ColumnPlainPtrs & merged_columns); - - /** Реализует операцию +=. - * Возвращает false, если результат получился нулевым. - */ - class FieldVisitorSum : public StaticVisitor - { - private: - const Field & rhs; - public: - FieldVisitorSum(const Field & rhs_) : rhs(rhs_) {} - - bool operator() (UInt64 & x) const { x += get(rhs); return x != 0; } - bool operator() (Int64 & x) const { x += get(rhs); return x != 0; } - bool operator() (Float64 & x) const { x += get(rhs); return x != 0; } - - bool operator() (Null & x) const { throw Exception("Cannot sum Nulls", ErrorCodes::LOGICAL_ERROR); } - bool operator() (String & x) const { throw Exception("Cannot sum Strings", ErrorCodes::LOGICAL_ERROR); } - bool operator() (Array & x) const { throw Exception("Cannot sum Arrays", ErrorCodes::LOGICAL_ERROR); } - }; - /** Для вложенных Map выполняется слияние по ключу с выбрасыванием строк вложенных массивов, в которых * все элементы - нулевые. */ diff --git a/dbms/include/DB/DataTypes/DataTypeAggregateFunction.h b/dbms/include/DB/DataTypes/DataTypeAggregateFunction.h index 2a0cf70d57d..b5db5242949 100644 --- a/dbms/include/DB/DataTypes/DataTypeAggregateFunction.h +++ b/dbms/include/DB/DataTypes/DataTypeAggregateFunction.h @@ -10,6 +10,13 @@ namespace DB using Poco::SharedPtr; +namespace ErrorCodes +{ + extern const int THERE_IS_NO_DEFAULT_VALUE; + extern const int NOT_IMPLEMENTED; +} + + /** Тип - состояние агрегатной функции. * Параметры типа - это агрегатная функция, типы её аргументов и её параметры (для параметрических агрегатных функций). */ diff --git a/dbms/include/DB/DataTypes/DataTypeEnum.h b/dbms/include/DB/DataTypes/DataTypeEnum.h index 0474809881a..75d562d8541 100644 --- a/dbms/include/DB/DataTypes/DataTypeEnum.h +++ b/dbms/include/DB/DataTypes/DataTypeEnum.h @@ -9,6 +9,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int SYNTAX_ERROR; + extern const int LOGICAL_ERROR; + extern const int EMPTY_DATA_PASSED; +} + template struct EnumName; template <> struct EnumName { static constexpr auto value = "Enum8"; }; diff --git a/dbms/include/DB/DataTypes/DataTypeFixedString.h b/dbms/include/DB/DataTypes/DataTypeFixedString.h index a5affe409aa..03e25d02adf 100644 --- a/dbms/include/DB/DataTypes/DataTypeFixedString.h +++ b/dbms/include/DB/DataTypes/DataTypeFixedString.h @@ -12,6 +12,11 @@ namespace DB using Poco::SharedPtr; +namespace ErrorCodes +{ + extern const int ARGUMENT_OUT_OF_BOUND; +} + class DataTypeFixedString final : public IDataType { diff --git a/dbms/include/DB/DataTypes/FieldToDataType.h b/dbms/include/DB/DataTypes/FieldToDataType.h index 6ba0743888b..ac1eadec8a4 100644 --- a/dbms/include/DB/DataTypes/FieldToDataType.h +++ b/dbms/include/DB/DataTypes/FieldToDataType.h @@ -7,12 +7,17 @@ #include #include -#include namespace DB { +namespace ErrorCodes +{ + extern const int NOT_IMPLEMENTED; +} + + /** Для заданного значения Field возвращает минимальный тип данных, позволяющий хранить значение этого типа. * В случае, если Field - массив, конвертирует все элементы к общему типу. */ diff --git a/dbms/include/DB/Dictionaries/DictionaryStructure.h b/dbms/include/DB/Dictionaries/DictionaryStructure.h index 9df9383e723..1e0471a2500 100644 --- a/dbms/include/DB/Dictionaries/DictionaryStructure.h +++ b/dbms/include/DB/Dictionaries/DictionaryStructure.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -16,6 +15,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_TYPE; + extern const int ARGUMENT_OUT_OF_BOUND; +} + + enum class AttributeUnderlyingType { UInt8, diff --git a/dbms/include/DB/Functions/FunctionsArray.h b/dbms/include/DB/Functions/FunctionsArray.h index 9f6a5b00fa9..1c524ba8612 100644 --- a/dbms/include/DB/Functions/FunctionsArray.h +++ b/dbms/include/DB/Functions/FunctionsArray.h @@ -33,6 +33,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ZERO_ARRAY_OR_TUPLE_INDEX; + extern const int SIZES_OF_ARRAYS_DOESNT_MATCH; + extern const int PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS; +} + + /** Функции по работе с массивами: * * array(с1, с2, ...) - создать массив из констант. diff --git a/dbms/include/DB/Functions/FunctionsMiscellaneous.h b/dbms/include/DB/Functions/FunctionsMiscellaneous.h index 0f067f8c75b..07555951654 100644 --- a/dbms/include/DB/Functions/FunctionsMiscellaneous.h +++ b/dbms/include/DB/Functions/FunctionsMiscellaneous.h @@ -32,6 +32,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; + extern const int ILLEGAL_INDEX; + extern const int FUNCTION_IS_SPECIAL; +} + /** Вспомогательные функции: * * visibleWidth(x) - вычисляет приблизительную ширину при выводе значения в текстовом (tab-separated) виде на консоль. diff --git a/dbms/include/DB/Functions/IFunction.h b/dbms/include/DB/Functions/IFunction.h index 8e7b1362dbc..4ddf982ccbe 100644 --- a/dbms/include/DB/Functions/IFunction.h +++ b/dbms/include/DB/Functions/IFunction.h @@ -12,6 +12,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_ARGUMENT; + extern const int ILLEGAL_COLUMN; + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; +} + class ExpressionAction; diff --git a/dbms/include/DB/IO/BufferWithOwnMemory.h b/dbms/include/DB/IO/BufferWithOwnMemory.h index aecae974795..edb5a89a0ac 100644 --- a/dbms/include/DB/IO/BufferWithOwnMemory.h +++ b/dbms/include/DB/IO/BufferWithOwnMemory.h @@ -6,7 +6,6 @@ #include #include -#include #include diff --git a/dbms/include/DB/IO/CompressedReadBufferBase.h b/dbms/include/DB/IO/CompressedReadBufferBase.h index 41b2315a681..bc801e52316 100644 --- a/dbms/include/DB/IO/CompressedReadBufferBase.h +++ b/dbms/include/DB/IO/CompressedReadBufferBase.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,15 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_COMPRESSION_METHOD; + extern const int TOO_LARGE_SIZE_COMPRESSED; + extern const int CHECKSUM_DOESNT_MATCH; + extern const int CANNOT_DECOMPRESS; +} + + class CompressedReadBufferBase { protected: diff --git a/dbms/include/DB/IO/CompressedReadBufferFromFile.h b/dbms/include/DB/IO/CompressedReadBufferFromFile.h index 6bfd6fb6a37..05bf95803d4 100644 --- a/dbms/include/DB/IO/CompressedReadBufferFromFile.h +++ b/dbms/include/DB/IO/CompressedReadBufferFromFile.h @@ -10,6 +10,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ARGUMENT_OUT_OF_BOUND; +} + + /// В отличие от CompressedReadBuffer, умеет делать seek. class CompressedReadBufferFromFile : public CompressedReadBufferBase, public BufferWithOwnMemory { diff --git a/dbms/include/DB/IO/CompressedWriteBuffer.h b/dbms/include/DB/IO/CompressedWriteBuffer.h index 3065defd1aa..7ec34fad10f 100644 --- a/dbms/include/DB/IO/CompressedWriteBuffer.h +++ b/dbms/include/DB/IO/CompressedWriteBuffer.h @@ -21,6 +21,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_COMPRESS; + extern const int UNKNOWN_COMPRESSION_METHOD; +} + + class CompressedWriteBuffer : public BufferWithOwnMemory { private: diff --git a/dbms/include/DB/IO/ReadBuffer.h b/dbms/include/DB/IO/ReadBuffer.h index c753d1c1b44..7a91f08abbe 100644 --- a/dbms/include/DB/IO/ReadBuffer.h +++ b/dbms/include/DB/IO/ReadBuffer.h @@ -4,13 +4,18 @@ #include #include -#include #include namespace DB { +namespace ErrorCodes +{ + extern const int ATTEMPT_TO_READ_AFTER_EOF; + extern const int CANNOT_READ_ALL_DATA; +} + /** Простой абстрактный класс для буферизованного чтения данных (последовательности char) откуда-нибудь. * В отличие от std::istream, предоставляет доступ к внутреннему буферу, * а также позволяет вручную управлять позицией внутри буфера. diff --git a/dbms/include/DB/IO/ReadBufferFromFile.h b/dbms/include/DB/IO/ReadBufferFromFile.h index 6fcedd4334d..e3337df6af0 100644 --- a/dbms/include/DB/IO/ReadBufferFromFile.h +++ b/dbms/include/DB/IO/ReadBufferFromFile.h @@ -8,6 +8,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int FILE_DOESNT_EXIST; + extern const int CANNOT_OPEN_FILE; + extern const int CANNOT_CLOSE_FILE; +} + + /** Принимает имя файла. Самостоятельно открывает и закрывает файл. */ class ReadBufferFromFile : public ReadBufferFromFileDescriptor diff --git a/dbms/include/DB/IO/ReadBufferFromFileDescriptor.h b/dbms/include/DB/IO/ReadBufferFromFileDescriptor.h index c907ab7c21a..2ec8e97ab8b 100644 --- a/dbms/include/DB/IO/ReadBufferFromFileDescriptor.h +++ b/dbms/include/DB/IO/ReadBufferFromFileDescriptor.h @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -21,6 +20,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_READ_FROM_FILE_DESCRIPTOR; + extern const int ARGUMENT_OUT_OF_BOUND; + extern const int CANNOT_SEEK_THROUGH_FILE; + extern const int CANNOT_SELECT; +} + /** Работает с готовым файловым дескриптором. Не открывает и не закрывает файл. */ class ReadBufferFromFileDescriptor : public ReadBufferFromFileBase diff --git a/dbms/include/DB/IO/ReadBufferFromHTTP.h b/dbms/include/DB/IO/ReadBufferFromHTTP.h index 5c9178d12b9..3ab9abbf1b7 100644 --- a/dbms/include/DB/IO/ReadBufferFromHTTP.h +++ b/dbms/include/DB/IO/ReadBufferFromHTTP.h @@ -18,6 +18,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int RECEIVED_ERROR_FROM_REMOTE_IO_SERVER; +} + + /** Делает указанный HTTP-запрос и отдает ответ. */ class ReadBufferFromHTTP : public ReadBuffer diff --git a/dbms/include/DB/IO/ReadBufferFromIStream.h b/dbms/include/DB/IO/ReadBufferFromIStream.h index 310c1137abe..f4eb478a8eb 100644 --- a/dbms/include/DB/IO/ReadBufferFromIStream.h +++ b/dbms/include/DB/IO/ReadBufferFromIStream.h @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -12,6 +11,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_READ_FROM_ISTREAM; +} + + class ReadBufferFromIStream : public BufferWithOwnMemory { private: diff --git a/dbms/include/DB/IO/ReadHelpers.h b/dbms/include/DB/IO/ReadHelpers.h index 118fe7b9861..80ba9ad9167 100644 --- a/dbms/include/DB/IO/ReadHelpers.h +++ b/dbms/include/DB/IO/ReadHelpers.h @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -26,6 +25,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_PARSE_DATE; + extern const int CANNOT_PARSE_DATETIME; + extern const int CANNOT_READ_ARRAY_FROM_TEXT; +} + /// Функции-помошники для форматированного чтения inline char parseEscapeSequence(char c) diff --git a/dbms/include/DB/IO/WriteBuffer.h b/dbms/include/DB/IO/WriteBuffer.h index 706874b4720..1016dc047f2 100644 --- a/dbms/include/DB/IO/WriteBuffer.h +++ b/dbms/include/DB/IO/WriteBuffer.h @@ -4,13 +4,18 @@ #include #include -#include #include namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_WRITE_AFTER_END_OF_BUFFER; +} + + /** Простой абстрактный класс для буферизованной записи данных (последовательности char) куда-нибудь. * В отличие от std::ostream, предоставляет доступ к внутреннему буферу, * а также позволяет вручную управлять позицией внутри буфера. diff --git a/dbms/include/DB/IO/WriteBufferFromFile.h b/dbms/include/DB/IO/WriteBufferFromFile.h index 9c542bbdf51..b75fbcd7104 100644 --- a/dbms/include/DB/IO/WriteBufferFromFile.h +++ b/dbms/include/DB/IO/WriteBufferFromFile.h @@ -12,6 +12,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int FILE_DOESNT_EXIST; + extern const int CANNOT_OPEN_FILE; + extern const int CANNOT_CLOSE_FILE; +} + + /** Принимает имя файла. Самостоятельно открывает и закрывает файл. */ class WriteBufferFromFile : public WriteBufferFromFileDescriptor diff --git a/dbms/include/DB/IO/WriteBufferFromFileDescriptor.h b/dbms/include/DB/IO/WriteBufferFromFileDescriptor.h index b6c48fb547c..f0999d8e39b 100644 --- a/dbms/include/DB/IO/WriteBufferFromFileDescriptor.h +++ b/dbms/include/DB/IO/WriteBufferFromFileDescriptor.h @@ -4,7 +4,6 @@ #include #include -#include #include #include @@ -16,6 +15,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_WRITE_TO_FILE_DESCRIPTOR; + extern const int CANNOT_FSYNC; + extern const int CANNOT_SEEK_THROUGH_FILE; + extern const int CANNOT_TRUNCATE_FILE; +} + /** Работает с готовым файловым дескриптором. Не открывает и не закрывает файл. */ class WriteBufferFromFileDescriptor : public WriteBufferFromFileBase diff --git a/dbms/include/DB/IO/WriteBufferFromHTTPServerResponse.h b/dbms/include/DB/IO/WriteBufferFromHTTPServerResponse.h index 419a20ae100..7f2ab25da5a 100644 --- a/dbms/include/DB/IO/WriteBufferFromHTTPServerResponse.h +++ b/dbms/include/DB/IO/WriteBufferFromHTTPServerResponse.h @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -13,6 +12,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_WRITE_TO_OSTREAM; +} + /** Отличается от WriteBufferFromOStream тем, что инициализируется не std::ostream, а Poco::Net::HTTPServerResponse. * При первом сбросе данных, получает из него std::ostream (с помощью метода send). diff --git a/dbms/include/DB/IO/WriteBufferFromOStream.h b/dbms/include/DB/IO/WriteBufferFromOStream.h index 4a87aa0a908..b3dcad4eb4b 100644 --- a/dbms/include/DB/IO/WriteBufferFromOStream.h +++ b/dbms/include/DB/IO/WriteBufferFromOStream.h @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -12,6 +11,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_WRITE_TO_OSTREAM; +} + class WriteBufferFromOStream : public BufferWithOwnMemory { private: diff --git a/dbms/include/DB/IO/WriteHelpers.h b/dbms/include/DB/IO/WriteHelpers.h index 0266350af6a..c9e3dc89c58 100644 --- a/dbms/include/DB/IO/WriteHelpers.h +++ b/dbms/include/DB/IO/WriteHelpers.h @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -27,6 +26,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER; +} + /// Функции-помошники для форматированной записи inline void writeChar(char x, WriteBuffer & buf) diff --git a/dbms/include/DB/Interpreters/Aggregator.h b/dbms/include/DB/Interpreters/Aggregator.h index 55dea518da0..899eec170c9 100644 --- a/dbms/include/DB/Interpreters/Aggregator.h +++ b/dbms/include/DB/Interpreters/Aggregator.h @@ -31,6 +31,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_AGGREGATED_DATA_VARIANT; +} + /** Разные структуры данных, которые могут использоваться для агрегации * Для эффективности, сами данные для агрегации кладутся в пул. diff --git a/dbms/include/DB/Interpreters/ExpressionActions.h b/dbms/include/DB/Interpreters/ExpressionActions.h index e89b835d464..72950502148 100644 --- a/dbms/include/DB/Interpreters/ExpressionActions.h +++ b/dbms/include/DB/Interpreters/ExpressionActions.h @@ -15,8 +15,13 @@ namespace DB { -typedef std::pair NameWithAlias; -typedef std::vector NamesWithAliases; +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + +using NameWithAlias = std::pair; +using NamesWithAliases = std::vector; class Join; diff --git a/dbms/include/DB/Interpreters/ExternalDictionaries.h b/dbms/include/DB/Interpreters/ExternalDictionaries.h index 917e9beaa8e..51e09a854e1 100644 --- a/dbms/include/DB/Interpreters/ExternalDictionaries.h +++ b/dbms/include/DB/Interpreters/ExternalDictionaries.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include diff --git a/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h b/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h index 27585b61165..3ad52dbba73 100644 --- a/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h +++ b/dbms/include/DB/Interpreters/InJoinSubqueriesPreprocessor.h @@ -15,6 +15,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED; +} + namespace { diff --git a/dbms/include/DB/Interpreters/InterpreterSetQuery.h b/dbms/include/DB/Interpreters/InterpreterSetQuery.h index 0899452863a..7a4a9cc2b63 100644 --- a/dbms/include/DB/Interpreters/InterpreterSetQuery.h +++ b/dbms/include/DB/Interpreters/InterpreterSetQuery.h @@ -8,6 +8,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int READONLY; +} + /** Установить один или несколько параметров, для сессии или глобально... или для текущего запроса. */ diff --git a/dbms/include/DB/Interpreters/InterserverIOHandler.h b/dbms/include/DB/Interpreters/InterserverIOHandler.h index a8406e69092..b3a409ce840 100644 --- a/dbms/include/DB/Interpreters/InterserverIOHandler.h +++ b/dbms/include/DB/Interpreters/InterserverIOHandler.h @@ -10,6 +10,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int DUPLICATE_INTERSERVER_IO_ENDPOINT; + extern const int NO_SUCH_INTERSERVER_IO_ENDPOINT; +} + + /** Обработчик запросов от других серверов. */ class InterserverIOEndpoint diff --git a/dbms/include/DB/Interpreters/ProcessList.h b/dbms/include/DB/Interpreters/ProcessList.h index 0cb48c91318..244cecfbdfe 100644 --- a/dbms/include/DB/Interpreters/ProcessList.h +++ b/dbms/include/DB/Interpreters/ProcessList.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/dbms/include/DB/Interpreters/Quota.h b/dbms/include/DB/Interpreters/Quota.h index 84a38b10585..34ae6840442 100644 --- a/dbms/include/DB/Interpreters/Quota.h +++ b/dbms/include/DB/Interpreters/Quota.h @@ -15,7 +15,6 @@ #include #include -#include #include diff --git a/dbms/include/DB/Interpreters/SettingsCommon.h b/dbms/include/DB/Interpreters/SettingsCommon.h index 67066741543..a47018af15a 100644 --- a/dbms/include/DB/Interpreters/SettingsCommon.h +++ b/dbms/include/DB/Interpreters/SettingsCommon.h @@ -11,6 +11,19 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CPUID_ERROR; + extern const int TYPE_MISMATCH; + extern const int UNKNOWN_LOAD_BALANCING; + extern const int UNKNOWN_OVERFLOW_MODE; + extern const int ILLEGAL_OVERFLOW_MODE; + extern const int UNKNOWN_TOTALS_MODE; + extern const int UNKNOWN_COMPRESSION_METHOD; + extern const int UNKNOWN_DISTRIBUTED_PRODUCT_MODE; + extern const int UNKNOWN_GLOBAL_SUBQUERIES_METHOD; +} + /** Одна настройка какого-либо типа. * Хранит внутри себя значение, а также флаг - было ли значение изменено. @@ -348,7 +361,7 @@ struct SettingLoadBalancing { const char * strings[] = {"random", "nearest_hostname", "in_order"}; if (value < LoadBalancing::RANDOM || value > LoadBalancing::IN_ORDER) - throw Exception("Unknown load balancing mode", ErrorCodes::UNKNOWN_OVERFLOW_MODE); + throw Exception("Unknown load balancing mode", ErrorCodes::UNKNOWN_LOAD_BALANCING); return strings[static_cast(value)]; } @@ -424,7 +437,7 @@ struct SettingTotalsMode case TotalsMode::AFTER_HAVING_AUTO: return "after_having_auto"; default: - throw Exception("Unknown TotalsMode enum value", ErrorCodes::ARGUMENT_OUT_OF_BOUND); + throw Exception("Unknown TotalsMode enum value", ErrorCodes::UNKNOWN_TOTALS_MODE); } } @@ -633,7 +646,7 @@ struct SettingDistributedProductMode { const char * strings[] = {"deny", "local", "global", "allow"}; if (value < DistributedProductMode::DENY || value > DistributedProductMode::ALLOW) - throw Exception("Unknown distributed product mode", ErrorCodes::UNKNOWN_OVERFLOW_MODE); + throw Exception("Unknown distributed product mode", ErrorCodes::UNKNOWN_DISTRIBUTED_PRODUCT_MODE); return strings[static_cast(value)]; } diff --git a/dbms/include/DB/Interpreters/Users.h b/dbms/include/DB/Interpreters/Users.h index 3d7b6b1ca5f..5ef476ff595 100644 --- a/dbms/include/DB/Interpreters/Users.h +++ b/dbms/include/DB/Interpreters/Users.h @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -28,6 +27,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int DNS_ERROR; + extern const int UNKNOWN_ADDRESS_PATTERN_TYPE; + extern const int UNKNOWN_USER; + extern const int REQUIRED_PASSWORD; + extern const int WRONG_PASSWORD; + extern const int IP_ADDRESS_NOT_ALLOWED; +} + /// Позволяет проверить соответствие адреса шаблону. class IAddressPattern diff --git a/dbms/include/DB/Parsers/ASTAlterQuery.h b/dbms/include/DB/Parsers/ASTAlterQuery.h index d89e4c32bac..55214d86e22 100644 --- a/dbms/include/DB/Parsers/ASTAlterQuery.h +++ b/dbms/include/DB/Parsers/ASTAlterQuery.h @@ -7,6 +7,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNEXPECTED_AST_STRUCTURE; +} + /** ALTER запрос * ALTER TABLE [db.]name_type * ADD COLUMN col_name type [AFTER col_after], diff --git a/dbms/include/DB/Parsers/IAST.h b/dbms/include/DB/Parsers/IAST.h index 9e52c527b39..1955cae5051 100644 --- a/dbms/include/DB/Parsers/IAST.h +++ b/dbms/include/DB/Parsers/IAST.h @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -20,8 +19,17 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NOT_A_COLUMN; + extern const int TOO_BIG_AST; + extern const int TOO_DEEP_AST; + extern const int UNKNOWN_TYPE_OF_AST_NODE; + extern const int UNKNOWN_ELEMENT_IN_AST; +} + using Poco::SharedPtr; -typedef std::set IdentifierNameSet; +using IdentifierNameSet = std::set; /** Элемент синтаксического дерева (в дальнейшем - направленного ациклического графа с элементами семантики) @@ -29,7 +37,7 @@ typedef std::set IdentifierNameSet; class IAST { public: - typedef std::vector > ASTs; + using ASTs = std::vector>; ASTs children; StringRange range; @@ -240,8 +248,8 @@ private: }; -typedef SharedPtr ASTPtr; -typedef std::vector ASTs; +using ASTPtr = SharedPtr; +using ASTs = std::vector; /// Квотировать идентификатор обратными кавычками, если это требуется. diff --git a/dbms/include/DB/Storages/CompressionMethodSelector.h b/dbms/include/DB/Storages/CompressionMethodSelector.h index bc7d85097fb..45883a11de3 100644 --- a/dbms/include/DB/Storages/CompressionMethodSelector.h +++ b/dbms/include/DB/Storages/CompressionMethodSelector.h @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -8,6 +7,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_COMPRESSION_METHOD; + extern const int UNKNOWN_ELEMENT_IN_CONFIG; +} + + /** Позволяет выбрать метод сжатия по указанным в конфигурационном файле условиям. * Конфиг выглядит примерно так: diff --git a/dbms/include/DB/Storages/Distributed/DirectoryMonitor.h b/dbms/include/DB/Storages/Distributed/DirectoryMonitor.h index dd97cb09f32..95594ef0ea3 100644 --- a/dbms/include/DB/Storages/Distributed/DirectoryMonitor.h +++ b/dbms/include/DB/Storages/Distributed/DirectoryMonitor.h @@ -19,6 +19,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INCORRECT_FILE_NAME; + extern const int CHECKSUM_DOESNT_MATCH; + extern const int TOO_LARGE_SIZE_COMPRESSED; +} + + namespace { static constexpr const std::chrono::seconds max_sleep_time{30}; diff --git a/dbms/include/DB/Storages/IStorage.h b/dbms/include/DB/Storages/IStorage.h index 2a75c147567..7d9f6619dde 100644 --- a/dbms/include/DB/Storages/IStorage.h +++ b/dbms/include/DB/Storages/IStorage.h @@ -20,6 +20,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TABLE_IS_DROPPED; +} + class Context; class IBlockInputStream; class IBlockOutputStream; diff --git a/dbms/include/DB/Storages/MergeTree/DiskSpaceMonitor.h b/dbms/include/DB/Storages/MergeTree/DiskSpaceMonitor.h index eb8df48faf4..bd1e538338d 100644 --- a/dbms/include/DB/Storages/MergeTree/DiskSpaceMonitor.h +++ b/dbms/include/DB/Storages/MergeTree/DiskSpaceMonitor.h @@ -4,13 +4,19 @@ #include #include #include -#include #include #include namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_STATVFS; + extern const int NOT_ENOUGH_SPACE; +} + + /** Узнает количество свободного места в файловой системе. * Можно "резервировать" место, чтобы разные операции могли согласованно планировать использование диска. * Резервирования не разделяются по файловым системам. diff --git a/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h b/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h index d0a4117a2fa..91d58cbe6bd 100644 --- a/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h +++ b/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h @@ -9,6 +9,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER; +} + + /// Для чтения из одного куска. Для чтения сразу из многих, Storage использует сразу много таких объектов. class MergeTreeBlockInputStream : public IProfilingBlockInputStream { diff --git a/dbms/include/DB/Storages/MergeTree/MergeTreeData.h b/dbms/include/DB/Storages/MergeTree/MergeTreeData.h index 34991cef917..d464b883bce 100644 --- a/dbms/include/DB/Storages/MergeTree/MergeTreeData.h +++ b/dbms/include/DB/Storages/MergeTree/MergeTreeData.h @@ -25,6 +25,24 @@ struct SimpleIncrement; namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int NO_FILE_IN_DATA_PART; + extern const int EXPECTED_END_OF_FILE; + extern const int BAD_SIZE_OF_FILE_IN_DATA_PART; + extern const int FORMAT_VERSION_TOO_OLD; + extern const int INVALID_PARTITION_NAME; + extern const int UNKNOWN_FORMAT; + extern const int UNEXPECTED_FILE_IN_DATA_PART; + extern const int TOO_MUCH_PARTS; + extern const int NO_SUCH_DATA_PART; + extern const int DUPLICATE_DATA_PART; + extern const int DIRECTORY_ALREADY_EXISTS; + extern const int TOO_MANY_UNEXPECTED_DATA_PARTS; + extern const int NO_SUCH_COLUMN_IN_TABLE; +} + /** Структура данных для *MergeTree движков. * Используется merge tree для инкрементальной сортировки данных. * Таблица представлена набором сортированных кусков. diff --git a/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h b/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h index 496fad7d34d..d7e785e1bdb 100644 --- a/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h +++ b/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h @@ -18,6 +18,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NOT_FOUND_EXPECTED_DATA_PART; + extern const int MEMORY_LIMIT_EXCEEDED; +} + + /** Умеет читать данные между парой засечек из одного куска. При чтении последовательных отрезков не делает лишних seek-ов. * При чтении почти последовательных отрезков делает seek-и быстро, не выбрасывая содержимое буфера. */ diff --git a/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h b/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h index 6b2c5993e8d..ced848d3178 100644 --- a/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h +++ b/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h @@ -10,6 +10,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_LESS_LIVE_REPLICAS; + extern const int UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE; + extern const int CHECKSUM_DOESNT_MATCH; + extern const int UNEXPECTED_ZOOKEEPER_ERROR; + extern const int NO_ZOOKEEPER; +} + + class ReplicatedMergeTreeBlockOutputStream : public IBlockOutputStream { public: diff --git a/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h b/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h index e8fc1041b08..1c632a7317f 100644 --- a/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h +++ b/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include @@ -19,6 +18,13 @@ class ReadBuffer; class WriteBuffer; class ReplicatedMergeTreeQueue; +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int UNKNOWN_FORMAT_VERSION; + extern const int CANNOT_PARSE_TEXT; +} + /// Запись о том, что нужно сделать. Только данные (их можно копировать). struct ReplicatedMergeTreeLogEntryData diff --git a/dbms/include/DB/Storages/StorageLog.h b/dbms/include/DB/Storages/StorageLog.h index c0ff2161457..4b1c19db24f 100644 --- a/dbms/include/DB/Storages/StorageLog.h +++ b/dbms/include/DB/Storages/StorageLog.h @@ -12,6 +12,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NO_SUCH_COLUMN_IN_TABLE; +} + + /** Смещение до каждой некоторой пачки значений. * Эти пачки имеют одинаковый размер в разных столбцах. * Они нужны, чтобы можно было читать данные в несколько потоков. diff --git a/dbms/include/DB/TableFunctions/TableFunctionMerge.h b/dbms/include/DB/TableFunctions/TableFunctionMerge.h index 9dc6525e561..eba61fff0dd 100644 --- a/dbms/include/DB/TableFunctions/TableFunctionMerge.h +++ b/dbms/include/DB/TableFunctions/TableFunctionMerge.h @@ -14,6 +14,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; + extern const int UNKNOWN_TABLE; +} + + /* * merge(db_name, tables_regexp)- создаёт временный StorageMerge. * Cтруктура таблицы берётся из первой попавшейся таблицы, подходящей под регексп. diff --git a/dbms/include/DB/TableFunctions/TableFunctionRemote.h b/dbms/include/DB/TableFunctions/TableFunctionRemote.h index e454ad6df6f..92cb903c200 100644 --- a/dbms/include/DB/TableFunctions/TableFunctionRemote.h +++ b/dbms/include/DB/TableFunctions/TableFunctionRemote.h @@ -9,10 +9,16 @@ #include -struct data; namespace DB { +namespace ErrorCodes +{ + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; + extern const int BAD_ARGUMENTS; + extern const int NO_REMOTE_SHARD_FOUND; +} + /* * remote('address', db, table) - создаёт временный StorageDistributed. * Чтобы получить структуру таблицы, делается запрос DESC TABLE на удалённый сервер. diff --git a/dbms/src/Client/Connection.cpp b/dbms/src/Client/Connection.cpp index 7cbbbb48c57..f5ccef544d6 100644 --- a/dbms/src/Client/Connection.cpp +++ b/dbms/src/Client/Connection.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -27,6 +26,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NETWORK_ERROR; + extern const int SOCKET_TIMEOUT; + extern const int SERVER_REVISION_IS_TOO_OLD; + extern const int UNEXPECTED_PACKET_FROM_SERVER; + extern const int UNKNOWN_PACKET_FROM_SERVER; +} + + void Connection::connect() { try diff --git a/dbms/src/Client/InterruptListener.h b/dbms/src/Client/InterruptListener.h index a8e95eec669..979f60e02b9 100644 --- a/dbms/src/Client/InterruptListener.h +++ b/dbms/src/Client/InterruptListener.h @@ -2,12 +2,20 @@ #include #include -#include namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_MANIPULATE_SIGSET; + extern const int CANNOT_WAIT_FOR_SIGNAL; + extern const int CANNOT_BLOCK_SIGNAL; + extern const int CANNOT_UNBLOCK_SIGNAL; +} + + /** Пока существует объект этого класса - блокирует сигнал INT, при этом позволяет узнать, не пришёл ли он. * Это нужно, чтобы можно было прервать выполнение запроса с помощью Ctrl+C. * В один момент времени используйте только один экземпляр этого класса. diff --git a/dbms/src/Columns/ColumnsCommon.cpp b/dbms/src/Columns/ColumnsCommon.cpp index 3b3d6afa527..0f6085ecdb8 100644 --- a/dbms/src/Columns/ColumnsCommon.cpp +++ b/dbms/src/Columns/ColumnsCommon.cpp @@ -43,6 +43,12 @@ size_t countBytesInFilter(const IColumn::Filter & filt) } +namespace ErrorCodes +{ + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; +} + + template void filterArraysImpl( const PODArray & src_elems, const IColumn::Offsets_t & src_offsets, diff --git a/dbms/src/Common/Exception.cpp b/dbms/src/Common/Exception.cpp index ae8a58a67f5..ae08aadafac 100644 --- a/dbms/src/Common/Exception.cpp +++ b/dbms/src/Common/Exception.cpp @@ -12,6 +12,15 @@ namespace DB { +namespace ErrorCodes +{ + extern const int POCO_EXCEPTION; + extern const int STD_EXCEPTION; + extern const int UNKNOWN_EXCEPTION; + extern const int CANNOT_TRUNCATE_FILE; +} + + void throwFromErrno(const std::string & s, int code, int e) { char buf[128]; diff --git a/dbms/src/Common/Macros.cpp b/dbms/src/Common/Macros.cpp index 9e09a60accf..4208578a089 100644 --- a/dbms/src/Common/Macros.cpp +++ b/dbms/src/Common/Macros.cpp @@ -1,10 +1,14 @@ #include #include -#include namespace DB { +namespace ErrorCodes +{ + extern const int SYNTAX_ERROR; +} + Macros::Macros() {} Macros::Macros(const Poco::Util::AbstractConfiguration & config, const String & root_key) diff --git a/dbms/src/Common/MemoryTracker.cpp b/dbms/src/Common/MemoryTracker.cpp index 8b50006b43a..43b9e4d51d5 100644 --- a/dbms/src/Common/MemoryTracker.cpp +++ b/dbms/src/Common/MemoryTracker.cpp @@ -8,6 +8,15 @@ #include +namespace DB +{ +namespace ErrorCodes +{ + extern const int MEMORY_LIMIT_EXCEEDED; +} +} + + MemoryTracker::~MemoryTracker() { LOG_DEBUG(&Logger::get("MemoryTracker"), "Peak memory usage for query: " << formatReadableSizeWithBinarySuffix(peak) << "."); diff --git a/dbms/src/Common/ShellCommand.cpp b/dbms/src/Common/ShellCommand.cpp index 70d62cea7c1..55318f39618 100644 --- a/dbms/src/Common/ShellCommand.cpp +++ b/dbms/src/Common/ShellCommand.cpp @@ -4,12 +4,25 @@ #include #include -#include #include #include #include +namespace DB +{ + namespace ErrorCodes + { + extern const int CANNOT_PIPE; + extern const int CANNOT_DLSYM; + extern const int CANNOT_FORK; + extern const int CANNOT_WAITPID; + extern const int CHILD_WAS_NOT_EXITED_NORMALLY; + extern const int CANNOT_CREATE_CHILD_PROCESS; + } +} + + namespace { struct Pipe diff --git a/dbms/src/Common/localBackup.cpp b/dbms/src/Common/localBackup.cpp index 594ca18ec03..a71a4cd6151 100644 --- a/dbms/src/Common/localBackup.cpp +++ b/dbms/src/Common/localBackup.cpp @@ -8,13 +8,21 @@ #include #include -#include + + +namespace DB +{ +namespace ErrorCodes +{ + extern const int TOO_DEEP_RECURSION; +} +} static void localBackupImpl(Poco::Path source_path, Poco::Path destination_path, size_t level) { if (level >= 1000) - throw DB::Exception("Too deep recursion"); + throw DB::Exception("Too deep recursion", DB::ErrorCodes::TOO_DEEP_RECURSION); Poco::File(destination_path).createDirectories(); diff --git a/dbms/src/Core/Block.cpp b/dbms/src/Core/Block.cpp index 1943e8a855a..534bbfbf606 100644 --- a/dbms/src/Core/Block.cpp +++ b/dbms/src/Core/Block.cpp @@ -1,7 +1,6 @@ #include #include -#include #include @@ -20,6 +19,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int POSITION_OUT_OF_BOUND; + extern const int NOT_FOUND_COLUMN_IN_BLOCK; + extern const int SIZES_OF_COLUMNS_DOESNT_MATCH; + extern const int SIZES_OF_ARRAYS_DOESNT_MATCH; +} + Block::Block(const Block & other) { diff --git a/dbms/src/Core/ErrorCodes.cpp b/dbms/src/Core/ErrorCodes.cpp new file mode 100644 index 00000000000..38456d5fbce --- /dev/null +++ b/dbms/src/Core/ErrorCodes.cpp @@ -0,0 +1,314 @@ +namespace DB +{ + +namespace ErrorCodes +{ + const int UNSUPPORTED_METHOD = 1; + const int UNSUPPORTED_PARAMETER = 2; + const int UNEXPECTED_END_OF_FILE = 3; + const int EXPECTED_END_OF_FILE = 4; + const int CANNOT_PARSE_TEXT = 6; + const int INCORRECT_NUMBER_OF_COLUMNS = 7; + const int THERE_IS_NO_COLUMN = 8; + const int SIZES_OF_COLUMNS_DOESNT_MATCH = 9; + const int NOT_FOUND_COLUMN_IN_BLOCK = 10; + const int POSITION_OUT_OF_BOUND = 11; + const int PARAMETER_OUT_OF_BOUND = 12; + const int SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH = 13; + const int DUPLICATE_COLUMN = 15; + const int NO_SUCH_COLUMN_IN_TABLE = 16; + const int DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH = 17; + const int CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN = 18; + const int SIZE_OF_ARRAY_DOESNT_MATCH_SIZE_OF_FIXEDARRAY_COLUMN = 19; + const int NUMBER_OF_COLUMNS_DOESNT_MATCH = 20; + const int CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT = 21; + const int CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT = 22; + const int CANNOT_READ_FROM_ISTREAM = 23; + const int CANNOT_WRITE_TO_OSTREAM = 24; + const int CANNOT_PARSE_ESCAPE_SEQUENCE = 25; + const int CANNOT_PARSE_QUOTED_STRING = 26; + const int CANNOT_PARSE_INPUT_ASSERTION_FAILED = 27; + const int CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER = 28; + const int CANNOT_PRINT_INTEGER = 29; + const int CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK = 30; + const int CANNOT_READ_COMPRESSED_CHUNK = 31; + const int ATTEMPT_TO_READ_AFTER_EOF = 32; + const int CANNOT_READ_ALL_DATA = 33; + const int TOO_MUCH_ARGUMENTS_FOR_FUNCTION = 34; + const int TOO_LESS_ARGUMENTS_FOR_FUNCTION = 35; + const int BAD_ARGUMENTS = 36; + const int UNKNOWN_ELEMENT_IN_AST = 37; + const int CANNOT_PARSE_DATE = 38; + const int TOO_LARGE_SIZE_COMPRESSED = 39; + const int CHECKSUM_DOESNT_MATCH = 40; + const int CANNOT_PARSE_DATETIME = 41; + const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH = 42; + const int ILLEGAL_TYPE_OF_ARGUMENT = 43; + const int ILLEGAL_COLUMN = 44; + const int ILLEGAL_NUMBER_OF_RESULT_COLUMNS = 45; + const int UNKNOWN_FUNCTION = 46; + const int UNKNOWN_IDENTIFIER = 47; + const int NOT_IMPLEMENTED = 48; + const int LOGICAL_ERROR = 49; + const int UNKNOWN_TYPE = 50; + const int EMPTY_LIST_OF_COLUMNS_QUERIED = 51; + const int COLUMN_QUERIED_MORE_THAN_ONCE = 52; + const int TYPE_MISMATCH = 53; + const int STORAGE_DOESNT_ALLOW_PARAMETERS = 54; + const int STORAGE_REQUIRES_PARAMETER = 55; + const int UNKNOWN_STORAGE = 56; + const int TABLE_ALREADY_EXISTS = 57; + const int TABLE_METADATA_ALREADY_EXISTS = 58; + const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER = 59; + const int UNKNOWN_TABLE = 60; + const int ONLY_FILTER_COLUMN_IN_BLOCK = 61; + const int SYNTAX_ERROR = 62; + const int UNKNOWN_AGGREGATE_FUNCTION = 63; + const int CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT = 64; + const int CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT = 65; + const int NOT_A_COLUMN = 66; + const int ILLEGAL_KEY_OF_AGGREGATION = 67; + const int CANNOT_GET_SIZE_OF_FIELD = 68; + const int ARGUMENT_OUT_OF_BOUND = 69; + const int CANNOT_CONVERT_TYPE = 70; + const int CANNOT_WRITE_AFTER_END_OF_BUFFER = 71; + const int CANNOT_PARSE_NUMBER = 72; + const int UNKNOWN_FORMAT = 73; + const int CANNOT_READ_FROM_FILE_DESCRIPTOR = 74; + const int CANNOT_WRITE_TO_FILE_DESCRIPTOR = 75; + const int CANNOT_OPEN_FILE = 76; + const int CANNOT_CLOSE_FILE = 77; + const int UNKNOWN_TYPE_OF_QUERY = 78; + const int INCORRECT_FILE_NAME = 79; + const int INCORRECT_QUERY = 80; + const int UNKNOWN_DATABASE = 81; + const int DATABASE_ALREADY_EXISTS = 82; + const int DIRECTORY_DOESNT_EXIST = 83; + const int DIRECTORY_ALREADY_EXISTS = 84; + const int FORMAT_IS_NOT_SUITABLE_FOR_INPUT = 85; + const int RECEIVED_ERROR_FROM_REMOTE_IO_SERVER = 86; + const int CANNOT_SEEK_THROUGH_FILE = 87; + const int CANNOT_TRUNCATE_FILE = 88; + const int UNKNOWN_COMPRESSION_METHOD = 89; + const int EMPTY_LIST_OF_COLUMNS_PASSED = 90; + const int SIZES_OF_MARKS_FILES_ARE_INCONSISTENT = 91; + const int EMPTY_DATA_PASSED = 92; + const int UNKNOWN_AGGREGATED_DATA_VARIANT = 93; + const int CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS = 94; + const int CANNOT_READ_FROM_SOCKET = 95; + const int CANNOT_WRITE_TO_SOCKET = 96; + const int CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT = 97; + const int CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM = 98; + const int UNKNOWN_PACKET_FROM_CLIENT = 99; + const int UNKNOWN_PACKET_FROM_SERVER = 100; + const int UNEXPECTED_PACKET_FROM_CLIENT = 101; + const int UNEXPECTED_PACKET_FROM_SERVER = 102; + const int RECEIVED_DATA_FOR_WRONG_QUERY_ID = 103; + const int TOO_SMALL_BUFFER_SIZE = 104; + const int CANNOT_READ_HISTORY = 105; + const int CANNOT_APPEND_HISTORY = 106; + const int FILE_DOESNT_EXIST = 107; + const int NO_DATA_TO_INSERT = 108; + const int CANNOT_BLOCK_SIGNAL = 109; + const int CANNOT_UNBLOCK_SIGNAL = 110; + const int CANNOT_MANIPULATE_SIGSET = 111; + const int CANNOT_WAIT_FOR_SIGNAL = 112; + const int THERE_IS_NO_SESSION = 113; + const int CANNOT_CLOCK_GETTIME = 114; + const int UNKNOWN_SETTING = 115; + const int THERE_IS_NO_DEFAULT_VALUE = 116; + const int INCORRECT_DATA = 117; + const int TABLE_METADATA_DOESNT_EXIST = 118; + const int ENGINE_REQUIRED = 119; + const int CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE = 120; + const int UNKNOWN_SET_DATA_VARIANT = 121; + const int INCOMPATIBLE_COLUMNS = 122; + const int UNKNOWN_TYPE_OF_AST_NODE = 123; + const int INCORRECT_ELEMENT_OF_SET = 124; + const int INCORRECT_RESULT_OF_SCALAR_SUBQUERY = 125; + const int CANNOT_GET_RETURN_TYPE = 126; + const int ILLEGAL_INDEX = 127; + const int TOO_LARGE_ARRAY_SIZE = 128; + const int FUNCTION_IS_SPECIAL = 129; + const int CANNOT_READ_ARRAY_FROM_TEXT = 130; + const int TOO_LARGE_STRING_SIZE = 131; + const int CANNOT_CREATE_TABLE_FROM_METADATA = 132; + const int AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS = 133; + const int PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS = 134; + const int ZERO_ARRAY_OR_TUPLE_INDEX = 135; + const int UNKNOWN_ELEMENT_IN_CONFIG = 137; + const int EXCESSIVE_ELEMENT_IN_CONFIG = 138; + const int NO_ELEMENTS_IN_CONFIG = 139; + const int ALL_REQUESTED_COLUMNS_ARE_MISSING = 140; + const int SAMPLING_NOT_SUPPORTED = 141; + const int NOT_FOUND_NODE = 142; + const int FOUND_MORE_THAN_ONE_NODE = 143; + const int FIRST_DATE_IS_BIGGER_THAN_LAST_DATE = 144; + const int UNKNOWN_OVERFLOW_MODE = 145; + const int QUERY_SECTION_DOESNT_MAKE_SENSE = 146; + const int NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE = 147; + const int NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION = 148; + const int NOT_FOUND_RHS_ELEMENT_FOR_CONDITION = 149; + const int NO_ATTRIBUTES_LISTED = 150; + const int INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE = 151; + const int UNKNOWN_DIRECTION_OF_SORTING = 152; + const int ILLEGAL_DIVISION = 153; + const int AGGREGATE_FUNCTION_NOT_APPLICABLE = 154; + const int UNKNOWN_RELATION = 155; + const int DICTIONARIES_WAS_NOT_LOADED = 156; + const int ILLEGAL_OVERFLOW_MODE = 157; + const int TOO_MUCH_ROWS = 158; + const int TIMEOUT_EXCEEDED = 159; + const int TOO_SLOW = 160; + const int TOO_MUCH_COLUMNS = 161; + const int TOO_DEEP_SUBQUERIES = 162; + const int TOO_DEEP_PIPELINE = 163; + const int READONLY = 164; + const int TOO_MUCH_TEMPORARY_COLUMNS = 165; + const int TOO_MUCH_TEMPORARY_NON_CONST_COLUMNS = 166; + const int TOO_DEEP_AST = 167; + const int TOO_BIG_AST = 168; + const int BAD_TYPE_OF_FIELD = 169; + const int BAD_GET = 170; + const int BLOCKS_HAS_DIFFERENT_STRUCTURE = 171; + const int CANNOT_CREATE_DIRECTORY = 172; + const int CANNOT_ALLOCATE_MEMORY = 173; + const int CYCLIC_ALIASES = 174; + const int CHUNK_NOT_FOUND = 176; + const int DUPLICATE_CHUNK_NAME = 177; + const int MULTIPLE_ALIASES_FOR_EXPRESSION = 178; + const int MULTIPLE_EXPRESSIONS_FOR_ALIAS = 179; + const int THERE_IS_NO_PROFILE = 180; + const int ILLEGAL_FINAL = 181; + const int ILLEGAL_PREWHERE = 182; + const int UNEXPECTED_EXPRESSION = 183; + const int ILLEGAL_AGGREGATION = 184; + const int UNSUPPORTED_MYISAM_BLOCK_TYPE = 185; + const int UNSUPPORTED_COLLATION_LOCALE = 186; + const int COLLATION_COMPARISON_FAILED = 187; + const int UNKNOWN_ACTION = 188; + const int TABLE_MUST_NOT_BE_CREATED_MANUALLY = 189; + const int SIZES_OF_ARRAYS_DOESNT_MATCH = 190; + const int SET_SIZE_LIMIT_EXCEEDED = 191; + const int UNKNOWN_USER = 192; + const int WRONG_PASSWORD = 193; + const int REQUIRED_PASSWORD = 194; + const int IP_ADDRESS_NOT_ALLOWED = 195; + const int UNKNOWN_ADDRESS_PATTERN_TYPE = 196; + const int SERVER_REVISION_IS_TOO_OLD = 197; + const int DNS_ERROR = 198; + const int UNKNOWN_QUOTA = 199; + const int QUOTA_DOESNT_ALLOW_KEYS = 200; + const int QUOTA_EXPIRED = 201; + const int TOO_MUCH_SIMULTANEOUS_QUERIES = 202; + const int NO_FREE_CONNECTION = 203; + const int CANNOT_FSYNC = 204; + const int NESTED_TYPE_TOO_DEEP = 205; + const int ALIAS_REQUIRED = 206; + const int AMBIGUOUS_IDENTIFIER = 207; + const int EMPTY_NESTED_TABLE = 208; + const int SOCKET_TIMEOUT = 209; + const int NETWORK_ERROR = 210; + const int EMPTY_QUERY = 211; + const int UNKNOWN_LOAD_BALANCING = 212; + const int UNKNOWN_TOTALS_MODE = 213; + const int CANNOT_STATVFS = 214; + const int NOT_AN_AGGREGATE = 215; + const int QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING = 216; + const int CLIENT_HAS_CONNECTED_TO_WRONG_PORT = 217; + const int TABLE_IS_DROPPED = 218; + const int DATABASE_NOT_EMPTY = 219; + const int DUPLICATE_INTERSERVER_IO_ENDPOINT = 220; + const int NO_SUCH_INTERSERVER_IO_ENDPOINT = 221; + const int ADDING_REPLICA_TO_NON_EMPTY_TABLE = 222; + const int UNEXPECTED_AST_STRUCTURE = 223; + const int REPLICA_IS_ALREADY_ACTIVE = 224; + const int NO_ZOOKEEPER = 225; + const int NO_FILE_IN_DATA_PART = 226; + const int UNEXPECTED_FILE_IN_DATA_PART = 227; + const int BAD_SIZE_OF_FILE_IN_DATA_PART = 228; + const int QUERY_IS_TOO_LARGE = 229; + const int NOT_FOUND_EXPECTED_DATA_PART = 230; + const int TOO_MANY_UNEXPECTED_DATA_PARTS = 231; + const int NO_SUCH_DATA_PART = 232; + const int BAD_DATA_PART_NAME = 233; + const int NO_REPLICA_HAS_PART = 234; + const int DUPLICATE_DATA_PART = 235; + const int ABORTED = 236; + const int NO_REPLICA_NAME_GIVEN = 237; + const int FORMAT_VERSION_TOO_OLD = 238; + const int CANNOT_MUNMAP = 239; + const int CANNOT_MREMAP = 240; + const int MEMORY_LIMIT_EXCEEDED = 241; + const int TABLE_IS_READ_ONLY = 242; + const int NOT_ENOUGH_SPACE = 243; + const int UNEXPECTED_ZOOKEEPER_ERROR = 244; + const int INVALID_NESTED_NAME = 245; + const int CORRUPTED_DATA = 246; + const int INCORRECT_MARK = 247; + const int INVALID_PARTITION_NAME = 248; + const int NOT_ENOUGH_BLOCK_NUMBERS = 250; + const int NO_SUCH_REPLICA = 251; + const int TOO_MUCH_PARTS = 252; + const int REPLICA_IS_ALREADY_EXIST = 253; + const int NO_ACTIVE_REPLICAS = 254; + const int TOO_MUCH_RETRIES_TO_FETCH_PARTS = 255; + const int PARTITION_ALREADY_EXISTS = 256; + const int PARTITION_DOESNT_EXIST = 257; + const int UNION_ALL_RESULT_STRUCTURES_MISMATCH = 258; + const int UNION_ALL_COLUMN_ALIAS_MISMATCH = 259; + const int CLIENT_OUTPUT_FORMAT_SPECIFIED = 260; + const int UNKNOWN_BLOCK_INFO_FIELD = 261; + const int BAD_COLLATION = 262; + const int CANNOT_COMPILE_CODE = 263; + const int INCOMPATIBLE_TYPE_OF_JOIN = 264; + const int NO_AVAILABLE_REPLICA = 265; + const int MISMATCH_REPLICAS_DATA_SOURCES = 266; + const int STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS = 267; + const int CPUID_ERROR = 268; + const int INFINITE_LOOP = 269; + const int CANNOT_COMPRESS = 270; + const int CANNOT_DECOMPRESS = 271; + const int AIO_SUBMIT_ERROR = 272; + const int AIO_COMPLETION_ERROR = 273; + const int AIO_READ_ERROR = 274; + const int AIO_WRITE_ERROR = 275; + const int INDEX_NOT_USED = 277; + const int LEADERSHIP_LOST = 278; + const int ALL_CONNECTION_TRIES_FAILED = 279; + const int NO_AVAILABLE_DATA = 280; + const int DICTIONARY_IS_EMPTY = 281; + const int INCORRECT_INDEX = 282; + const int UNKNOWN_DISTRIBUTED_PRODUCT_MODE = 283; + const int UNKNOWN_GLOBAL_SUBQUERIES_METHOD = 284; + const int TOO_LESS_LIVE_REPLICAS = 285; + const int UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE = 286; + const int UNKNOWN_FORMAT_VERSION = 287; + const int DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED = 288; + const int REPLICA_IS_NOT_IN_QUORUM = 289; + const int LIMIT_EXCEEDED = 290; + const int DATABASE_ACCESS_DENIED = 291; + const int LEADERSHIP_CHANGED = 292; + const int MONGODB_INIT_FAILED = 293; + const int INVALID_BLOCK_EXTRA_INFO = 294; + const int RECEIVED_EMPTY_DATA = 295; + const int NO_REMOTE_SHARD_FOUND = 296; + const int SHARD_HAS_NO_CONNECTIONS = 297; + const int CANNOT_PIPE = 298; + const int CANNOT_FORK = 299; + const int CANNOT_DLSYM = 300; + const int CANNOT_CREATE_CHILD_PROCESS = 301; + const int CHILD_WAS_NOT_EXITED_NORMALLY = 302; + const int CANNOT_SELECT = 303; + const int CANNOT_WAITPID = 304; + const int TABLE_WAS_NOT_DROPPED = 305; + const int TOO_DEEP_RECURSION = 306; + const int TOO_MUCH_BYTES = 307; + + const int KEEPER_EXCEPTION = 999; + const int POCO_EXCEPTION = 1000; + const int STD_EXCEPTION = 1001; + const int UNKNOWN_EXCEPTION = 1002; +} + +} diff --git a/dbms/src/Core/NamesAndTypes.cpp b/dbms/src/Core/NamesAndTypes.cpp index b093325410c..69041fd242a 100644 --- a/dbms/src/Core/NamesAndTypes.cpp +++ b/dbms/src/Core/NamesAndTypes.cpp @@ -9,6 +9,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int THERE_IS_NO_COLUMN; +} + + void NamesAndTypesList::readText(ReadBuffer & buf) { const DataTypeFactory & data_type_factory = DataTypeFactory::instance(); diff --git a/dbms/src/DataStreams/BlockInputStreamFromRowInputStream.cpp b/dbms/src/DataStreams/BlockInputStreamFromRowInputStream.cpp index 9e9d28eb387..18262f121bc 100644 --- a/dbms/src/DataStreams/BlockInputStreamFromRowInputStream.cpp +++ b/dbms/src/DataStreams/BlockInputStreamFromRowInputStream.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -10,6 +9,11 @@ namespace DB using Poco::SharedPtr; +namespace ErrorCodes +{ + extern const int NUMBER_OF_COLUMNS_DOESNT_MATCH; +} + BlockInputStreamFromRowInputStream::BlockInputStreamFromRowInputStream( RowInputStreamPtr row_input_, diff --git a/dbms/src/DataStreams/CollapsingSortedBlockInputStream.cpp b/dbms/src/DataStreams/CollapsingSortedBlockInputStream.cpp index 368996fb65d..fb1f3bb4bb9 100644 --- a/dbms/src/DataStreams/CollapsingSortedBlockInputStream.cpp +++ b/dbms/src/DataStreams/CollapsingSortedBlockInputStream.cpp @@ -8,6 +8,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INCORRECT_DATA; +} + void CollapsingSortedBlockInputStream::reportIncorrectData() { diff --git a/dbms/src/DataStreams/CreatingSetsBlockInputStream.cpp b/dbms/src/DataStreams/CreatingSetsBlockInputStream.cpp index 1b4acd4dee3..e4e9bee06ac 100644 --- a/dbms/src/DataStreams/CreatingSetsBlockInputStream.cpp +++ b/dbms/src/DataStreams/CreatingSetsBlockInputStream.cpp @@ -4,9 +4,16 @@ #include #include + namespace DB { +namespace ErrorCodes +{ + extern const int SET_SIZE_LIMIT_EXCEEDED; +} + + Block CreatingSetsBlockInputStream::readImpl() { Block res; diff --git a/dbms/src/DataStreams/DistinctBlockInputStream.cpp b/dbms/src/DataStreams/DistinctBlockInputStream.cpp index 7647f831462..3422fbabf87 100644 --- a/dbms/src/DataStreams/DistinctBlockInputStream.cpp +++ b/dbms/src/DataStreams/DistinctBlockInputStream.cpp @@ -4,6 +4,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int SET_SIZE_LIMIT_EXCEEDED; +} + + DistinctBlockInputStream::DistinctBlockInputStream(BlockInputStreamPtr input_, const Limits & limits, size_t limit_, Names columns_) : columns_names(columns_), limit(limit_), diff --git a/dbms/src/DataStreams/FilterBlockInputStream.cpp b/dbms/src/DataStreams/FilterBlockInputStream.cpp index 2a0283a49b9..524204d8754 100644 --- a/dbms/src/DataStreams/FilterBlockInputStream.cpp +++ b/dbms/src/DataStreams/FilterBlockInputStream.cpp @@ -7,6 +7,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER; +} + FilterBlockInputStream::FilterBlockInputStream(BlockInputStreamPtr input_, ssize_t filter_column_) : filter_column(filter_column_) diff --git a/dbms/src/DataStreams/FormatFactory.cpp b/dbms/src/DataStreams/FormatFactory.cpp index 76d42cdec75..1ec88afff48 100644 --- a/dbms/src/DataStreams/FormatFactory.cpp +++ b/dbms/src/DataStreams/FormatFactory.cpp @@ -26,6 +26,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int FORMAT_IS_NOT_SUITABLE_FOR_INPUT; + extern const int UNKNOWN_FORMAT; +} + + BlockInputStreamPtr FormatFactory::getInput(const String & name, ReadBuffer & buf, const Block & sample, size_t max_block_size) const { diff --git a/dbms/src/DataStreams/IBlockInputStream.cpp b/dbms/src/DataStreams/IBlockInputStream.cpp index 0bdbcb69f04..8592590ace5 100644 --- a/dbms/src/DataStreams/IBlockInputStream.cpp +++ b/dbms/src/DataStreams/IBlockInputStream.cpp @@ -7,6 +7,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_DEEP_PIPELINE; +} + String IBlockInputStream::getTreeID() const { diff --git a/dbms/src/DataStreams/IProfilingBlockInputStream.cpp b/dbms/src/DataStreams/IProfilingBlockInputStream.cpp index 40a3bb74af9..89d5d780734 100644 --- a/dbms/src/DataStreams/IProfilingBlockInputStream.cpp +++ b/dbms/src/DataStreams/IProfilingBlockInputStream.cpp @@ -12,6 +12,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_MUCH_ROWS; + extern const int TOO_MUCH_BYTES; + extern const int TIMEOUT_EXCEEDED; + extern const int TOO_SLOW; +} + Block IProfilingBlockInputStream::read() { @@ -173,7 +181,7 @@ bool IProfilingBlockInputStream::checkLimits() + (limits.mode == LIMITS_CURRENT ? "result bytes (uncompressed)" : "(uncompressed) bytes to read") + " exceeded: read " + toString(info.bytes) + " bytes, maximum: " + toString(limits.max_bytes_to_read), - ErrorCodes::TOO_MUCH_ROWS); + ErrorCodes::TOO_MUCH_BYTES); if (limits.read_overflow_mode == OverflowMode::BREAK) return false; @@ -259,7 +267,7 @@ void IProfilingBlockInputStream::progressImpl(const Progress & value) else throw Exception("Limit for (uncompressed) bytes to read exceeded: " + toString(bytes_processed) + " bytes read, maximum: " + toString(limits.max_bytes_to_read), - ErrorCodes::TOO_MUCH_ROWS); + ErrorCodes::TOO_MUCH_BYTES); } else if (limits.read_overflow_mode == OverflowMode::BREAK) { diff --git a/dbms/src/DataStreams/MergingSortedBlockInputStream.cpp b/dbms/src/DataStreams/MergingSortedBlockInputStream.cpp index 28c7144324a..a56c7ee3f0b 100644 --- a/dbms/src/DataStreams/MergingSortedBlockInputStream.cpp +++ b/dbms/src/DataStreams/MergingSortedBlockInputStream.cpp @@ -7,6 +7,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int NUMBER_OF_COLUMNS_DOESNT_MATCH; + extern const int BLOCKS_HAS_DIFFERENT_STRUCTURE; +} + void MergingSortedBlockInputStream::init(Block & merged_block, ColumnPlainPtrs & merged_columns) { diff --git a/dbms/src/DataStreams/NativeBlockInputStream.cpp b/dbms/src/DataStreams/NativeBlockInputStream.cpp index 0b21d86a541..07e56c24d96 100644 --- a/dbms/src/DataStreams/NativeBlockInputStream.cpp +++ b/dbms/src/DataStreams/NativeBlockInputStream.cpp @@ -14,6 +14,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INCORRECT_INDEX; + extern const int LOGICAL_ERROR; + extern const int CANNOT_READ_ALL_DATA; +} + NativeBlockInputStream::NativeBlockInputStream( ReadBuffer & istr_, UInt64 server_revision_, diff --git a/dbms/src/DataStreams/RemoteBlockInputStream.cpp b/dbms/src/DataStreams/RemoteBlockInputStream.cpp index 0ae282c5cca..617ae05aa59 100644 --- a/dbms/src/DataStreams/RemoteBlockInputStream.cpp +++ b/dbms/src/DataStreams/RemoteBlockInputStream.cpp @@ -5,6 +5,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_PACKET_FROM_SERVER; + extern const int LOGICAL_ERROR; +} + + RemoteBlockInputStream::RemoteBlockInputStream(Connection & connection_, const String & query_, const Settings * settings_, ThrottlerPtr throttler_, const Tables & external_tables_, QueryProcessingStage::Enum stage_, const Context & context_) diff --git a/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp b/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp index 56e88cf6504..523055999b1 100644 --- a/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp +++ b/dbms/src/DataStreams/SummingSortedBlockInputStream.cpp @@ -8,6 +8,24 @@ namespace DB { +String SummingSortedBlockInputStream::getID() const +{ + std::stringstream res; + res << "SummingSorted(inputs"; + + for (size_t i = 0; i < children.size(); ++i) + res << ", " << children[i]->getID(); + + res << ", description"; + + for (size_t i = 0; i < description.size(); ++i) + res << ", " << description[i].getID(); + + res << ")"; + return res.str(); +} + + void SummingSortedBlockInputStream::insertCurrentRow(ColumnPlainPtrs & merged_columns) { for (size_t i = 0; i < num_columns; ++i) @@ -215,6 +233,26 @@ void SummingSortedBlockInputStream::merge(ColumnPlainPtrs & merged_columns, std: } +/** Реализует операцию +=. + * Возвращает false, если результат получился нулевым. + */ +class FieldVisitorSum : public StaticVisitor +{ +private: + const Field & rhs; +public: + FieldVisitorSum(const Field & rhs_) : rhs(rhs_) {} + + bool operator() (UInt64 & x) const { x += get(rhs); return x != 0; } + bool operator() (Int64 & x) const { x += get(rhs); return x != 0; } + bool operator() (Float64 & x) const { x += get(rhs); return x != 0; } + + bool operator() (Null & x) const { throw Exception("Cannot sum Nulls", ErrorCodes::LOGICAL_ERROR); } + bool operator() (String & x) const { throw Exception("Cannot sum Strings", ErrorCodes::LOGICAL_ERROR); } + bool operator() (Array & x) const { throw Exception("Cannot sum Arrays", ErrorCodes::LOGICAL_ERROR); } +}; + + template bool SummingSortedBlockInputStream::mergeMaps(Row & row, TSortCursor & cursor) { diff --git a/dbms/src/DataStreams/TabSeparatedRowInputStream.cpp b/dbms/src/DataStreams/TabSeparatedRowInputStream.cpp index e54b72f7d8f..210dd621c86 100644 --- a/dbms/src/DataStreams/TabSeparatedRowInputStream.cpp +++ b/dbms/src/DataStreams/TabSeparatedRowInputStream.cpp @@ -8,6 +8,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INCORRECT_DATA; +} + + using Poco::SharedPtr; TabSeparatedRowInputStream::TabSeparatedRowInputStream(ReadBuffer & istr_, const Block & sample_, bool with_names_, bool with_types_) diff --git a/dbms/src/DataStreams/TotalsHavingBlockInputStream.cpp b/dbms/src/DataStreams/TotalsHavingBlockInputStream.cpp index fd52c3aced4..6ac8ea36af5 100644 --- a/dbms/src/DataStreams/TotalsHavingBlockInputStream.cpp +++ b/dbms/src/DataStreams/TotalsHavingBlockInputStream.cpp @@ -5,6 +5,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_COLUMN; + extern const int ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER; +} + + static void finalize(Block & block) { for (size_t i = 0; i < block.columns(); ++i) diff --git a/dbms/src/DataTypes/DataTypeArray.cpp b/dbms/src/DataTypes/DataTypeArray.cpp index fc7fee20fe4..2fe2d2e289b 100644 --- a/dbms/src/DataTypes/DataTypeArray.cpp +++ b/dbms/src/DataTypes/DataTypeArray.cpp @@ -11,6 +11,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_READ_ARRAY_FROM_TEXT; +} + DataTypeArray::DataTypeArray(DataTypePtr nested_) : nested(nested_) { diff --git a/dbms/src/DataTypes/DataTypeFactory.cpp b/dbms/src/DataTypes/DataTypeFactory.cpp index 7cdf357e323..64bd4123819 100644 --- a/dbms/src/DataTypes/DataTypeFactory.cpp +++ b/dbms/src/DataTypes/DataTypeFactory.cpp @@ -26,6 +26,15 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ARGUMENT_OUT_OF_BOUND; + extern const int UNKNOWN_TYPE; + extern const int NESTED_TYPE_TOO_DEEP; + extern const int PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS; +} + + DataTypeFactory::DataTypeFactory() : non_parametric_data_types { diff --git a/dbms/src/DataTypes/DataTypeFixedString.cpp b/dbms/src/DataTypes/DataTypeFixedString.cpp index ff24ba020b2..63ec292c10d 100644 --- a/dbms/src/DataTypes/DataTypeFixedString.cpp +++ b/dbms/src/DataTypes/DataTypeFixedString.cpp @@ -19,6 +19,11 @@ namespace DB using Poco::SharedPtr; +namespace ErrorCodes +{ + extern const int CANNOT_READ_ALL_DATA; +} + std::string DataTypeFixedString::getName() const { diff --git a/dbms/src/DataTypes/DataTypeNested.cpp b/dbms/src/DataTypes/DataTypeNested.cpp index cf2f70e1064..c973af83447 100644 --- a/dbms/src/DataTypes/DataTypeNested.cpp +++ b/dbms/src/DataTypes/DataTypeNested.cpp @@ -9,6 +9,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INVALID_NESTED_NAME; +} + DataTypeNested::DataTypeNested(NamesAndTypesListPtr nested_) : nested(nested_) diff --git a/dbms/src/DataTypes/FieldToDataType.cpp b/dbms/src/DataTypes/FieldToDataType.cpp index 03934c22a76..441052517c1 100644 --- a/dbms/src/DataTypes/FieldToDataType.cpp +++ b/dbms/src/DataTypes/FieldToDataType.cpp @@ -6,6 +6,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int EMPTY_DATA_PASSED; + extern const int ILLEGAL_TYPE_OF_ARGUMENT; + extern const int NOT_IMPLEMENTED; +} + template static void convertArrayToCommonType(Array & arr) diff --git a/dbms/src/IO/ReadBufferAIO.cpp b/dbms/src/IO/ReadBufferAIO.cpp index 10de3a7117f..eb3279578a4 100644 --- a/dbms/src/IO/ReadBufferAIO.cpp +++ b/dbms/src/IO/ReadBufferAIO.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include @@ -13,6 +12,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int FILE_DOESNT_EXIST; + extern const int CANNOT_OPEN_FILE; + extern const int LOGICAL_ERROR; + extern const int ARGUMENT_OUT_OF_BOUND; + extern const int AIO_READ_ERROR; +} + + /// Примечание: выделяется дополнительная страница, которая содежрит те данные, которые /// не влезают в основной буфер. ReadBufferAIO::ReadBufferAIO(const std::string & filename_, size_t buffer_size_, int flags_, char * existing_memory_) diff --git a/dbms/src/IO/ReadBufferFromPocoSocket.cpp b/dbms/src/IO/ReadBufferFromPocoSocket.cpp index 580747ff4a8..d35bf3c9462 100644 --- a/dbms/src/IO/ReadBufferFromPocoSocket.cpp +++ b/dbms/src/IO/ReadBufferFromPocoSocket.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include @@ -10,6 +9,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NETWORK_ERROR; + extern const int SOCKET_TIMEOUT; + extern const int CANNOT_READ_FROM_SOCKET; +} + + bool ReadBufferFromPocoSocket::nextImpl() { ssize_t bytes_read = 0; diff --git a/dbms/src/IO/ReadHelpers.cpp b/dbms/src/IO/ReadHelpers.cpp index 8215a8b35b5..c2448a9cdb2 100644 --- a/dbms/src/IO/ReadHelpers.cpp +++ b/dbms/src/IO/ReadHelpers.cpp @@ -11,6 +11,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_PARSE_INPUT_ASSERTION_FAILED; + extern const int CANNOT_PARSE_ESCAPE_SEQUENCE; + extern const int CANNOT_PARSE_QUOTED_STRING; +} + static void __attribute__((__noinline__)) throwAtAssertionFailed(const char * s, ReadBuffer & buf) { diff --git a/dbms/src/IO/WriteBufferAIO.cpp b/dbms/src/IO/WriteBufferAIO.cpp index 392eec2ada0..b641b986da4 100644 --- a/dbms/src/IO/WriteBufferAIO.cpp +++ b/dbms/src/IO/WriteBufferAIO.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -9,6 +8,21 @@ namespace DB { +namespace ErrorCodes +{ + extern const int FILE_DOESNT_EXIST; + extern const int CANNOT_OPEN_FILE; + extern const int LOGICAL_ERROR; + extern const int ARGUMENT_OUT_OF_BOUND; + extern const int AIO_READ_ERROR; + extern const int AIO_SUBMIT_ERROR; + extern const int AIO_WRITE_ERROR; + extern const int AIO_COMPLETION_ERROR; + extern const int CANNOT_TRUNCATE_FILE; + extern const int CANNOT_FSYNC; +} + + /// Примечание: выделяется дополнительная страница, которая содежрит те данные, которые /// не влезают в основной буфер. WriteBufferAIO::WriteBufferAIO(const std::string & filename_, size_t buffer_size_, int flags_, mode_t mode_, diff --git a/dbms/src/IO/WriteBufferFromPocoSocket.cpp b/dbms/src/IO/WriteBufferFromPocoSocket.cpp index 4725d0661a1..bdcf954c70e 100644 --- a/dbms/src/IO/WriteBufferFromPocoSocket.cpp +++ b/dbms/src/IO/WriteBufferFromPocoSocket.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include @@ -10,6 +9,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NETWORK_ERROR; + extern const int SOCKET_TIMEOUT; + extern const int CANNOT_WRITE_TO_SOCKET; +} + + void WriteBufferFromPocoSocket::nextImpl() { if (!offset()) diff --git a/dbms/src/Interpreters/Aggregator.cpp b/dbms/src/Interpreters/Aggregator.cpp index 6c15eb0f6db..6c8af429a9b 100644 --- a/dbms/src/Interpreters/Aggregator.cpp +++ b/dbms/src/Interpreters/Aggregator.cpp @@ -24,6 +24,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_COMPILE_CODE; + extern const int TOO_MUCH_ROWS; + extern const int EMPTY_DATA_PASSED; + extern const int CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS; +} + AggregatedDataVariants::~AggregatedDataVariants() { diff --git a/dbms/src/Interpreters/Context.cpp b/dbms/src/Interpreters/Context.cpp index d2b6aaed7cf..9ce2c12d658 100644 --- a/dbms/src/Interpreters/Context.cpp +++ b/dbms/src/Interpreters/Context.cpp @@ -48,6 +48,17 @@ namespace DB { +namespace ErrorCodes +{ + extern const int DATABASE_ACCESS_DENIED; + extern const int UNKNOWN_DATABASE; + extern const int UNKNOWN_TABLE; + extern const int TABLE_ALREADY_EXISTS; + extern const int DATABASE_ALREADY_EXISTS; + extern const int TABLE_METADATA_DOESNT_EXIST; + extern const int THERE_IS_NO_SESSION; + extern const int NO_ELEMENTS_IN_CONFIG; +} class TableFunctionFactory; diff --git a/dbms/src/Interpreters/ExpressionActions.cpp b/dbms/src/Interpreters/ExpressionActions.cpp index df4d8e94380..2de70f883fb 100644 --- a/dbms/src/Interpreters/ExpressionActions.cpp +++ b/dbms/src/Interpreters/ExpressionActions.cpp @@ -11,6 +11,17 @@ namespace DB { +namespace ErrorCodes +{ + extern const int DUPLICATE_COLUMN; + extern const int UNKNOWN_IDENTIFIER; + extern const int UNKNOWN_ACTION; + extern const int NOT_FOUND_COLUMN_IN_BLOCK; + extern const int SIZES_OF_ARRAYS_DOESNT_MATCH; + extern const int TOO_MUCH_TEMPORARY_COLUMNS; + extern const int TOO_MUCH_TEMPORARY_NON_CONST_COLUMNS; +} + Names ExpressionAction::getNeededColumns() const { diff --git a/dbms/src/Interpreters/ExpressionAnalyzer.cpp b/dbms/src/Interpreters/ExpressionAnalyzer.cpp index 7e961cb99cb..23eaea9c406 100644 --- a/dbms/src/Interpreters/ExpressionAnalyzer.cpp +++ b/dbms/src/Interpreters/ExpressionAnalyzer.cpp @@ -51,6 +51,23 @@ namespace DB { +namespace ErrorCodes +{ + extern const int MULTIPLE_EXPRESSIONS_FOR_ALIAS; + extern const int UNKNOWN_IDENTIFIER; + extern const int CYCLIC_ALIASES; + extern const int INCORRECT_RESULT_OF_SCALAR_SUBQUERY; + extern const int TOO_MUCH_ROWS; + extern const int NOT_FOUND_COLUMN_IN_BLOCK; + extern const int INCORRECT_ELEMENT_OF_SET; + extern const int ALIAS_REQUIRED; + extern const int EMPTY_NESTED_TABLE; + extern const int NOT_AN_AGGREGATE; + extern const int UNEXPECTED_EXPRESSION; + extern const int PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS; + extern const int DUPLICATE_COLUMN; +} + /** Calls to these functions in the GROUP BY statement would be * replaced by their immediate argument. diff --git a/dbms/src/Interpreters/ExternalDictionaries.cpp b/dbms/src/Interpreters/ExternalDictionaries.cpp index 79813706f65..cff3122c215 100644 --- a/dbms/src/Interpreters/ExternalDictionaries.cpp +++ b/dbms/src/Interpreters/ExternalDictionaries.cpp @@ -18,6 +18,13 @@ namespace namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int BAD_ARGUMENTS; +} + + namespace { std::set getDictionariesConfigPaths(const Poco::Util::AbstractConfiguration & config) diff --git a/dbms/src/Interpreters/InterpreterAlterQuery.cpp b/dbms/src/Interpreters/InterpreterAlterQuery.cpp index 1f8cbcfcc36..24a612ddc62 100644 --- a/dbms/src/Interpreters/InterpreterAlterQuery.cpp +++ b/dbms/src/Interpreters/InterpreterAlterQuery.cpp @@ -20,7 +20,14 @@ #include -using namespace DB; +namespace DB +{ + +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + InterpreterAlterQuery::InterpreterAlterQuery(ASTPtr query_ptr_, Context & context_) : query_ptr(query_ptr_), context(context_) @@ -204,3 +211,5 @@ void InterpreterAlterQuery::updateMetadata( Poco::File(metadata_temp_path).renameTo(metadata_path); } + +} diff --git a/dbms/src/Interpreters/InterpreterCheckQuery.cpp b/dbms/src/Interpreters/InterpreterCheckQuery.cpp index 3fc39a76dbb..dd07d2cec43 100644 --- a/dbms/src/Interpreters/InterpreterCheckQuery.cpp +++ b/dbms/src/Interpreters/InterpreterCheckQuery.cpp @@ -15,6 +15,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INVALID_BLOCK_EXTRA_INFO; + extern const int RECEIVED_EMPTY_DATA; +} + + namespace { diff --git a/dbms/src/Interpreters/InterpreterCreateQuery.cpp b/dbms/src/Interpreters/InterpreterCreateQuery.cpp index f1574ac5fee..5c95cc2d6c8 100644 --- a/dbms/src/Interpreters/InterpreterCreateQuery.cpp +++ b/dbms/src/Interpreters/InterpreterCreateQuery.cpp @@ -37,6 +37,17 @@ namespace DB { +namespace ErrorCodes +{ + extern const int DIRECTORY_DOESNT_EXIST; + extern const int DIRECTORY_ALREADY_EXISTS; + extern const int TABLE_ALREADY_EXISTS; + extern const int EMPTY_LIST_OF_COLUMNS_PASSED; + extern const int INCORRECT_QUERY; + extern const int ENGINE_REQUIRED; + extern const int TABLE_METADATA_ALREADY_EXISTS; +} + InterpreterCreateQuery::InterpreterCreateQuery(ASTPtr query_ptr_, Context & context_) : query_ptr(query_ptr_), context(context_) diff --git a/dbms/src/Interpreters/InterpreterDropQuery.cpp b/dbms/src/Interpreters/InterpreterDropQuery.cpp index 39ddf16a3c3..bdf34229cda 100644 --- a/dbms/src/Interpreters/InterpreterDropQuery.cpp +++ b/dbms/src/Interpreters/InterpreterDropQuery.cpp @@ -9,6 +9,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TABLE_WAS_NOT_DROPPED; + extern const int DATABASE_NOT_EMPTY; +} + InterpreterDropQuery::InterpreterDropQuery(ASTPtr query_ptr_, Context & context_) : query_ptr(query_ptr_), context(context_) diff --git a/dbms/src/Interpreters/InterpreterFactory.cpp b/dbms/src/Interpreters/InterpreterFactory.cpp index 2674e09d743..1dce83fb217 100644 --- a/dbms/src/Interpreters/InterpreterFactory.cpp +++ b/dbms/src/Interpreters/InterpreterFactory.cpp @@ -32,6 +32,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int READONLY; + extern const int UNKNOWN_TYPE_OF_QUERY; +} + static void throwIfReadOnly(Context & context) { diff --git a/dbms/src/Interpreters/InterpreterInsertQuery.cpp b/dbms/src/Interpreters/InterpreterInsertQuery.cpp index 06bc5709614..b5ad2a72a55 100644 --- a/dbms/src/Interpreters/InterpreterInsertQuery.cpp +++ b/dbms/src/Interpreters/InterpreterInsertQuery.cpp @@ -18,6 +18,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NO_SUCH_COLUMN_IN_TABLE; +} + InterpreterInsertQuery::InterpreterInsertQuery(ASTPtr query_ptr_, Context & context_) : query_ptr(query_ptr_), context(context_) diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 5335dd4706d..92d893576ae 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -37,6 +37,18 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_DEEP_SUBQUERIES; + extern const int THERE_IS_NO_COLUMN; + extern const int UNION_ALL_RESULT_STRUCTURES_MISMATCH; + extern const int SAMPLING_NOT_SUPPORTED; + extern const int ILLEGAL_FINAL; + extern const int ILLEGAL_PREWHERE; + extern const int TOO_MUCH_COLUMNS; +} + + InterpreterSelectQuery::~InterpreterSelectQuery() = default; diff --git a/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp b/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp index e67c70638ef..a4e475d1e0d 100644 --- a/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp +++ b/dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp @@ -5,13 +5,18 @@ #include #include -#include - #include + namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + + LogicalExpressionsOptimizer::OrWithExpression::OrWithExpression(ASTFunction * or_function_, const std::string & expression_) : or_function(or_function_), expression(expression_) { diff --git a/dbms/src/Interpreters/ProcessList.cpp b/dbms/src/Interpreters/ProcessList.cpp index 505aaf35934..e2b8afd4242 100644 --- a/dbms/src/Interpreters/ProcessList.cpp +++ b/dbms/src/Interpreters/ProcessList.cpp @@ -3,6 +3,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_MUCH_SIMULTANEOUS_QUERIES; + extern const int QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING; +} + ProcessList::EntryPtr ProcessList::insert( const String & query_, const String & user_, const String & query_id_, const Poco::Net::IPAddress & ip_address_, diff --git a/dbms/src/Interpreters/Quota.cpp b/dbms/src/Interpreters/Quota.cpp index fe4dde914e0..464a1c8a290 100644 --- a/dbms/src/Interpreters/Quota.cpp +++ b/dbms/src/Interpreters/Quota.cpp @@ -12,6 +12,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int QUOTA_EXPIRED; + extern const int QUOTA_DOESNT_ALLOW_KEYS; + extern const int UNKNOWN_QUOTA; +} + + void QuotaValues::initFromConfig(const String & config_elem, Poco::Util::AbstractConfiguration & config) { queries = parse(config.getString(config_elem + ".queries", "0")); diff --git a/dbms/src/Interpreters/executeQuery.cpp b/dbms/src/Interpreters/executeQuery.cpp index de9ffe9d1d7..95cf77f413a 100644 --- a/dbms/src/Interpreters/executeQuery.cpp +++ b/dbms/src/Interpreters/executeQuery.cpp @@ -24,6 +24,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int QUERY_IS_TOO_LARGE; +} + static void checkLimits(const IAST & ast, const Limits & limits) { diff --git a/dbms/src/Interpreters/loadMetadata.cpp b/dbms/src/Interpreters/loadMetadata.cpp index 7ea0a0fe978..ef651b79fef 100644 --- a/dbms/src/Interpreters/loadMetadata.cpp +++ b/dbms/src/Interpreters/loadMetadata.cpp @@ -25,6 +25,13 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TABLE_ALREADY_EXISTS; + extern const int CANNOT_CREATE_TABLE_FROM_METADATA; + extern const int INCORRECT_FILE_NAME; +} + static void executeCreateQuery(const String & query, Context & context, const String & database, const String & file_name) { diff --git a/dbms/src/Interpreters/sortBlock.cpp b/dbms/src/Interpreters/sortBlock.cpp index f0c090d61ef..f71976a66e2 100644 --- a/dbms/src/Interpreters/sortBlock.cpp +++ b/dbms/src/Interpreters/sortBlock.cpp @@ -4,7 +4,13 @@ namespace DB { -typedef std::vector > ColumnsWithSortDescriptions; +namespace ErrorCodes +{ + extern const int BAD_COLLATION; +} + + +using ColumnsWithSortDescriptions = std::vector>; static inline bool needCollation(const IColumn * column, const SortColumnDescription & description) diff --git a/dbms/src/Interpreters/tests/hash_map3.cpp b/dbms/src/Interpreters/tests/hash_map3.cpp index 202f2bc1174..ef7ecb85398 100644 --- a/dbms/src/Interpreters/tests/hash_map3.cpp +++ b/dbms/src/Interpreters/tests/hash_map3.cpp @@ -12,7 +12,6 @@ #include #include -#include #include diff --git a/dbms/src/Parsers/ASTSelectQuery.cpp b/dbms/src/Parsers/ASTSelectQuery.cpp index 3420fcead40..dd384659c5b 100644 --- a/dbms/src/Parsers/ASTSelectQuery.cpp +++ b/dbms/src/Parsers/ASTSelectQuery.cpp @@ -6,6 +6,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNION_ALL_COLUMN_ALIAS_MISMATCH; + extern const int UNION_ALL_RESULT_STRUCTURES_MISMATCH; + extern const int UNKNOWN_IDENTIFIER; +} + + ASTSelectQuery::ASTSelectQuery(const StringRange range_) : ASTQueryWithOutput(range_) { } diff --git a/dbms/src/Parsers/ExpressionElementParsers.cpp b/dbms/src/Parsers/ExpressionElementParsers.cpp index 1f973dc054c..307f20e02a0 100644 --- a/dbms/src/Parsers/ExpressionElementParsers.cpp +++ b/dbms/src/Parsers/ExpressionElementParsers.cpp @@ -24,6 +24,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int SYNTAX_ERROR; +} + bool ParserArray::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) { diff --git a/dbms/src/Parsers/IParserBase.cpp b/dbms/src/Parsers/IParserBase.cpp index 3dc3a795e14..a0a7182713e 100644 --- a/dbms/src/Parsers/IParserBase.cpp +++ b/dbms/src/Parsers/IParserBase.cpp @@ -4,6 +4,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + + bool IParserBase::parse(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) { Pos begin = pos; diff --git a/dbms/src/Parsers/ParserInsertQuery.cpp b/dbms/src/Parsers/ParserInsertQuery.cpp index ff494585863..70f48922a20 100644 --- a/dbms/src/Parsers/ParserInsertQuery.cpp +++ b/dbms/src/Parsers/ParserInsertQuery.cpp @@ -13,6 +13,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int SYNTAX_ERROR; +} + bool ParserInsertQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) { diff --git a/dbms/src/Parsers/ParserJoin.cpp b/dbms/src/Parsers/ParserJoin.cpp index ecf2df3a8ee..b4dc76317a4 100644 --- a/dbms/src/Parsers/ParserJoin.cpp +++ b/dbms/src/Parsers/ParserJoin.cpp @@ -8,6 +8,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int SYNTAX_ERROR; +} + bool ParserJoin::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected) { diff --git a/dbms/src/Parsers/parseQuery.cpp b/dbms/src/Parsers/parseQuery.cpp index 7ebba6e014d..ff7871847ff 100644 --- a/dbms/src/Parsers/parseQuery.cpp +++ b/dbms/src/Parsers/parseQuery.cpp @@ -4,10 +4,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int SYNTAX_ERROR; +} + + /** Из позиции в (возможно многострочном) запросе получить номер строки и номер столбца в строке. * Используется в сообщении об ошибках. */ -static inline std::pair getLineAndCol(IParser::Pos begin, IParser::Pos pos) +static std::pair getLineAndCol(IParser::Pos begin, IParser::Pos pos) { size_t line = 0; diff --git a/dbms/src/Server/HTTPHandler.cpp b/dbms/src/Server/HTTPHandler.cpp index 0fd8a245882..83f423c7752 100644 --- a/dbms/src/Server/HTTPHandler.cpp +++ b/dbms/src/Server/HTTPHandler.cpp @@ -4,8 +4,6 @@ #include -#include - #include #include #include @@ -28,6 +26,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int READONLY; +} + + void HTTPHandler::processQuery(Poco::Net::HTTPServerRequest & request, Poco::Net::HTTPServerResponse & response, Output & used_output) { LOG_TRACE(log, "Request URI: " << request.getURI()); diff --git a/dbms/src/Server/OLAPQueryParser.cpp b/dbms/src/Server/OLAPQueryParser.cpp index 7891b5c5613..0da75023df3 100644 --- a/dbms/src/Server/OLAPQueryParser.cpp +++ b/dbms/src/Server/OLAPQueryParser.cpp @@ -3,7 +3,6 @@ #include #include "OLAPQueryParser.h" -#include #include #include #include @@ -11,6 +10,22 @@ namespace DB { + + namespace ErrorCodes +{ + extern const int NOT_FOUND_NODE; + extern const int FOUND_MORE_THAN_ONE_NODE; + extern const int SYNTAX_ERROR; + extern const int FIRST_DATE_IS_BIGGER_THAN_LAST_DATE; + extern const int UNKNOWN_OVERFLOW_MODE; + extern const int NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE; + extern const int NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION; + extern const int NOT_FOUND_RHS_ELEMENT_FOR_CONDITION; + extern const int NO_ATTRIBUTES_LISTED; + extern const int UNKNOWN_DIRECTION_OF_SORTING; + extern const int INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE; +} + namespace OLAP { diff --git a/dbms/src/Server/TCPHandler.cpp b/dbms/src/Server/TCPHandler.cpp index 8c7c57be4c9..0c26448e505 100644 --- a/dbms/src/Server/TCPHandler.cpp +++ b/dbms/src/Server/TCPHandler.cpp @@ -6,7 +6,6 @@ #include -#include #include #include @@ -33,6 +32,18 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CLIENT_HAS_CONNECTED_TO_WRONG_PORT; + extern const int UNKNOWN_DATABASE; + extern const int UNKNOWN_EXCEPTION; + extern const int UNKNOWN_PACKET_FROM_CLIENT; + extern const int POCO_EXCEPTION; + extern const int STD_EXCEPTION; + extern const int SOCKET_TIMEOUT; + extern const int UNEXPECTED_PACKET_FROM_CLIENT; +} + void TCPHandler::runImpl() { diff --git a/dbms/src/Storages/AlterCommands.cpp b/dbms/src/Storages/AlterCommands.cpp index ad80a902173..ae7e1295f27 100644 --- a/dbms/src/Storages/AlterCommands.cpp +++ b/dbms/src/Storages/AlterCommands.cpp @@ -9,329 +9,338 @@ namespace DB { - void AlterCommand::apply( - NamesAndTypesList & columns, NamesAndTypesList & materialized_columns, NamesAndTypesList & alias_columns, - ColumnDefaults & column_defaults) const + +namespace ErrorCodes +{ + extern const int ILLEGAL_COLUMN; + extern const int LOGICAL_ERROR; +} + + +void AlterCommand::apply( + NamesAndTypesList & columns, NamesAndTypesList & materialized_columns, NamesAndTypesList & alias_columns, + ColumnDefaults & column_defaults) const +{ + if (type == ADD) { - if (type == ADD) - { - const auto exists_in = [this] (const NamesAndTypesList & columns) { - return columns.end() != std::find_if(columns.begin(), columns.end(), - std::bind(namesEqual, std::cref(column_name), std::placeholders::_1)); - }; + const auto exists_in = [this] (const NamesAndTypesList & columns) { + return columns.end() != std::find_if(columns.begin(), columns.end(), + std::bind(namesEqual, std::cref(column_name), std::placeholders::_1)); + }; - if (exists_in(columns) || - exists_in(materialized_columns) || - exists_in(alias_columns)) + if (exists_in(columns) || + exists_in(materialized_columns) || + exists_in(alias_columns)) + { + throw Exception{ + "Cannot add column " + column_name + ": column with this name already exists", + DB::ErrorCodes::ILLEGAL_COLUMN + }; + } + + const auto add_column = [this] (NamesAndTypesList & columns) + { + auto insert_it = columns.end(); + + if (!after_column.empty()) { - throw Exception{ - "Cannot add column " + column_name + ": column with this name already exists", - DB::ErrorCodes::ILLEGAL_COLUMN - }; + /// Пытаемся найти первую с конца колонку с именем column_name или с именем, начинающимся с column_name и ".". + /// Например "fruits.bananas" + /// одинаковыми считаются имена, если они совпадают целиком или name_without_dot совпадает с частью имени до точки + const auto reverse_insert_it = std::find_if(columns.rbegin(), columns.rend(), + std::bind(namesEqual, std::cref(after_column), std::placeholders::_1)); + + if (reverse_insert_it == columns.rend()) + throw Exception("Wrong column name. Cannot find column " + after_column + " to insert after", + DB::ErrorCodes::ILLEGAL_COLUMN); + else + { + /// base возвращает итератор, уже смещенный на один элемент вправо + insert_it = reverse_insert_it.base(); + } } - const auto add_column = [this] (NamesAndTypesList & columns) + columns.emplace(insert_it, column_name, data_type); + }; + + if (default_type == ColumnDefaultType::Default) + add_column(columns); + else if (default_type == ColumnDefaultType::Materialized) + add_column(materialized_columns); + else if (default_type == ColumnDefaultType::Alias) + add_column(alias_columns); + else + throw Exception{"Unknown ColumnDefaultType value", ErrorCodes::LOGICAL_ERROR}; + + if (default_expression) + column_defaults.emplace(column_name, ColumnDefault{default_type, default_expression}); + + /// Медленно, так как каждый раз копируется список + columns = *DataTypeNested::expandNestedColumns(columns); + } + else if (type == DROP) + { + /// look for a column in list and remove it if present, also removing corresponding entry from column_defaults + const auto remove_column = [&column_defaults, this] (NamesAndTypesList & columns) { + auto removed = false; + NamesAndTypesList::iterator column_it; + + while (columns.end() != (column_it = std::find_if(columns.begin(), columns.end(), + std::bind(namesEqual, std::cref(column_name), std::placeholders::_1)))) { - auto insert_it = columns.end(); + removed = true; + column_it = columns.erase(column_it); + column_defaults.erase(column_name); + } - if (!after_column.empty()) - { - /// Пытаемся найти первую с конца колонку с именем column_name или с именем, начинающимся с column_name и ".". - /// Например "fruits.bananas" - /// одинаковыми считаются имена, если они совпадают целиком или name_without_dot совпадает с частью имени до точки - const auto reverse_insert_it = std::find_if(columns.rbegin(), columns.rend(), - std::bind(namesEqual, std::cref(after_column), std::placeholders::_1)); + return removed; + }; - if (reverse_insert_it == columns.rend()) - throw Exception("Wrong column name. Cannot find column " + after_column + " to insert after", - DB::ErrorCodes::ILLEGAL_COLUMN); - else - { - /// base возвращает итератор, уже смещенный на один элемент вправо - insert_it = reverse_insert_it.base(); - } - } - - columns.emplace(insert_it, column_name, data_type); - }; - - if (default_type == ColumnDefaultType::Default) - add_column(columns); - else if (default_type == ColumnDefaultType::Materialized) - add_column(materialized_columns); - else if (default_type == ColumnDefaultType::Alias) - add_column(alias_columns); - else - throw Exception{"Unknown ColumnDefaultType value", ErrorCodes::LOGICAL_ERROR}; - - if (default_expression) - column_defaults.emplace(column_name, ColumnDefault{default_type, default_expression}); - - /// Медленно, так как каждый раз копируется список - columns = *DataTypeNested::expandNestedColumns(columns); - } - else if (type == DROP) + if (!remove_column(columns) && + !remove_column(materialized_columns) && + !remove_column(alias_columns)) { - /// look for a column in list and remove it if present, also removing corresponding entry from column_defaults - const auto remove_column = [&column_defaults, this] (NamesAndTypesList & columns) { - auto removed = false; - NamesAndTypesList::iterator column_it; + throw Exception("Wrong column name. Cannot find column " + column_name + " to drop", + DB::ErrorCodes::ILLEGAL_COLUMN); + } + } + else if (type == MODIFY) + { + const auto default_it = column_defaults.find(column_name); + const auto had_default_expr = default_it != std::end(column_defaults); + const auto old_default_type = had_default_expr ? default_it->second.type : ColumnDefaultType{}; - while (columns.end() != (column_it = std::find_if(columns.begin(), columns.end(), - std::bind(namesEqual, std::cref(column_name), std::placeholders::_1)))) - { - removed = true; - column_it = columns.erase(column_it); - column_defaults.erase(column_name); - } + /// target column list + auto & new_columns = default_type == ColumnDefaultType::Default ? + columns : default_type == ColumnDefaultType::Materialized ? + materialized_columns : alias_columns; - return removed; - }; - - if (!remove_column(columns) && - !remove_column(materialized_columns) && - !remove_column(alias_columns)) - { - throw Exception("Wrong column name. Cannot find column " + column_name + " to drop", + /// find column or throw exception + const auto find_column = [this] (NamesAndTypesList & columns) { + const auto it = std::find_if(columns.begin(), columns.end(), + std::bind(namesEqual, std::cref(column_name), std::placeholders::_1) ); + if (it == columns.end()) + throw Exception("Wrong column name. Cannot find column " + column_name + " to modify", DB::ErrorCodes::ILLEGAL_COLUMN); - } - } - else if (type == MODIFY) - { - const auto default_it = column_defaults.find(column_name); - const auto had_default_expr = default_it != std::end(column_defaults); - const auto old_default_type = had_default_expr ? default_it->second.type : ColumnDefaultType{}; - /// target column list - auto & new_columns = default_type == ColumnDefaultType::Default ? - columns : default_type == ColumnDefaultType::Materialized ? + return it; + }; + + /// if default types differ, remove column from the old list, then add to the new list + if (default_type != old_default_type) + { + /// source column list + auto & old_columns = old_default_type == ColumnDefaultType::Default ? + columns : old_default_type == ColumnDefaultType::Materialized ? materialized_columns : alias_columns; - /// find column or throw exception - const auto find_column = [this] (NamesAndTypesList & columns) { - const auto it = std::find_if(columns.begin(), columns.end(), - std::bind(namesEqual, std::cref(column_name), std::placeholders::_1) ); - if (it == columns.end()) - throw Exception("Wrong column name. Cannot find column " + column_name + " to modify", - DB::ErrorCodes::ILLEGAL_COLUMN); + const auto old_column_it = find_column(old_columns); + new_columns.emplace_back(*old_column_it); + old_columns.erase(old_column_it); - return it; - }; + /// do not forget to change the default type of old column + if (had_default_expr) + column_defaults[column_name].type = default_type; + } - /// if default types differ, remove column from the old list, then add to the new list - if (default_type != old_default_type) + /// find column in one of three column lists + const auto column_it = find_column(new_columns); + column_it->type = data_type; + + if (!default_expression && had_default_expr) + /// new column has no default expression, remove it from column_defaults along with it's type + column_defaults.erase(column_name); + else if (default_expression && !had_default_expr) + /// new column has a default expression while the old one had not, add it it column_defaults + column_defaults.emplace(column_name, ColumnDefault{default_type, default_expression}); + else if (had_default_expr) + /// both old and new columns have default expression, update it + column_defaults[column_name].expression = default_expression; + } + else + throw Exception("Wrong parameter type in ALTER query", ErrorCodes::LOGICAL_ERROR); +} + +void AlterCommands::apply(NamesAndTypesList & columns, + NamesAndTypesList & materialized_columns, + NamesAndTypesList & alias_columns, + ColumnDefaults & column_defaults) const +{ + auto new_columns = columns; + auto new_materialized_columns = materialized_columns; + auto new_alias_columns = alias_columns; + auto new_column_defaults = column_defaults; + + for (const AlterCommand & command : *this) + command.apply(new_columns, new_materialized_columns, new_alias_columns, new_column_defaults); + + columns = std::move(new_columns); + materialized_columns = std::move(new_materialized_columns); + alias_columns = std::move(new_alias_columns); + column_defaults = std::move(new_column_defaults); +} + +void AlterCommands::validate(IStorage * table, const Context & context) +{ + auto columns = table->getColumnsList(); + columns.insert(std::end(columns), std::begin(table->alias_columns), std::end(table->alias_columns)); + auto defaults = table->column_defaults; + + std::vector> defaulted_columns{}; + + ASTPtr default_expr_list{new ASTExpressionList}; + default_expr_list->children.reserve(defaults.size()); + + for (AlterCommand & command : *this) + { + if (command.type == AlterCommand::ADD || command.type == AlterCommand::MODIFY) + { + const auto & column_name = command.column_name; + const auto column_it = std::find_if(std::begin(columns), std::end(columns), + std::bind(AlterCommand::namesEqual, std::cref(command.column_name), std::placeholders::_1)); + + if (command.type == AlterCommand::ADD) + { + if (std::end(columns) != column_it) + throw Exception{ + "Cannot add column " + column_name + ": column with this name already exisits", + DB::ErrorCodes::ILLEGAL_COLUMN + }; + } + else if (command.type == AlterCommand::MODIFY) { - /// source column list - auto & old_columns = old_default_type == ColumnDefaultType::Default ? - columns : old_default_type == ColumnDefaultType::Materialized ? - materialized_columns : alias_columns; - const auto old_column_it = find_column(old_columns); - new_columns.emplace_back(*old_column_it); - old_columns.erase(old_column_it); + if (std::end(columns) == column_it) + throw Exception{ + "Wrong column name. Cannot find column " + column_name + " to modify", + DB::ErrorCodes::ILLEGAL_COLUMN + }; - /// do not forget to change the default type of old column - if (had_default_expr) - column_defaults[column_name].type = default_type; + columns.erase(column_it); + defaults.erase(column_name); } - /// find column in one of three column lists - const auto column_it = find_column(new_columns); - column_it->type = data_type; + /// we're creating dummy DataTypeUInt8 in order to prevent the NullPointerException in ExpressionActions + columns.emplace_back(column_name, command.data_type ? command.data_type : new DataTypeUInt8); - if (!default_expression && had_default_expr) - /// new column has no default expression, remove it from column_defaults along with it's type - column_defaults.erase(column_name); - else if (default_expression && !had_default_expr) - /// new column has a default expression while the old one had not, add it it column_defaults - column_defaults.emplace(column_name, ColumnDefault{default_type, default_expression}); - else if (had_default_expr) - /// both old and new columns have default expression, update it - column_defaults[column_name].expression = default_expression; + if (command.default_expression) + { + if (command.data_type) + { + const auto & final_column_name = column_name; + const auto tmp_column_name = final_column_name + "_tmp"; + const auto column_type_raw_ptr = command.data_type.get(); + + default_expr_list->children.emplace_back(setAlias( + makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, + ASTPtr{new ASTLiteral{{}, column_type_raw_ptr->getName()}}), + final_column_name)); + + default_expr_list->children.emplace_back(setAlias(command.default_expression->clone(), tmp_column_name)); + + defaulted_columns.emplace_back(NameAndTypePair{column_name, command.data_type}, &command); + } + else + { + /// no type explicitly specified, will deduce later + default_expr_list->children.emplace_back( + setAlias(command.default_expression->clone(), column_name)); + + defaulted_columns.emplace_back(NameAndTypePair{column_name, nullptr}, &command); + } + } + } + else if (command.type == AlterCommand::DROP) + { + auto found = false; + for (auto it = std::begin(columns); it != std::end(columns);) + if (AlterCommand::namesEqual(command.column_name, *it)) + { + found = true; + it = columns.erase(it); + } + else + ++it; + + for (auto it = std::begin(defaults); it != std::end(defaults);) + if (AlterCommand::namesEqual(command.column_name, { it->first, nullptr })) + it = defaults.erase(it); + else + ++it; + + if (!found) + throw Exception("Wrong column name. Cannot find column " + command.column_name + " to drop", + DB::ErrorCodes::ILLEGAL_COLUMN); + } + } + + /** Existing defaulted columns may require default expression extensions with a type conversion, + * therefore we add them to defaulted_columns to allow further processing */ + for (const auto & col_def : defaults) + { + const auto & column_name = col_def.first; + const auto column_it = std::find_if(columns.begin(), columns.end(), [&] (const NameAndTypePair & name_type) { + return AlterCommand::namesEqual(column_name, name_type); + }); + const auto tmp_column_name = column_name + "_tmp"; + const auto & column_type_ptr = column_it->type; + + default_expr_list->children.emplace_back(setAlias( + makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, + ASTPtr{new ASTLiteral{{}, column_type_ptr->getName()}}), + column_name)); + + default_expr_list->children.emplace_back(setAlias(col_def.second.expression->clone(), tmp_column_name)); + + defaulted_columns.emplace_back(NameAndTypePair{column_name, column_type_ptr}, nullptr); + } + + const auto actions = ExpressionAnalyzer{default_expr_list, context, {}, columns}.getActions(true); + const auto block = actions->getSampleBlock(); + + /// set deduced types, modify default expression if necessary + for (auto & defaulted_column : defaulted_columns) + { + const auto & name_and_type = defaulted_column.first; + AlterCommand * & command_ptr = defaulted_column.second; + + const auto & column_name = name_and_type.name; + const auto has_explicit_type = nullptr != name_and_type.type; + + /// default expression on old column + if (has_explicit_type) + { + const auto & explicit_type = name_and_type.type; + const auto & tmp_column = block.getByName(column_name + "_tmp"); + const auto & deduced_type = tmp_column.type; + + // column not specified explicitly in the ALTER query may require default_expression modification + if (explicit_type->getName() != deduced_type->getName()) + { + const auto default_it = defaults.find(column_name); + + /// column has no associated alter command, let's create it + if (!command_ptr) + { + /// add a new alter command to modify existing column + this->emplace_back(AlterCommand{ + AlterCommand::MODIFY, column_name, explicit_type, + default_it->second.type, default_it->second.expression + }); + + command_ptr = &this->back(); + } + + command_ptr->default_expression = makeASTFunction("CAST", command_ptr->default_expression->clone(), + ASTPtr{new ASTLiteral{{}, explicit_type->getName()}}); + } } else - throw Exception("Wrong parameter type in ALTER query", ErrorCodes::LOGICAL_ERROR); - } - - void AlterCommands::apply(NamesAndTypesList & columns, - NamesAndTypesList & materialized_columns, - NamesAndTypesList & alias_columns, - ColumnDefaults & column_defaults) const - { - auto new_columns = columns; - auto new_materialized_columns = materialized_columns; - auto new_alias_columns = alias_columns; - auto new_column_defaults = column_defaults; - - for (const AlterCommand & command : *this) - command.apply(new_columns, new_materialized_columns, new_alias_columns, new_column_defaults); - - columns = std::move(new_columns); - materialized_columns = std::move(new_materialized_columns); - alias_columns = std::move(new_alias_columns); - column_defaults = std::move(new_column_defaults); - } - - void AlterCommands::validate(IStorage * table, const Context & context) - { - auto columns = table->getColumnsList(); - columns.insert(std::end(columns), std::begin(table->alias_columns), std::end(table->alias_columns)); - auto defaults = table->column_defaults; - - std::vector> defaulted_columns{}; - - ASTPtr default_expr_list{new ASTExpressionList}; - default_expr_list->children.reserve(defaults.size()); - - for (AlterCommand & command : *this) { - if (command.type == AlterCommand::ADD || command.type == AlterCommand::MODIFY) - { - const auto & column_name = command.column_name; - const auto column_it = std::find_if(std::begin(columns), std::end(columns), - std::bind(AlterCommand::namesEqual, std::cref(command.column_name), std::placeholders::_1)); - - if (command.type == AlterCommand::ADD) - { - if (std::end(columns) != column_it) - throw Exception{ - "Cannot add column " + column_name + ": column with this name already exisits", - DB::ErrorCodes::ILLEGAL_COLUMN - }; - } - else if (command.type == AlterCommand::MODIFY) - { - - if (std::end(columns) == column_it) - throw Exception{ - "Wrong column name. Cannot find column " + column_name + " to modify", - DB::ErrorCodes::ILLEGAL_COLUMN - }; - - columns.erase(column_it); - defaults.erase(column_name); - } - - /// we're creating dummy DataTypeUInt8 in order to prevent the NullPointerException in ExpressionActions - columns.emplace_back(column_name, command.data_type ? command.data_type : new DataTypeUInt8); - - if (command.default_expression) - { - if (command.data_type) - { - const auto & final_column_name = column_name; - const auto tmp_column_name = final_column_name + "_tmp"; - const auto column_type_raw_ptr = command.data_type.get(); - - default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, - ASTPtr{new ASTLiteral{{}, column_type_raw_ptr->getName()}}), - final_column_name)); - - default_expr_list->children.emplace_back(setAlias(command.default_expression->clone(), tmp_column_name)); - - defaulted_columns.emplace_back(NameAndTypePair{column_name, command.data_type}, &command); - } - else - { - /// no type explicitly specified, will deduce later - default_expr_list->children.emplace_back( - setAlias(command.default_expression->clone(), column_name)); - - defaulted_columns.emplace_back(NameAndTypePair{column_name, nullptr}, &command); - } - } - } - else if (command.type == AlterCommand::DROP) - { - auto found = false; - for (auto it = std::begin(columns); it != std::end(columns);) - if (AlterCommand::namesEqual(command.column_name, *it)) - { - found = true; - it = columns.erase(it); - } - else - ++it; - - for (auto it = std::begin(defaults); it != std::end(defaults);) - if (AlterCommand::namesEqual(command.column_name, { it->first, nullptr })) - it = defaults.erase(it); - else - ++it; - - if (!found) - throw Exception("Wrong column name. Cannot find column " + command.column_name + " to drop", - DB::ErrorCodes::ILLEGAL_COLUMN); - } - } - - /** Existing defaulted columns may require default expression extensions with a type conversion, - * therefore we add them to defaulted_columns to allow further processing */ - for (const auto & col_def : defaults) - { - const auto & column_name = col_def.first; - const auto column_it = std::find_if(columns.begin(), columns.end(), [&] (const NameAndTypePair & name_type) { - return AlterCommand::namesEqual(column_name, name_type); - }); - const auto tmp_column_name = column_name + "_tmp"; - const auto & column_type_ptr = column_it->type; - - default_expr_list->children.emplace_back(setAlias( - makeASTFunction("CAST", ASTPtr{new ASTIdentifier{{}, tmp_column_name}}, - ASTPtr{new ASTLiteral{{}, column_type_ptr->getName()}}), - column_name)); - - default_expr_list->children.emplace_back(setAlias(col_def.second.expression->clone(), tmp_column_name)); - - defaulted_columns.emplace_back(NameAndTypePair{column_name, column_type_ptr}, nullptr); - } - - const auto actions = ExpressionAnalyzer{default_expr_list, context, {}, columns}.getActions(true); - const auto block = actions->getSampleBlock(); - - /// set deduced types, modify default expression if necessary - for (auto & defaulted_column : defaulted_columns) - { - const auto & name_and_type = defaulted_column.first; - AlterCommand * & command_ptr = defaulted_column.second; - - const auto & column_name = name_and_type.name; - const auto has_explicit_type = nullptr != name_and_type.type; - - /// default expression on old column - if (has_explicit_type) - { - const auto & explicit_type = name_and_type.type; - const auto & tmp_column = block.getByName(column_name + "_tmp"); - const auto & deduced_type = tmp_column.type; - - // column not specified explicitly in the ALTER query may require default_expression modification - if (explicit_type->getName() != deduced_type->getName()) - { - const auto default_it = defaults.find(column_name); - - /// column has no associated alter command, let's create it - if (!command_ptr) - { - /// add a new alter command to modify existing column - this->emplace_back(AlterCommand{ - AlterCommand::MODIFY, column_name, explicit_type, - default_it->second.type, default_it->second.expression - }); - - command_ptr = &this->back(); - } - - command_ptr->default_expression = makeASTFunction("CAST", command_ptr->default_expression->clone(), - ASTPtr{new ASTLiteral{{}, explicit_type->getName()}}); - } - } - else - { - /// just set deduced type - command_ptr->data_type = block.getByName(column_name).type; - } + /// just set deduced type + command_ptr->data_type = block.getByName(column_name).type; } } } + +} diff --git a/dbms/src/Storages/ColumnsDescription.cpp b/dbms/src/Storages/ColumnsDescription.cpp index 989c629a4b8..4cd19c9e09a 100644 --- a/dbms/src/Storages/ColumnsDescription.cpp +++ b/dbms/src/Storages/ColumnsDescription.cpp @@ -11,6 +11,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_PARSE_TEXT; +} + template String ColumnsDescription::toString() const diff --git a/dbms/src/Storages/ITableDeclaration.cpp b/dbms/src/Storages/ITableDeclaration.cpp index 033e8aab4df..255d0142c6b 100644 --- a/dbms/src/Storages/ITableDeclaration.cpp +++ b/dbms/src/Storages/ITableDeclaration.cpp @@ -13,6 +13,17 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NO_SUCH_COLUMN_IN_TABLE; + extern const int EMPTY_LIST_OF_COLUMNS_QUERIED; + extern const int COLUMN_QUERIED_MORE_THAN_ONCE; + extern const int TYPE_MISMATCH; + extern const int DUPLICATE_COLUMN; + extern const int NOT_FOUND_COLUMN_IN_BLOCK; +} + + NamesAndTypesList ITableDeclaration::getColumnsList() const { return ext::collection_cast(getColumnsListRange()); diff --git a/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp b/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp index cb2a091d6d5..d9b6e945011 100644 --- a/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp +++ b/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp @@ -6,6 +6,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int BAD_DATA_PART_NAME; +} + + ActiveDataPartSet::ActiveDataPartSet(const Strings & names) { for (const auto & name : names) diff --git a/dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp b/dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp index 33f481ef328..111dd9a9c1b 100644 --- a/dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp +++ b/dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp index 3a71396aec1..5c5f1ca881d 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp @@ -15,6 +15,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ABORTED; +} + /// Не будем соглашаться мерджить куски, если места на диске менее чем во столько раз больше суммарного размера кусков. static const double DISK_USAGE_COEFFICIENT_TO_SELECT = 1.6; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index c74d6bbac42..fd9ea66e10d 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -23,6 +23,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INDEX_NOT_USED; +} + + MergeTreeDataSelectExecutor::MergeTreeDataSelectExecutor(MergeTreeData & data_) : data(data_), log(&Logger::get(data.getLogName() + " (SelectExecutor)")) { diff --git a/dbms/src/Storages/MergeTree/MergeTreePartChecker.cpp b/dbms/src/Storages/MergeTree/MergeTreePartChecker.cpp index 5ed7f94b7b3..5b9bc1b8a5b 100644 --- a/dbms/src/Storages/MergeTree/MergeTreePartChecker.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreePartChecker.cpp @@ -16,6 +16,15 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CORRUPTED_DATA; + extern const int INCORRECT_MARK; + extern const int EMPTY_LIST_OF_COLUMNS_PASSED; + extern const int UNKNOWN_TYPE; +} + + struct Stream { static const size_t UNKNOWN = std::numeric_limits::max(); diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp index 428e8f6ad05..f19280fa8fa 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp @@ -6,6 +6,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NOT_FOUND_NODE; +} + + ReplicatedMergeTreeCleanupThread::ReplicatedMergeTreeCleanupThread(StorageReplicatedMergeTree & storage_) : storage(storage_), log(&Logger::get(storage.database_name + "." + storage.table_name + " (StorageReplicatedMergeTree, CleanupThread)")), diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp b/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp index 3ed08b430be..22b3078237c 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartsExchange.cpp @@ -5,6 +5,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ABORTED; +} + + void ReplicatedMergeTreePartsServer::processQuery(const Poco::Net::HTMLForm & params, WriteBuffer & out) { if (is_cancelled) diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.cpp b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.cpp index 855cd6adbc1..7faf545e754 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.cpp +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.cpp @@ -9,6 +9,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CANNOT_CLOCK_GETTIME; + extern const int REPLICA_IS_ALREADY_ACTIVE; +} + /// Используется для проверки, выставили ли ноду is_active мы, или нет. static String generateActiveNodeIdentifier() diff --git a/dbms/src/Storages/StorageBuffer.cpp b/dbms/src/Storages/StorageBuffer.cpp index e961857f437..3c9151c3cf7 100644 --- a/dbms/src/Storages/StorageBuffer.cpp +++ b/dbms/src/Storages/StorageBuffer.cpp @@ -14,6 +14,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int INFINITE_LOOP; + extern const int BLOCKS_HAS_DIFFERENT_STRUCTURE; +} + StoragePtr StorageBuffer::create(const std::string & name_, NamesAndTypesListPtr columns_, const NamesAndTypesList & materialized_columns_, diff --git a/dbms/src/Storages/StorageChunkMerger.cpp b/dbms/src/Storages/StorageChunkMerger.cpp index 2ed96263139..0ae9d2cac3a 100644 --- a/dbms/src/Storages/StorageChunkMerger.cpp +++ b/dbms/src/Storages/StorageChunkMerger.cpp @@ -16,6 +16,14 @@ namespace DB { + +namespace ErrorCodes +{ + extern const int UNKNOWN_DATABASE; + extern const int TYPE_MISMATCH; +} + + const int NOTHING_TO_MERGE_PERIOD = 10; StorageChunkMerger::TableNames StorageChunkMerger::currently_written_groups; @@ -334,23 +342,9 @@ bool StorageChunkMerger::MergeTask::merge() { merged = maybeMergeSomething(); } - catch (const Exception & e) - { - LOG_ERROR(log, "StorageChunkMerger at " << chunk_merger.this_database << "." << chunk_merger.name << " failed to merge: Code: " << e.code() << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what() - << ", Stack trace:\n\n" << e.getStackTrace().toString()); - } - catch (const Poco::Exception & e) - { - LOG_ERROR(log, "StorageChunkMerger at " << chunk_merger.this_database << "." << chunk_merger.name << " failed to merge: Poco::Exception. Code: " << ErrorCodes::POCO_EXCEPTION << ", e.code() = " << e.code() - << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what()); - } - catch (const std::exception & e) - { - LOG_ERROR(log, "StorageChunkMerger at " << chunk_merger.this_database << "." << chunk_merger.name << " failed to merge: std::exception. Code: " << ErrorCodes::STD_EXCEPTION << ", e.what() = " << e.what()); - } catch (...) { - LOG_ERROR(log, "StorageChunkMerger at " << chunk_merger.this_database << "." << chunk_merger.name << " failed to merge: unknown exception. Code: " << ErrorCodes::UNKNOWN_EXCEPTION); + tryLogCurrentException(log, "StorageChunkMerger at " + chunk_merger.this_database + "." + chunk_merger.name + " failed to merge"); } if (!merged) diff --git a/dbms/src/Storages/StorageChunkRef.cpp b/dbms/src/Storages/StorageChunkRef.cpp index 040636dd022..27a5d4d9299 100644 --- a/dbms/src/Storages/StorageChunkRef.cpp +++ b/dbms/src/Storages/StorageChunkRef.cpp @@ -7,6 +7,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNKNOWN_TABLE; +} + + StoragePtr StorageChunkRef::create(const std::string & name_, const Context & context_, const std::string & source_database_name_, const std::string & source_table_name_, bool attach) { return (new StorageChunkRef(name_, context_, source_database_name_, source_table_name_, attach))->thisPtr(); diff --git a/dbms/src/Storages/StorageChunks.cpp b/dbms/src/Storages/StorageChunks.cpp index 139c6f85409..fe3fd5b82df 100644 --- a/dbms/src/Storages/StorageChunks.cpp +++ b/dbms/src/Storages/StorageChunks.cpp @@ -15,6 +15,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int CHUNK_NOT_FOUND; + extern const int DUPLICATE_CHUNK_NAME; + extern const int SIZES_OF_MARKS_FILES_ARE_INCONSISTENT; +} + + StoragePtr StorageChunks::create( const std::string & path_, const std::string & name_, diff --git a/dbms/src/Storages/StorageDistributed.cpp b/dbms/src/Storages/StorageDistributed.cpp index 72edb0f3221..106de8192fe 100644 --- a/dbms/src/Storages/StorageDistributed.cpp +++ b/dbms/src/Storages/StorageDistributed.cpp @@ -24,6 +24,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int STORAGE_REQUIRES_PARAMETER; +} + + namespace { /// select query has database and table names as AST pointers diff --git a/dbms/src/Storages/StorageFactory.cpp b/dbms/src/Storages/StorageFactory.cpp index 50ee571929f..59a12090867 100644 --- a/dbms/src/Storages/StorageFactory.cpp +++ b/dbms/src/Storages/StorageFactory.cpp @@ -35,6 +35,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TABLE_MUST_NOT_BE_CREATED_MANUALLY; + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; + extern const int BAD_ARGUMENTS; + extern const int UNKNOWN_STORAGE; + extern const int NO_REPLICA_NAME_GIVEN; +} + + static bool endsWith(const std::string & s, const std::string & suffix) { return s.size() >= suffix.size() && 0 == strncmp(s.data() + s.size() - suffix.size(), suffix.data(), suffix.size()); diff --git a/dbms/src/Storages/StorageJoin.cpp b/dbms/src/Storages/StorageJoin.cpp index ee50eefb8ba..916425d3d26 100644 --- a/dbms/src/Storages/StorageJoin.cpp +++ b/dbms/src/Storages/StorageJoin.cpp @@ -4,6 +4,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NO_SUCH_COLUMN_IN_TABLE; + extern const int INCOMPATIBLE_TYPE_OF_JOIN; +} + StorageJoin::StorageJoin( const String & path_, diff --git a/dbms/src/Storages/StorageLog.cpp b/dbms/src/Storages/StorageLog.cpp index df15b885390..2677deda310 100644 --- a/dbms/src/Storages/StorageLog.cpp +++ b/dbms/src/Storages/StorageLog.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -35,6 +34,14 @@ namespace DB using Poco::SharedPtr; +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; + extern const int EMPTY_LIST_OF_COLUMNS_PASSED; + extern const int DUPLICATE_COLUMN; + extern const int SIZES_OF_MARKS_FILES_ARE_INCONSISTENT; +} + class LogBlockInputStream : public IProfilingBlockInputStream { diff --git a/dbms/src/Storages/StorageMaterializedView.cpp b/dbms/src/Storages/StorageMaterializedView.cpp index 3079bd5974b..3e2f0ab0949 100644 --- a/dbms/src/Storages/StorageMaterializedView.cpp +++ b/dbms/src/Storages/StorageMaterializedView.cpp @@ -11,6 +11,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + + StoragePtr StorageMaterializedView::create( const String & table_name_, const String & database_name_, diff --git a/dbms/src/Storages/StorageMemory.cpp b/dbms/src/Storages/StorageMemory.cpp index 0d22615f67f..06bf2156f0d 100644 --- a/dbms/src/Storages/StorageMemory.cpp +++ b/dbms/src/Storages/StorageMemory.cpp @@ -1,7 +1,6 @@ #include #include -#include #include diff --git a/dbms/src/Storages/StorageMerge.cpp b/dbms/src/Storages/StorageMerge.cpp index 3dd1526264c..de4fc0e7415 100644 --- a/dbms/src/Storages/StorageMerge.cpp +++ b/dbms/src/Storages/StorageMerge.cpp @@ -13,6 +13,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int ILLEGAL_PREWHERE; +} + + StorageMerge::StorageMerge( const std::string & name_, NamesAndTypesListPtr columns_, diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index 3e1722a7ca8..affb82773c5 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -8,9 +8,17 @@ #include #include + namespace DB { +namespace ErrorCodes +{ + extern const int ABORTED; + extern const int BAD_ARGUMENTS; +} + + StorageMergeTree::StorageMergeTree( const String & path_, const String & database_name_, diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 49a610128a2..e074af24909 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -30,6 +30,30 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NO_ZOOKEEPER; + extern const int INCORRECT_DATA; + extern const int INCOMPATIBLE_COLUMNS; + extern const int REPLICA_IS_ALREADY_EXIST; + extern const int NO_SUCH_REPLICA; + extern const int NO_REPLICA_HAS_PART; + extern const int LOGICAL_ERROR; + extern const int TOO_MANY_UNEXPECTED_DATA_PARTS; + extern const int ABORTED; + extern const int REPLICA_IS_NOT_IN_QUORUM; + extern const int TABLE_IS_READ_ONLY; + extern const int NOT_FOUND_NODE; + extern const int NO_ACTIVE_REPLICAS; + extern const int LEADERSHIP_CHANGED; + extern const int TABLE_IS_READ_ONLY; + extern const int TABLE_WAS_NOT_DROPPED; + extern const int PARTITION_ALREADY_EXISTS; + extern const int TOO_MUCH_RETRIES_TO_FETCH_PARTS; + extern const int RECEIVED_ERROR_FROM_REMOTE_IO_SERVER; + extern const int PARTITION_DOESNT_EXIST; +} + const auto ERROR_SLEEP_MS = 1000; const auto MERGE_SELECTING_SLEEP_MS = 5 * 1000; diff --git a/dbms/src/Storages/StorageStripeLog.cpp b/dbms/src/Storages/StorageStripeLog.cpp index 2242c6d46ee..54f61f0134b 100644 --- a/dbms/src/Storages/StorageStripeLog.cpp +++ b/dbms/src/Storages/StorageStripeLog.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -36,6 +35,12 @@ namespace DB #define INDEX_BUFFER_SIZE 4096 +namespace ErrorCodes +{ + extern const int EMPTY_LIST_OF_COLUMNS_PASSED; + extern const int CANNOT_CREATE_DIRECTORY; +} + class StripeLogBlockInputStream : public IProfilingBlockInputStream { diff --git a/dbms/src/Storages/StorageTinyLog.cpp b/dbms/src/Storages/StorageTinyLog.cpp index 52a9689b09a..bce15fde2b5 100644 --- a/dbms/src/Storages/StorageTinyLog.cpp +++ b/dbms/src/Storages/StorageTinyLog.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -34,6 +33,14 @@ namespace DB using Poco::SharedPtr; +namespace ErrorCodes +{ + extern const int EMPTY_LIST_OF_COLUMNS_PASSED; + extern const int CANNOT_CREATE_DIRECTORY; + extern const int CANNOT_READ_ALL_DATA; + extern const int DUPLICATE_COLUMN; +} + class TinyLogBlockInputStream : public IProfilingBlockInputStream { diff --git a/dbms/src/Storages/StorageView.cpp b/dbms/src/Storages/StorageView.cpp index 210c4a37d17..d3df577fd84 100644 --- a/dbms/src/Storages/StorageView.cpp +++ b/dbms/src/Storages/StorageView.cpp @@ -9,6 +9,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + StoragePtr StorageView::create( const String & table_name_, diff --git a/dbms/src/Storages/System/StorageSystemClusters.cpp b/dbms/src/Storages/System/StorageSystemClusters.cpp index 43fee761450..5172f5d4eec 100644 --- a/dbms/src/Storages/System/StorageSystemClusters.cpp +++ b/dbms/src/Storages/System/StorageSystemClusters.cpp @@ -10,6 +10,7 @@ namespace DB { + StorageSystemClusters::StorageSystemClusters(const std::string & name_, Context & context_) : name(name_) , columns{ diff --git a/dbms/src/Storages/System/StorageSystemNumbers.cpp b/dbms/src/Storages/System/StorageSystemNumbers.cpp index 7a05fdfbbb8..b163c85060f 100644 --- a/dbms/src/Storages/System/StorageSystemNumbers.cpp +++ b/dbms/src/Storages/System/StorageSystemNumbers.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include #include diff --git a/dbms/src/Storages/System/StorageSystemOne.cpp b/dbms/src/Storages/System/StorageSystemOne.cpp index 5e92d99517e..f346101e68b 100644 --- a/dbms/src/Storages/System/StorageSystemOne.cpp +++ b/dbms/src/Storages/System/StorageSystemOne.cpp @@ -1,5 +1,4 @@ #include -#include #include #include diff --git a/dbms/src/Storages/System/StorageSystemTables.cpp b/dbms/src/Storages/System/StorageSystemTables.cpp index 1e4d673c7c8..a08ac735cef 100644 --- a/dbms/src/Storages/System/StorageSystemTables.cpp +++ b/dbms/src/Storages/System/StorageSystemTables.cpp @@ -8,6 +8,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + StorageSystemTables::StorageSystemTables(const std::string & name_) : name(name_), diff --git a/dbms/src/Storages/VirtualColumnFactory.cpp b/dbms/src/Storages/VirtualColumnFactory.cpp index 58ebb99ee45..581e5886be2 100644 --- a/dbms/src/Storages/VirtualColumnFactory.cpp +++ b/dbms/src/Storages/VirtualColumnFactory.cpp @@ -6,6 +6,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int NO_SUCH_COLUMN_IN_TABLE; +} + + DataTypePtr VirtualColumnFactory::getType(const String & name) { auto res = tryGetType(name); diff --git a/dbms/src/TableFunctions/TableFunctionFactory.cpp b/dbms/src/TableFunctions/TableFunctionFactory.cpp index f1df2cd4194..2a8497c7800 100644 --- a/dbms/src/TableFunctions/TableFunctionFactory.cpp +++ b/dbms/src/TableFunctions/TableFunctionFactory.cpp @@ -7,6 +7,12 @@ namespace DB { +namespace ErrorCodes +{ + extern const int READONLY; + extern const int UNKNOWN_FUNCTION; +} + TableFunctionPtr TableFunctionFactory::get( const String & name, diff --git a/libs/libzkutil/include/zkutil/KeeperException.h b/libs/libzkutil/include/zkutil/KeeperException.h index 96fae823c36..acc6a076351 100644 --- a/libs/libzkutil/include/zkutil/KeeperException.h +++ b/libs/libzkutil/include/zkutil/KeeperException.h @@ -2,7 +2,16 @@ #include #include #include -#include + + +namespace DB +{ + namespace ErrorCodes + { + extern const int KEEPER_EXCEPTION; + } +} + namespace zkutil { From c062fc1ce0367ea500a0b003c18c41b34c8d212e Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 12 Jan 2016 05:21:15 +0300 Subject: [PATCH 15/66] dbms: cutting dependency [#METR-2944]. --- .../AggregateFunctionGroupArray.h | 5 + .../AggregateFunctionSequenceMatch.h | 8 + .../AggregateFunctions/IAggregateFunction.h | 1 + .../ReservoirSamplerDeterministic.h | 10 + dbms/include/DB/Common/StringSearcher.h | 6 + .../include/DB/Dictionaries/CacheDictionary.h | 8 + .../Dictionaries/ClickHouseDictionarySource.h | 6 + .../Dictionaries/ComplexKeyCacheDictionary.h | 8 + .../Dictionaries/ComplexKeyHashedDictionary.h | 8 + .../DB/Dictionaries/DictionarySourceFactory.h | 7 + .../DB/Dictionaries/DictionaryStructure.h | 1 + dbms/include/DB/Dictionaries/FlatDictionary.h | 9 + .../DB/Dictionaries/HashedDictionary.h | 9 + .../DB/Dictionaries/MongoDBDictionarySource.h | 8 + .../DB/Dictionaries/MySQLBlockInputStream.h | 5 + .../DB/Dictionaries/MySQLDictionarySource.h | 5 + .../DB/Functions/FunctionsArithmetic.h | 6 + .../DB/Functions/FunctionsConversion.h | 5 + .../DB/Functions/FunctionsDictionaries.h | 5 + .../DB/Functions/FunctionsHigherOrder.h | 5 + dbms/include/DB/Functions/FunctionsRandom.h | 5 + dbms/include/DB/Functions/IFunction.h | 1 + dbms/include/DB/IO/RemoteWriteBuffer.h | 30 +- .../AggregateFunctionFactory.cpp | 8 + dbms/src/Client/Client.cpp | 16 + dbms/src/Client/MultiplexedConnections.cpp | 9 + dbms/src/Core/ErrorCodes.cpp | 610 +++++++++--------- dbms/src/Functions/FunctionFactory.cpp | 6 + dbms/src/Interpreters/Cluster.cpp | 8 + dbms/src/Interpreters/DictionaryFactory.cpp | 8 + dbms/src/Interpreters/Join.cpp | 14 +- dbms/src/Interpreters/Set.cpp | 18 +- dbms/src/Interpreters/Settings.cpp | 8 + dbms/src/Server/InterserverIOHTTPHandler.cpp | 8 + dbms/src/Server/OLAPHTTPHandler.cpp | 8 + dbms/src/Server/OLAPQueryConverter.cpp | 147 +++-- dbms/src/Server/OLAPQueryParser.cpp | 1 + 37 files changed, 637 insertions(+), 393 deletions(-) diff --git a/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h b/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h index 68aca9f1939..31e581c8724 100644 --- a/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h +++ b/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h @@ -17,6 +17,11 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_LARGE_ARRAY_SIZE; +} + /// Частный случай - реализация для числовых типов. template diff --git a/dbms/include/DB/AggregateFunctions/AggregateFunctionSequenceMatch.h b/dbms/include/DB/AggregateFunctions/AggregateFunctionSequenceMatch.h index 15acd585c61..bd51ec6006b 100644 --- a/dbms/include/DB/AggregateFunctions/AggregateFunctionSequenceMatch.h +++ b/dbms/include/DB/AggregateFunctions/AggregateFunctionSequenceMatch.h @@ -15,6 +15,14 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_SLOW; + extern const int TOO_LESS_ARGUMENTS_FOR_FUNCTION; + extern const int TOO_MUCH_ARGUMENTS_FOR_FUNCTION; + extern const int SYNTAX_ERROR; +} + /// helper type for comparing `std::pair`s using solely the .first member template