Commit 48af05a8 authored by unknown's avatar unknown

Fixed bug #28561: assertion abort for update on multi-table view with

CHECK OPTION and a subquery in WHERE condition.
The abort was triggered by setting the value of join->tables for
subqueries in the function JOIN::cleanup. This function was called
after an invocation of the JOIN::join_free method for subqueries
used in WHERE condition.


mysql-test/r/view.result:
  Added a test case for bug #28561.
mysql-test/t/view.test:
  Added a test case for bug #28561.
sql/sql_select.cc:
  Fixed bug #28561: assertion abort for update on multi-table view with
  CHECK OPTION and a subquery in WHERE condition.
  The abort was triggered by setting the value of join->tables for
  subqueries in the function JOIN::cleanup. This function was called
  after an invocation of the JOIN::join_free method for subqueries
  used in WHERE condition.
  Setting the value of join->tables to for a subquery created serious
  problems for checking WHERE condition after update of the multi-table
  view as this check is performed in the do_select function right
  after a call of the JOIN::join_free method.
  In fact setting join->tables to 0 in JOIN::cleanup is not needed 
  anywhere in the current code.
parent f7f593ae
...@@ -3367,4 +3367,14 @@ SHOW CREATE VIEW v1; ...@@ -3367,4 +3367,14 @@ SHOW CREATE VIEW v1;
View Create View View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col` v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(1.23456789 as decimal(8,0)) AS `col`
DROP VIEW v1; DROP VIEW v1;
CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int, c int DEFAULT 0);
INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
CREATE VIEW v1 AS
SELECT t2.c FROM t1, t2
WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
UPDATE v1 SET c=1;
DROP VIEW v1;
DROP TABLE t1,t2;
End of 5.0 tests. End of 5.0 tests.
...@@ -3233,4 +3233,23 @@ CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col; ...@@ -3233,4 +3233,23 @@ CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col;
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
DROP VIEW v1; DROP VIEW v1;
#
# Bug #28561: update on multi-table view with CHECK OPTION and
# a subquery in WHERE condition
#
CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int, c int DEFAULT 0);
INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
CREATE VIEW v1 AS
SELECT t2.c FROM t1, t2
WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
UPDATE v1 SET c=1;
DROP VIEW v1;
DROP TABLE t1,t2;
--echo End of 5.0 tests. --echo End of 5.0 tests.
...@@ -6375,7 +6375,6 @@ void JOIN::cleanup(bool full) ...@@ -6375,7 +6375,6 @@ void JOIN::cleanup(bool full)
for (tab= join_tab, end= tab+tables; tab != end; tab++) for (tab= join_tab, end= tab+tables; tab != end; tab++)
tab->cleanup(); tab->cleanup();
table= 0; table= 0;
tables= 0;
} }
else else
{ {
......
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