Skip to content

Commit c432c9e

Browse files
committed
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.
1 parent 361a11d commit c432c9e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

include/mysql.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ typedef struct st_mysql
274274
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
275275
char *info, *db;
276276
const struct charset_info_st *charset;
277-
MYSQL_FIELD *fields;
278277
MEM_ROOT field_alloc;
279278
my_ulonglong affected_rows;
280279
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
@@ -296,7 +295,8 @@ typedef struct st_mysql
296295
/* session-wide random string */
297296
char scramble[SCRAMBLE_LENGTH+1];
298297
my_bool auto_local_infile;
299-
void *unused2, *unused3, *unused4, *unused5;
298+
void *unused2, *unused3, *unused4;
299+
MYSQL_FIELD *fields;
300300

301301
LIST *stmts; /* list of all statements */
302302
const struct st_mysql_methods *methods;

tests/mysql_client_fw.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,14 @@ int main(int argc, char **argv)
14261426
tests_to_run[i]= NULL;
14271427
}
14281428

1429+
#ifdef _WIN32
1430+
/* must be the same in C/C and embedded, 1208 on 64bit, 968 on 32bit */
1431+
compile_time_assert(sizeof(MYSQL) == 60*sizeof(void*)+728);
1432+
#else
1433+
/* must be the same in C/C and embedded, 1272 on 64bit, 964 on 32bit */
1434+
compile_time_assert(sizeof(MYSQL) == 77*sizeof(void*)+656);
1435+
#endif
1436+
14291437
if (mysql_server_init(embedded_server_arg_count,
14301438
embedded_server_args,
14311439
(char**) embedded_server_groups))

0 commit comments

Comments
 (0)