From 5282a20abad41f00c87a850166f972692308fc76 Mon Sep 17 00:00:00 2001 From: MikhailBurdukov Date: Thu, 6 Apr 2023 15:50:28 +0000 Subject: [PATCH 1/2] Test and fix --- src/Core/SettingsFields.h | 4 +- ...2705_settings_check_changed_flag.reference | 32 ++++++++ .../02705_settings_check_changed_flag.sql | 82 +++++++++++++++++++ 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/02705_settings_check_changed_flag.reference create mode 100644 tests/queries/0_stateless/02705_settings_check_changed_flag.sql diff --git a/src/Core/SettingsFields.h b/src/Core/SettingsFields.h index 3994e402c9a..2cd55e6b4c5 100644 --- a/src/Core/SettingsFields.h +++ b/src/Core/SettingsFields.h @@ -453,8 +453,8 @@ struct SettingFieldMultiEnum explicit operator StorageType() const { return value.getValue(); } explicit operator Field() const { return toString(); } - SettingFieldMultiEnum & operator= (StorageType x) { changed = x != value.getValue(); value.setValue(x); return *this; } - SettingFieldMultiEnum & operator= (ValueType x) { changed = !(x == value); value = x; return *this; } + SettingFieldMultiEnum & operator= (StorageType x) { changed = true; value.setValue(x); return *this; } + SettingFieldMultiEnum & operator= (ValueType x) { changed = true; value = x; return *this; } SettingFieldMultiEnum & operator= (const Field & x) { parseFromString(x.safeGet()); return *this; } String toString() const diff --git a/tests/queries/0_stateless/02705_settings_check_changed_flag.reference b/tests/queries/0_stateless/02705_settings_check_changed_flag.reference new file mode 100644 index 00000000000..58a93072157 --- /dev/null +++ b/tests/queries/0_stateless/02705_settings_check_changed_flag.reference @@ -0,0 +1,32 @@ +0 +1 +1 +1 +0 +1 +1 +1 +0 +1 +1 +1 +0 +1 +1 +1 +0 +1 +1 +1 +0 +1 +1 +1 +0 +1 +1 +1 +0 +1 +1 +1 diff --git a/tests/queries/0_stateless/02705_settings_check_changed_flag.sql b/tests/queries/0_stateless/02705_settings_check_changed_flag.sql new file mode 100644 index 00000000000..151e7a66b71 --- /dev/null +++ b/tests/queries/0_stateless/02705_settings_check_changed_flag.sql @@ -0,0 +1,82 @@ +---SettingFieldNumber +SELECT changed from system.settings where name = 'mysql_max_rows_to_insert'; +SET mysql_max_rows_to_insert = 123123; + +select changed from system.settings where name = 'mysql_max_rows_to_insert'; +set mysql_max_rows_to_insert = 123123; +select changed from system.settings where name = 'mysql_max_rows_to_insert'; +set mysql_max_rows_to_insert = 65536; +select changed from system.settings where name = 'mysql_max_rows_to_insert'; + +---SettingAutoWrapper + +select changed from system.settings where name = 'insert_quorum'; +set insert_quorum = 123123; +select changed from system.settings where name = 'insert_quorum'; +set insert_quorum = 123123; +select changed from system.settings where name = 'insert_quorum'; +set insert_quorum = 0; +select changed from system.settings where name = 'insert_quorum'; + +---SettingFieldMaxThreads + +select changed from system.settings where name = 'max_alter_threads'; +set max_alter_threads = 123123; +select changed from system.settings where name = 'max_alter_threads'; +set max_alter_threads = 123123; +select changed from system.settings where name = 'max_alter_threads'; +set max_alter_threads = 0; +select changed from system.settings where name = 'max_alter_threads'; + +---SettingFieldTimespanUnit + +select changed from system.settings where name = 'drain_timeout'; +set drain_timeout = 123123; +select changed from system.settings where name = 'drain_timeout'; +set drain_timeout = 123123; +select changed from system.settings where name = 'drain_timeout'; +set drain_timeout = 3; +select changed from system.settings where name = 'drain_timeout'; + + +---SettingFieldChar + +select changed from system.settings where name = 'format_csv_delimiter'; +set format_csv_delimiter = ','; +select changed from system.settings where name = 'format_csv_delimiter'; +set format_csv_delimiter = ','; +select changed from system.settings where name = 'format_csv_delimiter'; +set format_csv_delimiter = ','; +select changed from system.settings where name = 'format_csv_delimiter'; + + +---SettingFieldURI + +select changed from system.settings where name = 'format_avro_schema_registry_url'; +set format_avro_schema_registry_url = 'https://github.com/ClickHouse/ClickHouse/tree/master/src/Core'; +select changed from system.settings where name = 'format_avro_schema_registry_url'; +set format_avro_schema_registry_url = 'https://github.com/ClickHouse/ClickHouse/tree/master/src/Core'; +select changed from system.settings where name = 'format_avro_schema_registry_url'; +set format_avro_schema_registry_url = ''; +select changed from system.settings where name = 'format_avro_schema_registry_url'; + + +--- SettingFieldEnum + +select changed from system.settings where name = 'output_format_orc_compression_method'; +set output_format_orc_compression_method = 'none'; +select changed from system.settings where name = 'output_format_orc_compression_method'; +set output_format_orc_compression_method = 'none'; +select changed from system.settings where name = 'output_format_orc_compression_method'; +set output_format_orc_compression_method = 'lz4'; +select changed from system.settings where name = 'output_format_orc_compression_method'; + +--- SettingFieldMultiEnum + +select changed from system.settings where name = 'join_algorithm'; +set join_algorithm = 'auto,direct'; +select changed from system.settings where name = 'join_algorithm'; +set join_algorithm = 'auto,direct'; +select changed from system.settings where name = 'join_algorithm'; +set join_algorithm = 'default'; +select changed from system.settings where name = 'join_algorithm'; From 54d7a412ec85fdedaf0ac2ce4ebdce05d0026868 Mon Sep 17 00:00:00 2001 From: MikhailBurdukov Date: Fri, 7 Apr 2023 11:04:00 +0000 Subject: [PATCH 2/2] Fixed unit tests --- src/Core/tests/gtest_settings.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Core/tests/gtest_settings.cpp b/src/Core/tests/gtest_settings.cpp index 46d8f9665dc..cbeb84ef2e7 100644 --- a/src/Core/tests/gtest_settings.cpp +++ b/src/Core/tests/gtest_settings.cpp @@ -122,7 +122,7 @@ GTEST_TEST(SettingMySQLDataTypesSupport, SetString) // comma with spaces setting = " datetime64 , decimal "; - ASSERT_FALSE(setting.changed); // false since value is the same as previous one. + ASSERT_TRUE(setting.changed); ASSERT_TRUE(setting.value.isSet(MySQLDataTypesSupport::DECIMAL)); ASSERT_TRUE(setting.value.isSet(MySQLDataTypesSupport::DATETIME64)); ASSERT_EQ("decimal,datetime64", setting.toString()); @@ -136,7 +136,7 @@ GTEST_TEST(SettingMySQLDataTypesSupport, SetString) ASSERT_EQ(Field("decimal"), setting); setting = String(",decimal,decimal,decimal,decimal,decimal,decimal,decimal,decimal,decimal,"); - ASSERT_FALSE(setting.changed); //since previous value was DECIMAL + ASSERT_TRUE(setting.changed); //since previous value was DECIMAL ASSERT_TRUE(setting.value.isSet(MySQLDataTypesSupport::DECIMAL)); ASSERT_FALSE(setting.value.isSet(MySQLDataTypesSupport::DATETIME64)); ASSERT_EQ("decimal", setting.toString()); @@ -163,7 +163,7 @@ GTEST_TEST(SettingMySQLDataTypesSupport, SetInvalidString) ASSERT_EQ(0, setting.value.getValue()); EXPECT_NO_THROW(setting = String(", ")); - ASSERT_FALSE(setting.changed); + ASSERT_TRUE(setting.changed); ASSERT_EQ(0, setting.value.getValue()); }