Skip to content

Commit

Permalink
MDEV-15729 Server crashes in Field::make_field upon HANDLER READ exec…
Browse files Browse the repository at this point in the history
…uted 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
  • Loading branch information
vuvova committed Jun 11, 2018
1 parent 6da8192 commit ca733d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mysql-test/suite/handler/ps.result
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions mysql-test/suite/handler/ps.test
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions sql/sql_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ca733d0

Please sign in to comment.