MDEV-15729 Server crashes in Field::make_field upon HANDLER READ executed with PS protocol

update table->pos_in_table_list during prepare,
just like it's done in normal execution.

otherwise it'll be a dangling pointer
This commit is contained in:
Sergei Golubchik 2018-06-10 21:19:11 +02:00
parent 6da8192174
commit ca733d03c8
3 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,9 @@
create table t1 (i int);
handler test.t1 open handler_a;
flush status;
handler handler_a read first;
i
show status like 'Com_stmt_prepare%';
Variable_name Value
Com_stmt_prepare OK
drop table t1;

View File

@ -0,0 +1,11 @@
#
# MDEV-15729 Server crashes in Field::make_field upon HANDLER READ executed with PS protocol
#
create table t1 (i int);
handler test.t1 open handler_a;
flush status;
handler handler_a read first;
# handler...read must be prepared in --ps-protocol mode
--replace_result $PS_PROTOCOL OK
show status like 'Com_stmt_prepare%';
drop table t1;

View File

@ -980,6 +980,7 @@ SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables,
if (!(handler= mysql_ha_find_handler(thd, tables->alias)))
DBUG_RETURN(0);
tables->table= handler->table; // This is used by fix_fields
handler->table->pos_in_table_list= tables;
if (mysql_ha_fix_cond_and_key(handler, mode, keyname, key_expr, cond, 1))
DBUG_RETURN(0);
DBUG_RETURN(handler);