Skip to content

Commit 7c6f42b

Browse files
committed
fix: MySQL 9.x charset handling and log_last_insert_id test race
- validate_charset: compare server_version as a numeric major version instead of testing the first character, so MySQL 9.x and later are treated like 8.x for collations with id >= 255 - test_log_last_insert_id-t: re-enable PROXYSQL FLUSH LOGS; with buffered query logging, eventslog_flush_timeout=0 alone still races the periodic flush thread
1 parent d212102 commit 7c6f42b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

lib/MySQL_Variables.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ bool validate_charset(MySQL_Session* session, int idx, int &_rc) {
337337
unsigned int replace_collation_nr = 0;
338338
std::stringstream ss;
339339
int charset = atoi(mysql_variables.client_get_value(session, idx));
340-
if (charset >= 255 && myconn->mysql->server_version[0] != '8') {
340+
// Pre-8.0 MySQL cannot handle collations with id >= 255.
341+
// MySQL 8.x, 9.x and later can — match by numeric major version, not first character.
342+
if (charset >= 255 && atoi(myconn->mysql->server_version) < 8) {
341343
switch(mysql_thread___handle_unknown_charset) {
342344
case HANDLE_UNKNOWN_CHARSET__DISCONNECT_CLIENT:
343345
snprintf(msg,sizeof(msg),"Can't initialize character set %s", mysql_variables.client_get_value(session, idx));

test/tap/tests/test_log_last_insert_id-t.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ int main(int argc, char** argv) {
7777
MYSQL_QUERY(proxysql_mysql, "INSERT INTO test.test_insert_id VALUES (NULL)");
7878
MYSQL_QUERY(proxysql_mysql, "DO 1");
7979

80-
/* in 3.0.6 we added buffering for query log . So we either flush logs or set mysql-eventslog_flush_timeout = 0 */
81-
/*
80+
/* in 3.0.6 we added buffering for query log; flush_timeout=0 alone leaves a race
81+
* between query completion and the periodic flush thread, so force a flush here. */
8282
MYSQL_QUERY(proxysql_admin, "PROXYSQL FLUSH LOGS");
8383
sleep(1);
84-
*/
8584
{
8685
const string f_path { get_env("REGULAR_INFRA_DATADIR") + "/loginsertid.log.00000001" };
8786
diag("Trying to open file %s" , f_path.c_str());

0 commit comments

Comments
 (0)