From c432c9ef19bf6ff40ab9551bcae202d7e1319878 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 23 Nov 2023 10:00:37 +0100 Subject: [PATCH] MDEV-32862 MYSQL struct in C/C and server differs move MYSQL::fields down, replacing MYSQL::unused5 this way only MYSQL::fields and MYSQL::field_alloc will still have different offset in C/C and the server, but all other MYSQL members will get back in sync. luckily, plugins shouldn't need MYSQL::fields or MYSQL::field_alloc added a check to ensure both MYSQL structures are always of the same size. --- include/mysql.h | 4 ++-- tests/mysql_client_fw.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 89807c07fce..dd928fe0bf1 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -274,7 +274,6 @@ typedef struct st_mysql char *host,*user,*passwd,*unix_socket,*server_version,*host_info; char *info, *db; const struct charset_info_st *charset; - MYSQL_FIELD *fields; MEM_ROOT field_alloc; my_ulonglong affected_rows; my_ulonglong insert_id; /* id if insert on table with NEXTNR */ @@ -296,7 +295,8 @@ typedef struct st_mysql /* session-wide random string */ char scramble[SCRAMBLE_LENGTH+1]; my_bool auto_local_infile; - void *unused2, *unused3, *unused4, *unused5; + void *unused2, *unused3, *unused4; + MYSQL_FIELD *fields; LIST *stmts; /* list of all statements */ const struct st_mysql_methods *methods; diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index 75425aa98e4..f6e9bfc2713 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -1426,6 +1426,14 @@ int main(int argc, char **argv) tests_to_run[i]= NULL; } +#ifdef _WIN32 + /* must be the same in C/C and embedded, 1208 on 64bit, 968 on 32bit */ + compile_time_assert(sizeof(MYSQL) == 60*sizeof(void*)+728); +#else + /* must be the same in C/C and embedded, 1272 on 64bit, 964 on 32bit */ + compile_time_assert(sizeof(MYSQL) == 77*sizeof(void*)+656); +#endif + if (mysql_server_init(embedded_server_arg_count, embedded_server_args, (char**) embedded_server_groups))