Commit f41bd7e5 authored by Varun Gupta's avatar Varun Gupta

MDEV-11060 sql/protocol.cc:532: void Protocol::end_statement(): Assertion `0' failed

In file sql/opt_range.cc,when calculate_cond_selectivity_for_table() is called with optimizer_use_condition_selectivity=4 then
	- thd->no_errors is set to 1
	- the original value of thd->no_error is not restored to its original value
	- this is causing the assertion to fail in the subsequent queries

Fixed by restoring the original value of thd->no_errors
parent 0c79de24
......@@ -1670,6 +1670,26 @@ DROP TABLE t1,t2;
#
# End of 10.0 tests
#
#
# Start of 10.1 tests
#
#
# MDEV-11060: sql/protocol.cc:532: void Protocol::end_statement(): Assertion `0' failed
#
set optimizer_use_condition_selectivity=4;
drop view if exists v1;
create table t1 (a int not null, b int, c int) engine=InnoDB;
create trigger trgi before insert on t1 for each row set new.a=if(new.a is null,new.b,new.c);
create table t2 (d int, e int) engine=InnoDB;
update t1, t2 set a=NULL, b=2, c=NULL where b=d and e=200;
create view v1 as select * from t1, t2 where d=2;
insert v1 (a,c) values (NULL, 20);
ERROR 23000: Column 'a' cannot be null
drop table t1,t2;
drop view v1;
#
# End of 10.1 tests
#
set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
SET SESSION STORAGE_ENGINE=DEFAULT;
......@@ -138,6 +138,39 @@ DROP TABLE t1,t2;
--echo # End of 10.0 tests
--echo #
--echo #
--echo # Start of 10.1 tests
--echo #
--echo #
--echo # MDEV-11060: sql/protocol.cc:532: void Protocol::end_statement(): Assertion `0' failed
--echo #
set optimizer_use_condition_selectivity=4;
--disable_warnings
drop view if exists v1;
--enable_warnings
create table t1 (a int not null, b int, c int) engine=InnoDB;
create trigger trgi before insert on t1 for each row set new.a=if(new.a is null,new.b,new.c);
create table t2 (d int, e int) engine=InnoDB;
update t1, t2 set a=NULL, b=2, c=NULL where b=d and e=200;
create view v1 as select * from t1, t2 where d=2;
--error ER_BAD_NULL_ERROR
insert v1 (a,c) values (NULL, 20);
drop table t1,t2;
drop view v1;
--echo #
--echo # End of 10.1 tests
--echo #
set use_stat_tables= @tmp_ust;
set optimizer_use_condition_selectivity= @tmp_oucs;
SET SESSION STORAGE_ENGINE=DEFAULT;
......@@ -3112,6 +3112,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
}
free_alloc:
thd->no_errors= 0;
thd->mem_root= param.old_root;
free_root(&alloc, MYF(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