From 60dc8fcac245d15aac1b8b3b8edb8cef4b7deb14 Mon Sep 17 00:00:00 2001 From: chertus Date: Thu, 6 Dec 2018 20:20:17 +0300 Subject: [PATCH] fixes for review CLICKHOUSE-3578 --- dbms/src/Client/Connection.cpp | 2 +- dbms/src/Core/Protocol.h | 2 +- dbms/src/DataStreams/AddingDefaultsBlockInputStream.cpp | 4 ++-- dbms/src/DataStreams/AddingMissedBlockInputStream.h | 2 +- dbms/src/Formats/IRowInputStream.h | 7 +++---- dbms/src/Storages/ColumnDefault.h | 3 --- dbms/src/Storages/ColumnsDescription.cpp | 2 -- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dbms/src/Client/Connection.cpp b/dbms/src/Client/Connection.cpp index 82c76324a40..923c8179ca1 100644 --- a/dbms/src/Client/Connection.cpp +++ b/dbms/src/Client/Connection.cpp @@ -718,7 +718,7 @@ std::unique_ptr Connection::receiveException() std::vector Connection::receiveMultistringMessage(UInt64 msg_type) { - size_t num = Protocol::Server::wordsInMessage(msg_type); + size_t num = Protocol::Server::stringsInMessage(msg_type); std::vector out(num); for (size_t i = 0; i < num; ++i) readStringBinary(out[i], *in); diff --git a/dbms/src/Core/Protocol.h b/dbms/src/Core/Protocol.h index 28f60cce901..b50d018f9ce 100644 --- a/dbms/src/Core/Protocol.h +++ b/dbms/src/Core/Protocol.h @@ -86,7 +86,7 @@ namespace Protocol : "Unknown packet"; } - inline size_t wordsInMessage(UInt64 msg_type) + inline size_t stringsInMessage(UInt64 msg_type) { switch (msg_type) { diff --git a/dbms/src/DataStreams/AddingDefaultsBlockInputStream.cpp b/dbms/src/DataStreams/AddingDefaultsBlockInputStream.cpp index 9ee6b15e1b9..6b959cbc05b 100644 --- a/dbms/src/DataStreams/AddingDefaultsBlockInputStream.cpp +++ b/dbms/src/DataStreams/AddingDefaultsBlockInputStream.cpp @@ -118,12 +118,12 @@ void AddingDefaultsBlockInputStream::checkCalculated(const ColumnWithTypeAndName size_t column_size = col_read.column->size(); if (column_size != col_defaults.column->size()) - throw Exception("Mismach column sizes while adding defaults", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); + throw Exception("Mismatch column sizes while adding defaults", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); if (column_size < defaults_needed) throw Exception("Unexpected defaults count", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); - if (col_read.type->getTypeId() != col_defaults.type->getTypeId()) + if (!col_read.type->equals(*col_defaults.type)) throw Exception("Mismach column types while adding defaults", ErrorCodes::TYPE_MISMATCH); } diff --git a/dbms/src/DataStreams/AddingMissedBlockInputStream.h b/dbms/src/DataStreams/AddingMissedBlockInputStream.h index 07b37a56d22..b3b98509645 100644 --- a/dbms/src/DataStreams/AddingMissedBlockInputStream.h +++ b/dbms/src/DataStreams/AddingMissedBlockInputStream.h @@ -23,7 +23,7 @@ public: const ColumnDefaults & column_defaults_, const Context & context_); - String getName() const override { return "AddingDefault"; } + String getName() const override { return "AddingMissed"; } Block getHeader() const override { return header; } private: diff --git a/dbms/src/Formats/IRowInputStream.h b/dbms/src/Formats/IRowInputStream.h index 65b98d2524f..045b2343e44 100644 --- a/dbms/src/Formats/IRowInputStream.h +++ b/dbms/src/Formats/IRowInputStream.h @@ -10,12 +10,11 @@ namespace DB { -/// A way to set some extentions to read and return extra information too. IRowInputStream.extendedRead() output. +/// Contains extra information about read data. struct RowReadExtension { - /// IRowInputStream.extendedRead() output value. - /// Contains one bit per column in resently read row. IRowInputStream could leave it empty, or partialy set. - /// It should contain true for columns that actually read from the source and false for defaults. + /// IRowInputStream.read() output. It contains non zero for columns that actually read from the source and zero otherwise. + /// It's used to attach defaults for partially filled rows. std::vector read_columns; }; diff --git a/dbms/src/Storages/ColumnDefault.h b/dbms/src/Storages/ColumnDefault.h index 292c0cf7495..0667ce4ed57 100644 --- a/dbms/src/Storages/ColumnDefault.h +++ b/dbms/src/Storages/ColumnDefault.h @@ -9,9 +9,6 @@ namespace DB { -class Context; -class Block; - enum class ColumnDefaultKind { Default, diff --git a/dbms/src/Storages/ColumnsDescription.cpp b/dbms/src/Storages/ColumnsDescription.cpp index 049845b75ec..0926fef14e8 100644 --- a/dbms/src/Storages/ColumnsDescription.cpp +++ b/dbms/src/Storages/ColumnsDescription.cpp @@ -221,8 +221,6 @@ const ColumnsDescription * ColumnsDescription::loadFromContext(const Context & c { if (context.getSettingsRef().insert_sample_with_metadata) { - auto db_and_table = context.getInsertionTable(); - if (context.isTableExist(db, table)) { StoragePtr storage = context.getTable(db, table);