Skip to content

Commit

Permalink
MDEV-7765: Crash (Assertion `!table || (!table->write_set || bitmap_i…
Browse files Browse the repository at this point in the history
…s_set(table->write_set, field_index) || bitmap_is_set(table->vcol_set, field_index))' fails) on using function over not created table

Problem was that created table was not marked as used (not set query_id) and so opening tables for stored function pick it up (as opened place holder for it) and used changing TABLE internals.
  • Loading branch information
sanja-byelkin committed Feb 9, 2016
1 parent 775cccc commit 6b614c6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mysql-test/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -2483,3 +2483,19 @@ Warnings:
Note 1291 Column 'a' has duplicated value '' in ENUM
drop table t1;
set @@session.collation_server=default;
#
# MDEV-7765: Crash (Assertion `!table || (!table->write_set ||
# bitmap_is_set(table->write_set, field_index) ||
# bitmap_is_set(table->vcol_set, field_index))' fails)
# on using function over not created table
#
CREATE function f1() returns int
BEGIN
declare n int;
set n:= (select count(*) from t1);
return n;
end|
create table t1 as select f1();
ERROR 42S02: Table 'test.t1' doesn't exist
drop function f1;
End of 5.5 tests
21 changes: 21 additions & 0 deletions mysql-test/t/create.test
Original file line number Diff line number Diff line change
Expand Up @@ -2061,3 +2061,24 @@ set @@session.collation_server=filename;
create table t1(a enum('',''));
drop table t1;
set @@session.collation_server=default;

--echo #
--echo # MDEV-7765: Crash (Assertion `!table || (!table->write_set ||
--echo # bitmap_is_set(table->write_set, field_index) ||
--echo # bitmap_is_set(table->vcol_set, field_index))' fails)
--echo # on using function over not created table
--echo #

DELIMITER |;
CREATE function f1() returns int
BEGIN
declare n int;
set n:= (select count(*) from t1);
return n;
end|
DELIMITER ;|
-- error ER_NO_SUCH_TABLE
create table t1 as select f1();
drop function f1;

--echo End of 5.5 tests
2 changes: 2 additions & 0 deletions sql/sql_insert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4151,6 +4151,8 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
DBUG_RETURN(1);
table->mark_columns_needed_for_insert();
table->file->extra(HA_EXTRA_WRITE_CACHE);
// Mark table as used
table->query_id= thd->query_id;
DBUG_RETURN(0);
}

Expand Down

0 comments on commit 6b614c6

Please sign in to comment.