Review and style fixes

This commit is contained in:
alesapin 2022-06-29 20:29:50 +02:00
parent 9b387a57ed
commit 8f5582f95e
3 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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()

View File

@ -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;