From 8f5582f95efd18eac8c926a89574b20e617b939c Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 29 Jun 2022 20:29:50 +0200 Subject: [PATCH] Review and style fixes --- src/Interpreters/InterpreterCreateQuery.cpp | 9 ++++---- .../test.py | 23 ++++++++++++++----- ...2316_cast_to_ip_address_default_column.sql | 1 + 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Interpreters/InterpreterCreateQuery.cpp b/src/Interpreters/InterpreterCreateQuery.cpp index 0fb048332b7..7a00bbf524c 100644 --- a/src/Interpreters/InterpreterCreateQuery.cpp +++ b/src/Interpreters/InterpreterCreateQuery.cpp @@ -996,11 +996,6 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create) throw Exception("Temporary tables cannot be inside a database. You should not specify a database for a temporary table.", ErrorCodes::BAD_DATABASE_FOR_TEMPORARY_TABLE); - /// Compatibility setting which should be enabled by default on attach - /// Otherwise server will be unable to start for some old-format of IPv6/IPv4 types - if (create.attach) - getContext()->setSetting("cast_ipv4_ipv6_default_on_conversion_error", 1); - String current_database = getContext()->getCurrentDatabase(); auto database_name = create.database ? create.getDatabase() : current_database; @@ -1043,6 +1038,10 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create) create.attach = true; create.attach_short_syntax = true; create.if_not_exists = if_not_exists; + + /// Compatibility setting which should be enabled by default on attach + /// Otherwise server will be unable to start for some old-format of IPv6/IPv4 types + getContext()->setSetting("cast_ipv4_ipv6_default_on_conversion_error", 1); } /// TODO throw exception if !create.attach_short_syntax && !create.attach_from_path && !internal diff --git a/tests/integration/test_server_start_and_ip_conversions/test.py b/tests/integration/test_server_start_and_ip_conversions/test.py index 73604394d9d..abb6a546f64 100644 --- a/tests/integration/test_server_start_and_ip_conversions/test.py +++ b/tests/integration/test_server_start_and_ip_conversions/test.py @@ -6,6 +6,7 @@ from helpers.cluster import ClickHouseCluster cluster = ClickHouseCluster(__file__) node = cluster.add_instance("node", stay_alive=True) + @pytest.fixture(scope="module", autouse=True) def start_cluster(): try: @@ -16,15 +17,20 @@ def start_cluster(): def test_restart_success_ipv4(): - node.query(""" + node.query( + """ CREATE TABLE ipv4_test ( id UInt64, value String ) ENGINE=MergeTree ORDER BY id""", - settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}) + settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}, + ) - node.query("ALTER TABLE ipv4_test MODIFY COLUMN value IPv4 DEFAULT ''", settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}) + node.query( + "ALTER TABLE ipv4_test MODIFY COLUMN value IPv4 DEFAULT ''", + settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}, + ) node.restart_clickhouse() @@ -32,15 +38,20 @@ def test_restart_success_ipv4(): def test_restart_success_ipv6(): - node.query(""" + node.query( + """ CREATE TABLE ipv6_test ( id UInt64, value String ) ENGINE=MergeTree ORDER BY id""", - settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}) + settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}, + ) - node.query("ALTER TABLE ipv6_test MODIFY COLUMN value IPv6 DEFAULT ''", settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}) + node.query( + "ALTER TABLE ipv6_test MODIFY COLUMN value IPv6 DEFAULT ''", + settings={"cast_ipv4_ipv6_default_on_conversion_error": 1}, + ) node.restart_clickhouse() diff --git a/tests/queries/0_stateless/02316_cast_to_ip_address_default_column.sql b/tests/queries/0_stateless/02316_cast_to_ip_address_default_column.sql index 128acd7d132..eabe6ed1d65 100644 --- a/tests/queries/0_stateless/02316_cast_to_ip_address_default_column.sql +++ b/tests/queries/0_stateless/02316_cast_to_ip_address_default_column.sql @@ -1,4 +1,5 @@ -- Tags: no-backward-compatibility-check +-- TODO: remove after new 22.6 release SET cast_ipv4_ipv6_default_on_conversion_error = 1;