summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc8
-rw-r--r--include/mysql_com.h20
-rw-r--r--libmysql/client_settings.h2
-rw-r--r--sql-common/client.c2
-rw-r--r--sql/client_settings.h2
-rw-r--r--sql/sql_acl.cc24
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_class.h6
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--tests/mysql_client_test.c7
10 files changed, 49 insertions, 26 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 3e08c87aea1..c4dbe21a465 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1921,7 +1921,7 @@ static int get_options(int argc, char **argv)
connect_flag|= CLIENT_IGNORE_SPACE;
if (opt_progress_reports)
- connect_flag|= CLIENT_PROGRESS;
+ connect_flag|= CLIENT_PROGRESS_OBSOLETE;
return(0);
}
@@ -4638,10 +4638,10 @@ sql_real_connect(char *host,char *database,char *user,char *password,
mysql.reconnect= debug_info_flag; // We want to know if this happens
/*
- CLIENT_PROGRESS is set only if we requsted it in mysql_real_connect()
- and the server also supports it
+ CLIENT_PROGRESS_OBSOLETE is set only if we requested it in
+ mysql_real_connect() and the server also supports it
*/
- if (mysql.client_flag & CLIENT_PROGRESS)
+ if (mysql.client_flag & CLIENT_PROGRESS_OBSOLETE)
mysql_options(&mysql, MYSQL_PROGRESS_CALLBACK, (void*) report_progress);
#else
mysql.reconnect= 1;
diff --git a/include/mysql_com.h b/include/mysql_com.h
index aa6ab0f0d0a..df1ff3fe954 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -188,7 +188,8 @@ enum enum_server_command
#define REFRESH_GENERIC (1ULL << 30)
#define REFRESH_FAST (1ULL << 31) /* Intern flag */
-#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
+#define CLIENT_LONG_PASSWORD 0 /* obsolete flag */
+#define CLIENT_MYSQL 1 /* mysql/old mariadb server/client */
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
@@ -215,7 +216,7 @@ enum enum_server_command
/* Don't close the connection for a connection with expired password. */
#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22)
-#define CLIENT_PROGRESS (1UL << 29) /* Client support progress indicator */
+#define CLIENT_PROGRESS_OBSOLETE (1UL << 29)
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
/*
It used to be that if mysql_real_connect() failed, it would delete any
@@ -228,14 +229,23 @@ enum enum_server_command
*/
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
+/* MariaDB extended capability flags */
+#define MARIADB_CLIENT_FLAGS_MASK 0xffffffff00000000ULL
+/* Client support progress indicator */
+#define MARIADB_CLIENT_PROGRESS (1ULL << 32)
+
#ifdef HAVE_COMPRESS
#define CAN_CLIENT_COMPRESS CLIENT_COMPRESS
#else
#define CAN_CLIENT_COMPRESS 0
#endif
-/* Gather all possible capabilites (flags) supported by the server */
-#define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \
+/*
+ Gather all possible capabilites (flags) supported by the server
+
+ MARIADB_* flags supported only by MariaDB connector(s).
+*/
+#define CLIENT_ALL_FLAGS (\
CLIENT_FOUND_ROWS | \
CLIENT_LONG_FLAG | \
CLIENT_CONNECT_WITH_DB | \
@@ -256,7 +266,7 @@ enum enum_server_command
CLIENT_PS_MULTI_RESULTS | \
CLIENT_SSL_VERIFY_SERVER_CERT | \
CLIENT_REMEMBER_OPTIONS | \
- CLIENT_PROGRESS | \
+ MARIADB_CLIENT_PROGRESS | \
CLIENT_PLUGIN_AUTH | \
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA | \
CLIENT_CONNECT_ATTRS)
diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h
index b233614fa1e..2577870bfa3 100644
--- a/libmysql/client_settings.h
+++ b/libmysql/client_settings.h
@@ -27,7 +27,7 @@ extern char * mysql_unix_port;
When adding capabilities here, consider if they should be also added to
the server's version.
*/
-#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \
+#define CLIENT_CAPABILITIES (CLIENT_MYSQL | \
CLIENT_LONG_FLAG | \
CLIENT_TRANSACTIONS | \
CLIENT_PROTOCOL_41 | \
diff --git a/sql-common/client.c b/sql-common/client.c
index 36a644cb90f..41a262ad448 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -601,7 +601,7 @@ restart:
uint last_errno=uint2korr(pos);
if (last_errno == 65535 &&
- (mysql->server_capabilities & CLIENT_PROGRESS))
+ (mysql->server_capabilities & CLIENT_PROGRESS_OBSOLETE))
{
if (cli_report_progress(mysql, pos+2, (uint) (len-3)))
{
diff --git a/sql/client_settings.h b/sql/client_settings.h
index d6a157f71fd..cc90d6a174d 100644
--- a/sql/client_settings.h
+++ b/sql/client_settings.h
@@ -28,7 +28,7 @@
When adding capabilities here, consider if they should be also added to
the libmysql version.
*/
-#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \
+#define CLIENT_CAPABILITIES (CLIENT_MYSQL | \
CLIENT_LONG_FLAG | \
CLIENT_TRANSACTIONS | \
CLIENT_PROTOCOL_41 | \
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 2bcd351ae32..7d6301cb5b4 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -11314,7 +11314,8 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
int2store(end+5, thd->client_capabilities >> 16);
end[7]= data_len;
DBUG_EXECUTE_IF("poison_srv_handshake_scramble_len", end[7]= -100;);
- bzero(end + 8, 10);
+ bzero(end + 8, 6);
+ int4store(end + 14, thd->client_capabilities >> 32);
end+= 18;
/* write scramble tail */
end= (char*) memcpy(end, data + SCRAMBLE_LENGTH_323,
@@ -11730,18 +11731,29 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
*/
DBUG_ASSERT(net->read_pos[pkt_len] == 0);
- ulong client_capabilities= uint2korr(net->read_pos);
+ ulonglong client_capabilities= uint2korr(net->read_pos);
+ compile_time_assert(sizeof(client_capabilities) >= 8);
if (client_capabilities & CLIENT_PROTOCOL_41)
{
- if (pkt_len < 4)
+ if (pkt_len < 32)
return packet_error;
client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
+ if (!(client_capabilities & CLIENT_MYSQL))
+ {
+ // it is client with mariadb extensions
+ ulonglong ext_client_capabilities=
+ (((ulonglong)uint4korr(net->read_pos + 28)) << 32);
+ client_capabilities|= ext_client_capabilities;
+ }
+ else if (client_capabilities & CLIENT_PROGRESS_OBSOLETE)
+ client_capabilities|= MARIADB_CLIENT_PROGRESS;
}
/* Disable those bits which are not supported by the client. */
+ compile_time_assert(sizeof(thd->client_capabilities) >= 8);
thd->client_capabilities&= client_capabilities;
- DBUG_PRINT("info", ("client capabilities: %lu", thd->client_capabilities));
+ DBUG_PRINT("info", ("client capabilities: %llu", thd->client_capabilities));
if (thd->client_capabilities & CLIENT_SSL)
{
unsigned long errptr __attribute__((unused));
@@ -11769,8 +11781,6 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
if (client_capabilities & CLIENT_PROTOCOL_41)
{
- if (pkt_len < 32)
- return packet_error;
thd->max_client_packet_length= uint4korr(net->read_pos+4);
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
if (thd_init_client_charset(thd, (uint) net->read_pos[8]))
@@ -12547,7 +12557,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
}
DBUG_PRINT("info",
- ("Capabilities: %lu packet_length: %ld Host: '%s' "
+ ("Capabilities: %llu packet_length: %ld Host: '%s' "
"Login user: '%s' Priv_user: '%s' Using password: %s "
"Access: %lu db: '%s'",
thd->client_capabilities, thd->max_client_packet_length,
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index c5ad66200c8..a38822c3f16 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4329,7 +4329,7 @@ extern "C" void thd_progress_init(MYSQL_THD thd, uint max_stage)
is a high level command (like ALTER TABLE) and we are not in a
stored procedure
*/
- thd->progress.report= ((thd->client_capabilities & CLIENT_PROGRESS) &&
+ thd->progress.report= ((thd->client_capabilities & MARIADB_CLIENT_PROGRESS) &&
thd->progress.report_to_client &&
!thd->in_sub_stmt);
thd->progress.next_report_time= 0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 47c351efb80..ffa0a3b887e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1411,7 +1411,7 @@ public:
Discrete_intervals_list auto_inc_intervals_forced;
ulonglong limit_found_rows;
ha_rows cuted_fields, sent_row_count, examined_row_count;
- ulong client_capabilities;
+ ulonglong client_capabilities;
ulong query_plan_flags;
uint in_sub_stmt;
bool enable_slow_log;
@@ -2044,7 +2044,7 @@ public:
/* Needed by MariaDB semi sync replication */
Trans_binlog_info *semisync_info;
- ulong client_capabilities; /* What the client supports */
+ ulonglong client_capabilities; /* What the client supports */
ulong max_client_packet_length;
HASH handler_tables_hash;
@@ -2086,7 +2086,7 @@ public:
bool report_to_client;
/*
true, if we will send progress report packets to a client
- (client has requested them, see CLIENT_PROGRESS; report_to_client
+ (client has requested them, see MARIADB_CLIENT_PROGRESS; report_to_client
is true; not in sub-statement)
*/
bool report;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 96985aac051..4548a0bf47c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -637,7 +637,7 @@ void execute_init_command(THD *thd, LEX_STRING *init_command,
mysql_rwlock_t *var_lock)
{
Vio* save_vio;
- ulong save_client_capabilities;
+ ulonglong save_client_capabilities;
mysql_rwlock_rdlock(var_lock);
if (!init_command->length)
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index ae4cf6d71d3..91efdc9ef35 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -18699,8 +18699,11 @@ static void test_progress_reporting()
myheader("test_progress_reporting");
- conn= client_connect(CLIENT_PROGRESS, MYSQL_PROTOCOL_TCP, 0);
- DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS);
+
+ conn= client_connect(CLIENT_PROGRESS_OBSOLETE, MYSQL_PROTOCOL_TCP, 0);
+ if (!(conn->server_capabilities & CLIENT_PROGRESS_OBSOLETE))
+ return;
+ DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS_OBSOLETE);
mysql_options(conn, MYSQL_PROGRESS_CALLBACK, (void*) report_progress);
rc= mysql_query(conn, "set @save=@@global.progress_report_time");