mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Add SHOW WARNINGS
support in MySQL interface
This commit is contained in:
parent
7731297aef
commit
cb8372a3f9
@ -61,6 +61,8 @@ namespace ErrorCodes
|
||||
static const size_t PACKET_HEADER_SIZE = 4;
|
||||
static const size_t SSL_REQUEST_PAYLOAD_SIZE = 32;
|
||||
|
||||
static String showWarningsReplacementQuery(const String & query);
|
||||
static String showCountWarningsReplacementQuery(const String & query);
|
||||
static String selectEmptyReplacementQuery(const String & query);
|
||||
static String showTableStatusReplacementQuery(const String & query);
|
||||
static String killConnectionIdReplacementQuery(const String & query);
|
||||
@ -86,6 +88,8 @@ MySQLHandler::MySQLHandler(
|
||||
if (ssl_enabled)
|
||||
server_capabilities |= CLIENT_SSL;
|
||||
|
||||
replacements.emplace("SHOW WARNINGS", showWarningsReplacementQuery);
|
||||
replacements.emplace("SHOW COUNT(*) WARNINGS", showCountWarningsReplacementQuery);
|
||||
replacements.emplace("KILL QUERY", killConnectionIdReplacementQuery);
|
||||
replacements.emplace("SHOW TABLE STATUS LIKE", showTableStatusReplacementQuery);
|
||||
replacements.emplace("SHOW VARIABLES", selectEmptyReplacementQuery);
|
||||
@ -544,6 +548,18 @@ static bool isFederatedServerSetupSetCommand(const String & query)
|
||||
return re2::RE2::FullMatch(query, expr);
|
||||
}
|
||||
|
||||
/// Always return an empty set with appropriate column definitions for SHOW WARNINGS queries
|
||||
/// See also: https://dev.mysql.com/doc/refman/8.0/en/show-warnings.html
|
||||
static String showWarningsReplacementQuery([[maybe_unused]] const String & query)
|
||||
{
|
||||
return "SELECT '' AS Level, 0::UInt32 AS Code, '' AS Message WHERE false";
|
||||
}
|
||||
|
||||
static String showCountWarningsReplacementQuery([[maybe_unused]] const String & query)
|
||||
{
|
||||
return "SELECT 0::UInt64 AS `@@session.warning_count`";
|
||||
}
|
||||
|
||||
/// Replace "[query(such as SHOW VARIABLES...)]" into "".
|
||||
static String selectEmptyReplacementQuery(const String & query)
|
||||
{
|
||||
|
@ -0,0 +1,6 @@
|
||||
@@session.warning_count
|
||||
0
|
||||
@@session.warning_count
|
||||
0
|
||||
@@warning_count
|
||||
0
|
19
tests/queries/0_stateless/02968_mysql_show_warnings.sh
Executable file
19
tests/queries/0_stateless/02968_mysql_show_warnings.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest
|
||||
# Tag no-fasttest: requires mysql client
|
||||
|
||||
# Tests the override of certain MySQL proprietary settings to ClickHouse native settings
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
${MYSQL_CLIENT} --execute "SHOW WARNINGS;"
|
||||
${MYSQL_CLIENT} --execute "show warnings;"
|
||||
${MYSQL_CLIENT} --execute "SHOW WARNINGS LIMIT 100;"
|
||||
${MYSQL_CLIENT} --execute "show warnings limit 100;"
|
||||
${MYSQL_CLIENT} --execute "SHOW WARNINGS LIMIT 100 OFFSET 100;"
|
||||
${MYSQL_CLIENT} --execute "show warnings limit 100 offset 100;"
|
||||
${MYSQL_CLIENT} --execute "SHOW COUNT(*) WARNINGS;"
|
||||
${MYSQL_CLIENT} --execute "show count(*) warnings;"
|
||||
${MYSQL_CLIENT} --execute "SELECT @@session.warning_count;"
|
Loading…
Reference in New Issue
Block a user