Skip to content

Commit cc86a0b

Browse files
committed
MDEV-15572: view.test, server crash with --big-tables=1
Check that table is really opened before cleanup using handler.
1 parent 1a79a29 commit cc86a0b

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

mysql-test/r/view.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5732,6 +5732,21 @@ t37, t38, t39, t40, t41, t42, t43, t44, t45,
57325732
t46, t47, t48, t49, t50, t51, t52, t53, t54,
57335733
t55, t56, t57, t58, t59,t60;
57345734
drop view v60;
5735+
#
5736+
# MDEV-15572: view.test, server crash with --big-tables=1
5737+
#
5738+
set @save_big_tables=@@big_tables;
5739+
set big_tables=ON;
5740+
CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int);
5741+
CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int);
5742+
CREATE VIEW v1 AS
5743+
SELECT t2.f1, t1.f2, t2.f3, t2.f4 FROM (t1 JOIN t2);
5744+
REPLACE INTO v1 (f1, f2, f3, f4)
5745+
SELECT f1, f2, f3, f4 FROM t1;
5746+
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
5747+
drop view v1;
5748+
drop table t1, t2;
5749+
set big_tables=@save_big_tables;
57355750
# -----------------------------------------------------------------
57365751
# -- End of 5.5 tests.
57375752
# -----------------------------------------------------------------

mysql-test/t/view.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5674,6 +5674,26 @@ t46, t47, t48, t49, t50, t51, t52, t53, t54,
56745674
t55, t56, t57, t58, t59,t60;
56755675
drop view v60;
56765676

5677+
--echo #
5678+
--echo # MDEV-15572: view.test, server crash with --big-tables=1
5679+
--echo #
5680+
5681+
set @save_big_tables=@@big_tables;
5682+
set big_tables=ON;
5683+
CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int);
5684+
CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int);
5685+
5686+
CREATE VIEW v1 AS
5687+
SELECT t2.f1, t1.f2, t2.f3, t2.f4 FROM (t1 JOIN t2);
5688+
5689+
--error ER_VIEW_MULTIUPDATE
5690+
REPLACE INTO v1 (f1, f2, f3, f4)
5691+
SELECT f1, f2, f3, f4 FROM t1;
5692+
5693+
drop view v1;
5694+
drop table t1, t2;
5695+
set big_tables=@save_big_tables;
5696+
56775697
--echo # -----------------------------------------------------------------
56785698
--echo # -- End of 5.5 tests.
56795699
--echo # -----------------------------------------------------------------

sql/sql_insert.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3743,8 +3743,12 @@ void select_insert::abort_result_set() {
37433743
example), no table will have been opened and therefore 'table'
37443744
will be NULL. In that case, we still need to execute the rollback
37453745
and the end of the function.
3746+
3747+
If it fail due to inability to insert in multi-table view for example,
3748+
table will be assigned with view table structure, but that table will
3749+
not be opened really (it is dummy to check fields types & Co).
37463750
*/
3747-
if (table)
3751+
if (table && table->file->get_table())
37483752
{
37493753
bool changed, transactional_table;
37503754
/*

0 commit comments

Comments
 (0)