Commit 3e8f7c85 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-5122: "Commands out of sync", "Malformed packet" or client hang up...

- When INSERT catches an error, it should not attempt to send parts of 
  EXPLAIN output.
parent a1705b76
......@@ -198,3 +198,24 @@ id select_type table type possible_keys key key_len ref rows Extra
3 SUBQUERY t1 index NULL a 5 NULL 3 Using index
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-5122: "Commands out of sync", "Malformed packet" or client hang up on unique key violation
#
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
drop function if exists f1;
create table t1 (a int, unique(a));
create function f1(x int)
returns int
begin
insert into t1 values(x),(x);
return 10;
end|
select f1(100);
ERROR 23000: Duplicate entry '100' for key 'a'
select 'OK';
OK
OK
drop function f1;
drop table t1;
......@@ -169,3 +169,32 @@ explain insert into t2 values
(11, 1+(select max(a+1) from t1));
drop table t1,t2;
--echo #
--echo # MDEV-5122: "Commands out of sync", "Malformed packet" or client hang up on unique key violation
--echo #
drop table if exists t1;
--disable_warnings
drop function if exists f1;
--enable_warnings
create table t1 (a int, unique(a));
delimiter |;
create function f1(x int)
returns int
begin
insert into t1 values(x),(x);
return 10;
end|
delimiter ;|
--error ER_DUP_ENTRY
select f1(100);
select 'OK';
drop function f1;
drop table t1;
......@@ -819,8 +819,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
save_insert_query_plan(thd, table_list);
if (thd->lex->describe)
{
retval= 0;
goto exit_without_my_ok;
retval= thd->lex->explain->send_explain(thd);
goto free_and_exit;
}
/*
......@@ -1170,15 +1170,14 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
DBUG_RETURN(FALSE);
abort:
exit_without_my_ok:
#ifndef EMBEDDED_LIBRARY
if (lock_type == TL_WRITE_DELAYED)
end_delayed_insert(thd);
#endif
if (table != NULL)
table->file->ha_release_auto_increment();
retval= thd->lex->explain->send_explain(thd);
free_and_exit:
if (!joins_freed)
free_underlaid_joins(thd, &thd->lex->select_lex);
thd->abort_on_warning= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment