mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Merge pull request #60365 from rschu1ze/mysql-friday-evening-fix
MySQL: Force-set `prefer_column_name_to_alias` in handler and set `mysql_map_(fixed)_string_to_text_in_show_columns` by default
This commit is contained in:
commit
de45c26262
@ -3449,7 +3449,7 @@ Has an effect only when the connection is made through the MySQL wire protocol.
|
||||
- 0 - Use `BLOB`.
|
||||
- 1 - Use `TEXT`.
|
||||
|
||||
Default value: `0`.
|
||||
Default value: `1`.
|
||||
|
||||
## mysql_map_fixed_string_to_text_in_show_columns {#mysql_map_fixed_string_to_text_in_show_columns}
|
||||
|
||||
@ -3460,7 +3460,7 @@ Has an effect only when the connection is made through the MySQL wire protocol.
|
||||
- 0 - Use `BLOB`.
|
||||
- 1 - Use `TEXT`.
|
||||
|
||||
Default value: `0`.
|
||||
Default value: `1`.
|
||||
|
||||
## execute_merges_on_single_replica_time_threshold {#execute-merges-on-single-replica-time-threshold}
|
||||
|
||||
|
@ -224,8 +224,8 @@ class IColumn;
|
||||
M(Bool, allow_experimental_inverted_index, false, "If it is set to true, allow to use experimental inverted index.", 0) \
|
||||
\
|
||||
M(UInt64, mysql_max_rows_to_insert, 65536, "The maximum number of rows in MySQL batch insertion of the MySQL storage engine", 0) \
|
||||
M(Bool, mysql_map_string_to_text_in_show_columns, false, "If enabled, String type will be mapped to TEXT in SHOW [FULL] COLUMNS, BLOB otherwise.", 0) \
|
||||
M(Bool, mysql_map_fixed_string_to_text_in_show_columns, false, "If enabled, FixedString type will be mapped to TEXT in SHOW [FULL] COLUMNS, BLOB otherwise.", 0) \
|
||||
M(Bool, mysql_map_string_to_text_in_show_columns, true, "If enabled, String type will be mapped to TEXT in SHOW [FULL] COLUMNS, BLOB otherwise. Has an effect only when the connection is made through the MySQL wire protocol.", 0) \
|
||||
M(Bool, mysql_map_fixed_string_to_text_in_show_columns, true, "If enabled, FixedString type will be mapped to TEXT in SHOW [FULL] COLUMNS, BLOB otherwise. Has an effect only when the connection is made through the MySQL wire protocol.", 0) \
|
||||
\
|
||||
M(UInt64, optimize_min_equality_disjunction_chain_length, 3, "The minimum length of the expression `expr = x1 OR ... expr = xN` for optimization ", 0) \
|
||||
M(UInt64, optimize_min_inequality_conjunction_chain_length, 3, "The minimum length of the expression `expr <> x1 AND ... expr <> xN` for optimization ", 0) \
|
||||
|
@ -78,7 +78,8 @@ namespace SettingsChangesHistory
|
||||
/// History of settings changes that controls some backward incompatible changes
|
||||
/// across all ClickHouse versions. It maps ClickHouse version to settings changes that were done
|
||||
/// in this version. This history contains both changes to existing settings and newly added settings.
|
||||
/// Settings changes is a vector of structs {setting_name, previous_value, new_value}.
|
||||
/// Settings changes is a vector of structs
|
||||
/// {setting_name, previous_value, new_value, reason}.
|
||||
/// For newly added setting choose the most appropriate previous_value (for example, if new setting
|
||||
/// controls new feature and it's 'true' by default, use 'false' as previous_value).
|
||||
/// It's used to implement `compatibility` setting (see https://github.com/ClickHouse/ClickHouse/issues/35972)
|
||||
@ -103,6 +104,8 @@ static std::map<ClickHouseVersion, SettingsChangesHistory::SettingsChanges> sett
|
||||
{"min_external_table_block_size_bytes", DEFAULT_INSERT_BLOCK_SIZE * 256, DEFAULT_INSERT_BLOCK_SIZE * 256, "Squash blocks passed to external table to specified size in bytes, if blocks are not big enough."},
|
||||
{"parallel_replicas_prefer_local_join", true, true, "If true, and JOIN can be executed with parallel replicas algorithm, and all storages of right JOIN part are *MergeTree, local JOIN will be used instead of GLOBAL JOIN."},
|
||||
{"extract_key_value_pairs_max_pairs_per_row", 0, 0, "Max number of pairs that can be produced by the `extractKeyValuePairs` function. Used as a safeguard against consuming too much memory."},
|
||||
{"mysql_map_string_to_text_in_show_columns", false, true, "Reduce the configuration effort to connect ClickHouse with BI tools."},
|
||||
{"mysql_map_fixed_string_to_text_in_show_columns", false, true, "Reduce the configuration effort to connect ClickHouse with BI tools."},
|
||||
}},
|
||||
{"24.1", {{"print_pretty_type_names", false, true, "Better user experience."},
|
||||
{"input_format_json_read_bools_as_strings", false, true, "Allow to read bools as strings in JSON formats by default"},
|
||||
|
@ -461,6 +461,12 @@ void MySQLHandler::comQuery(ReadBuffer & payload, bool binary_protocol)
|
||||
|
||||
auto query_context = session->makeQueryContext();
|
||||
query_context->setCurrentQueryId(fmt::format("mysql:{}:{}", connection_id, toString(UUIDHelpers::generateV4())));
|
||||
|
||||
/// --- Workaround for Bug 56173. Can be removed when the analyzer is on by default.
|
||||
auto settings = query_context->getSettings();
|
||||
settings.prefer_column_name_to_alias = true;
|
||||
query_context->setSettings(settings);
|
||||
|
||||
CurrentThread::QueryScope query_scope{query_context};
|
||||
|
||||
std::atomic<size_t> affected_rows {0};
|
||||
|
@ -123,7 +123,7 @@ expect -- "| dt_tz2 | DATETIME | NO | | NULL | |
|
||||
expect -- "| enm | TEXT | NO | | NULL | |"
|
||||
expect -- "| f32 | FLOAT | NO | | NULL | |"
|
||||
expect -- "| f64 | DOUBLE | NO | | NULL | |"
|
||||
expect -- "| fs | BLOB | NO | | NULL | |"
|
||||
expect -- "| fs | TEXT | NO | | NULL | |"
|
||||
expect -- "| i128 | TEXT | NO | | NULL | |"
|
||||
expect -- "| i16 | SMALLINT | NO | | NULL | |"
|
||||
expect -- "| i256 | TEXT | NO | | NULL | |"
|
||||
@ -132,74 +132,8 @@ expect -- "| i64 | BIGINT | NO | | NULL | |
|
||||
expect -- "| i8 | TINYINT | NO | | NULL | |"
|
||||
expect -- "| ip4 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ip6 | TEXT | NO | | NULL | |"
|
||||
expect -- "| lfs | BLOB | NO | | NULL | |"
|
||||
expect -- "| lnfs | BLOB | YES | | NULL | |"
|
||||
expect -- "| lns | BLOB | YES | | NULL | |"
|
||||
expect -- "| ls | BLOB | NO | | NULL | |"
|
||||
expect -- "| m | JSON | NO | | NULL | |"
|
||||
expect -- "| m_complex | JSON | NO | | NULL | |"
|
||||
expect -- "| mpg | TEXT | NO | | NULL | |"
|
||||
expect -- "| ndt64 | DATETIME | YES | | NULL | |"
|
||||
expect -- "| ndt64_tz | DATETIME | YES | | NULL | |"
|
||||
expect -- "| nested.col1 | TEXT | NO | | NULL | |"
|
||||
expect -- "| nested.col2 | TEXT | NO | | NULL | |"
|
||||
expect -- "| nfs | BLOB | YES | | NULL | |"
|
||||
expect -- "| ns | BLOB | YES | | NULL | |"
|
||||
expect -- "| o | JSON | NO | | NULL | |"
|
||||
expect -- "| p | TEXT | NO | | NULL | |"
|
||||
expect -- "| pg | TEXT | NO | | NULL | |"
|
||||
expect -- "| r | TEXT | NO | | NULL | |"
|
||||
expect -- "| s | BLOB | NO | | NULL | |"
|
||||
expect -- "| sagg | TEXT | NO | | NULL | |"
|
||||
expect -- "| t | JSON | NO | | NULL | |"
|
||||
expect -- "| ui128 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ui16 | SMALLINT UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| ui256 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ui32 | INTEGER UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| ui64 | BIGINT UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| ui8 | TINYINT UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| uuid | CHAR | NO | | NULL | |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
|
||||
send -- "SHOW COLUMNS FROM tab SETTINGS mysql_map_string_to_text_in_show_columns=1;\r"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
expect -- "| field | type | null | key | default | extra |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
expect -- "| a | TEXT | NO | | NULL | |"
|
||||
expect -- "| agg | TEXT | NO | | NULL | |"
|
||||
expect -- "| b | TINYINT | NO | | NULL | |"
|
||||
expect -- "| d | DATE | NO | | NULL | |"
|
||||
expect -- "| d32 | DATE | NO | | NULL | |"
|
||||
expect -- "| dec128 | DECIMAL(38, 2) | NO | | NULL | |"
|
||||
expect -- "| dec128_native | DECIMAL(35, 30) | NO | | NULL | |"
|
||||
expect -- "| dec128_text | TEXT | NO | | NULL | |"
|
||||
expect -- "| dec256 | TEXT | NO | | NULL | |"
|
||||
expect -- "| dec256_native | DECIMAL(65, 2) | NO | | NULL | |"
|
||||
expect -- "| dec256_text | TEXT | NO | | NULL | |"
|
||||
expect -- "| dec32 | DECIMAL(9, 2) | NO | | NULL | |"
|
||||
expect -- "| dec64 | DECIMAL(18, 2) | NO | | NULL | |"
|
||||
expect -- "| dt | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_3_tz1 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_3_tz2 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_6 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_9 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt_tz1 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt_tz2 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| enm | TEXT | NO | | NULL | |"
|
||||
expect -- "| f32 | FLOAT | NO | | NULL | |"
|
||||
expect -- "| f64 | DOUBLE | NO | | NULL | |"
|
||||
expect -- "| fs | BLOB | NO | | NULL | |"
|
||||
expect -- "| i128 | TEXT | NO | | NULL | |"
|
||||
expect -- "| i16 | SMALLINT | NO | | NULL | |"
|
||||
expect -- "| i256 | TEXT | NO | | NULL | |"
|
||||
expect -- "| i32 | INTEGER | NO | | NULL | |"
|
||||
expect -- "| i64 | BIGINT | NO | | NULL | |"
|
||||
expect -- "| i8 | TINYINT | NO | | NULL | |"
|
||||
expect -- "| ip4 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ip6 | TEXT | NO | | NULL | |"
|
||||
expect -- "| lfs | BLOB | NO | | NULL | |"
|
||||
expect -- "| lnfs | BLOB | YES | | NULL | |"
|
||||
expect -- "| lfs | TEXT | NO | | NULL | |"
|
||||
expect -- "| lnfs | TEXT | YES | | NULL | |"
|
||||
expect -- "| lns | TEXT | YES | | NULL | |"
|
||||
expect -- "| ls | TEXT | NO | | NULL | |"
|
||||
expect -- "| m | JSON | NO | | NULL | |"
|
||||
@ -209,7 +143,7 @@ expect -- "| ndt64 | DATETIME | YES | | NULL | |
|
||||
expect -- "| ndt64_tz | DATETIME | YES | | NULL | |"
|
||||
expect -- "| nested.col1 | TEXT | NO | | NULL | |"
|
||||
expect -- "| nested.col2 | TEXT | NO | | NULL | |"
|
||||
expect -- "| nfs | BLOB | YES | | NULL | |"
|
||||
expect -- "| nfs | TEXT | YES | | NULL | |"
|
||||
expect -- "| ns | TEXT | YES | | NULL | |"
|
||||
expect -- "| o | JSON | NO | | NULL | |"
|
||||
expect -- "| p | TEXT | NO | | NULL | |"
|
||||
@ -227,7 +161,7 @@ expect -- "| ui8 | TINYINT UNSIGNED | NO | | NULL | |
|
||||
expect -- "| uuid | CHAR | NO | | NULL | |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
|
||||
send -- "SHOW COLUMNS FROM tab SETTINGS mysql_map_fixed_string_to_text_in_show_columns=1;\r"
|
||||
send -- "SHOW COLUMNS FROM tab SETTINGS mysql_map_string_to_text_in_show_columns=0;\r"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
expect -- "| field | type | null | key | default | extra |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
@ -293,6 +227,73 @@ expect -- "| ui8 | TINYINT UNSIGNED | NO | | NULL | |
|
||||
expect -- "| uuid | CHAR | NO | | NULL | |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
|
||||
send -- "SHOW COLUMNS FROM tab SETTINGS mysql_map_fixed_string_to_text_in_show_columns=0;\r"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
expect -- "| field | type | null | key | default | extra |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
expect -- "| a | TEXT | NO | | NULL | |"
|
||||
expect -- "| agg | TEXT | NO | | NULL | |"
|
||||
expect -- "| b | TINYINT | NO | | NULL | |"
|
||||
expect -- "| d | DATE | NO | | NULL | |"
|
||||
expect -- "| d32 | DATE | NO | | NULL | |"
|
||||
expect -- "| dec128 | DECIMAL(38, 2) | NO | | NULL | |"
|
||||
expect -- "| dec128_native | DECIMAL(35, 30) | NO | | NULL | |"
|
||||
expect -- "| dec128_text | TEXT | NO | | NULL | |"
|
||||
expect -- "| dec256 | TEXT | NO | | NULL | |"
|
||||
expect -- "| dec256_native | DECIMAL(65, 2) | NO | | NULL | |"
|
||||
expect -- "| dec256_text | TEXT | NO | | NULL | |"
|
||||
expect -- "| dec32 | DECIMAL(9, 2) | NO | | NULL | |"
|
||||
expect -- "| dec64 | DECIMAL(18, 2) | NO | | NULL | |"
|
||||
expect -- "| dt | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_3_tz1 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_3_tz2 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_6 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt64_9 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt_tz1 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| dt_tz2 | DATETIME | NO | | NULL | |"
|
||||
expect -- "| enm | TEXT | NO | | NULL | |"
|
||||
expect -- "| f32 | FLOAT | NO | | NULL | |"
|
||||
expect -- "| f64 | DOUBLE | NO | | NULL | |"
|
||||
expect -- "| fs | BLOB | NO | | NULL | |"
|
||||
expect -- "| i128 | TEXT | NO | | NULL | |"
|
||||
expect -- "| i16 | SMALLINT | NO | | NULL | |"
|
||||
expect -- "| i256 | TEXT | NO | | NULL | |"
|
||||
expect -- "| i32 | INTEGER | NO | | NULL | |"
|
||||
expect -- "| i64 | BIGINT | NO | | NULL | |"
|
||||
expect -- "| i8 | TINYINT | NO | | NULL | |"
|
||||
expect -- "| ip4 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ip6 | TEXT | NO | | NULL | |"
|
||||
expect -- "| lfs | BLOB | NO | | NULL | |"
|
||||
expect -- "| lnfs | BLOB | YES | | NULL | |"
|
||||
expect -- "| lns | TEXT | YES | | NULL | |"
|
||||
expect -- "| ls | TEXT | NO | | NULL | |"
|
||||
expect -- "| m | JSON | NO | | NULL | |"
|
||||
expect -- "| m_complex | JSON | NO | | NULL | |"
|
||||
expect -- "| mpg | TEXT | NO | | NULL | |"
|
||||
expect -- "| ndt64 | DATETIME | YES | | NULL | |"
|
||||
expect -- "| ndt64_tz | DATETIME | YES | | NULL | |"
|
||||
expect -- "| nested.col1 | TEXT | NO | | NULL | |"
|
||||
expect -- "| nested.col2 | TEXT | NO | | NULL | |"
|
||||
expect -- "| nfs | BLOB | YES | | NULL | |"
|
||||
expect -- "| ns | TEXT | YES | | NULL | |"
|
||||
expect -- "| o | JSON | NO | | NULL | |"
|
||||
expect -- "| p | TEXT | NO | | NULL | |"
|
||||
expect -- "| pg | TEXT | NO | | NULL | |"
|
||||
expect -- "| r | TEXT | NO | | NULL | |"
|
||||
expect -- "| s | TEXT | NO | | NULL | |"
|
||||
expect -- "| sagg | TEXT | NO | | NULL | |"
|
||||
expect -- "| t | JSON | NO | | NULL | |"
|
||||
expect -- "| ui128 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ui16 | SMALLINT UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| ui256 | TEXT | NO | | NULL | |"
|
||||
expect -- "| ui32 | INTEGER UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| ui64 | BIGINT UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| ui8 | TINYINT UNSIGNED | NO | | NULL | |"
|
||||
expect -- "| uuid | CHAR | NO | | NULL | |"
|
||||
expect -- "+---------------+-------------------+------+------+---------+-------+"
|
||||
|
||||
|
||||
send -- "DROP TABLE tab;"
|
||||
|
||||
send -- "quit;\r"
|
||||
|
@ -0,0 +1,2 @@
|
||||
b count()
|
||||
2 1
|
14
tests/queries/0_stateless/02968_mysql_prefer_column_name_to_alias.sh
Executable file
14
tests/queries/0_stateless/02968_mysql_prefer_column_name_to_alias.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest
|
||||
# Tag no-fasttest: requires mysql client
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
# Some BI tools which connect to ClickHouse's MySQL port, run queries which succeed only with (the analyzer enabled)
|
||||
# or (without analyzer and setting prefer_column_name_to_alias = 1). Since the setting is too impactful to enable it
|
||||
# globally, it is enabled only by the MySQL handler internally as a workaround. Run a query from Bug 56173 to verify.
|
||||
#
|
||||
# When the analyzer is the new default, the test and the workaround can be deleted.
|
||||
${MYSQL_CLIENT} --execute "select a + b as b, count() from (select 1 as a, 1 as b) group by a + b";
|
Loading…
Reference in New Issue
Block a user