From b4bf53dfc9a6668b723ad45f2d14472ee6ed80a3 Mon Sep 17 00:00:00 2001 From: TCeason Date: Fri, 16 Apr 2021 09:42:55 +0800 Subject: [PATCH] add some comment and modify a parameter type --- src/Core/Settings.h | 4 ++-- src/Formats/MySQLBlockInputStream.cpp | 2 +- src/Formats/MySQLBlockInputStream.h | 3 ++- src/Storages/StorageMySQL.cpp | 4 +--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Core/Settings.h b/src/Core/Settings.h index be3a7ce739b..2b0815291b5 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -445,8 +445,8 @@ class IColumn; M(Bool, database_replicated_always_detach_permanently, false, "Execute DETACH TABLE as DETACH TABLE PERMANENTLY if database engine is Replicated", 0) \ M(DistributedDDLOutputMode, distributed_ddl_output_mode, DistributedDDLOutputMode::THROW, "Format of distributed DDL query result", 0) \ M(UInt64, distributed_ddl_entry_format_version, 1, "Version of DDL entry to write into ZooKeeper", 0) \ - M(UInt64, external_storage_max_read_rows, 0, "Limit maximum number of rows when MaterializeMySQL should flush history data. If equal to 0, this setting is disabled", 0) \ - M(UInt64, external_storage_max_read_bytes, (DEFAULT_INSERT_BLOCK_SIZE * 256), "Limit maximum number of bytes when MaterializeMySQL should flush history data. If equal to 0, this setting is disabled", 0) \ + M(UInt64, external_storage_max_read_rows, 0, "Limit maximum number of rows when table with external engine should flush history data. Now supported only for MySQL table engine, database engine, dictionary and MaterializeMySQL. If equal to 0, this setting is disabled", 0) \ + M(UInt64, external_storage_max_read_bytes, 0, "Limit maximum number of bytes when table with external engine should flush history data. Now supported only for MySQL table engine, database engine, dictionary and MaterializeMySQL. If equal to 0, this setting is disabled", 0) \ \ /** Obsolete settings that do nothing but left for compatibility reasons. Remove each one after half a year of obsolescence. */ \ \ diff --git a/src/Formats/MySQLBlockInputStream.cpp b/src/Formats/MySQLBlockInputStream.cpp index 445b159dc4b..be0cb31f22d 100644 --- a/src/Formats/MySQLBlockInputStream.cpp +++ b/src/Formats/MySQLBlockInputStream.cpp @@ -31,7 +31,7 @@ namespace ErrorCodes } StreamSettings::StreamSettings(const Settings & settings, bool auto_close_, bool fetch_by_name_, size_t max_retry_) - : max_read_mysql_row_nums(settings.external_storage_max_read_rows) + : max_read_mysql_row_nums((settings.external_storage_max_read_rows) ? settings.external_storage_max_read_rows : settings.max_block_size) , max_read_mysql_bytes_size(settings.external_storage_max_read_bytes) , auto_close(auto_close_) , fetch_by_name(fetch_by_name_) diff --git a/src/Formats/MySQLBlockInputStream.h b/src/Formats/MySQLBlockInputStream.h index 4190addc71d..12deb9c3146 100644 --- a/src/Formats/MySQLBlockInputStream.h +++ b/src/Formats/MySQLBlockInputStream.h @@ -13,6 +13,7 @@ namespace DB struct StreamSettings { + /// Check if setting is enabled, otherwise use common `max_block_size` setting. size_t max_read_mysql_row_nums; size_t max_read_mysql_bytes_size; bool auto_close; @@ -38,7 +39,7 @@ public: Block getHeader() const override { return description.sample_block.cloneEmpty(); } protected: - MySQLBlockInputStream(const Block & sample_block_, const struct StreamSettings & settings); + MySQLBlockInputStream(const Block & sample_block_, const StreamSettings & settings); Block readImpl() override; void initPositionMappingFromQueryResultStructure(); diff --git a/src/Storages/StorageMySQL.cpp b/src/Storages/StorageMySQL.cpp index 984682ac0a4..bc07679a0de 100644 --- a/src/Storages/StorageMySQL.cpp +++ b/src/Storages/StorageMySQL.cpp @@ -71,7 +71,7 @@ Pipe StorageMySQL::read( SelectQueryInfo & query_info_, ContextPtr context_, QueryProcessingStage::Enum /*processed_stage*/, - size_t max_block_size, + size_t /*max_block_size*/, unsigned) { metadata_snapshot->check(column_names_, getVirtuals(), getStorageID()); @@ -95,8 +95,6 @@ Pipe StorageMySQL::read( sample_block.insert({ column_data.type, column_data.name }); } - if (!context_->getSettingsRef().external_storage_max_read_rows) - context_->setSetting("external_storage_max_read_rows", max_block_size); StreamSettings mysql_input_stream_settings(context_->getSettingsRef(), true, false); return Pipe(std::make_shared(