List:Commits« Previous MessageNext Message »
From:igor Date:February 6 2007 9:34pm
Subject:bk commit into 5.0 tree (igor:1.2402) BUG#25931
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-02-06 12:34:10-08:00, igor@stripped +3 -0
  Fixed bug #25931.
  View check option clauses were ignored for updates of multi-table
  views when the updates could not be performed on fly and the rows
  to update had to be put into temporary tables first.

  mysql-test/r/view.result@stripped, 2007-02-06 12:34:08-08:00, igor@stripped +27 -1
    Added a test case for bug #25931.

  mysql-test/t/view.test@stripped, 2007-02-06 12:34:08-08:00, igor@stripped +23 -1
    Added a test case for bug #25931.
    Adjusted another existed test case to have the correct result.

  sql/sql_update.cc@stripped, 2007-02-06 12:34:08-08:00, igor@stripped +9 -0
    Fixed bug #25931.
    View check option clauses were ignored for updates of multi-table
    views when the updates could not be performed on fly and the rows
    to update had to be put into temporary tables first.
    Added the required check to multi_update::do_updates to fix the problem.  

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-5.0-opt-bug25931

--- 1.210/sql/sql_update.cc	2007-02-06 12:34:15 -08:00
+++ 1.211/sql/sql_update.cc	2007-02-06 12:34:15 -08:00
@@ -1445,6 +1445,15 @@
 
       if (!can_compare_record || compare_record(table, thd->query_id))
       {
+	int error;
+        if ((error= cur_table->view_check_option(thd, ignore)) !=
+            VIEW_CHECK_OK)
+        {
+          if (error == VIEW_CHECK_SKIP)
+            continue;
+          else if (error == VIEW_CHECK_ERROR)
+            goto err;
+        }
 	if ((local_error=table->file->update_row(table->record[1],
 						 table->record[0])))
 	{

--- 1.187/mysql-test/r/view.result	2007-02-06 12:34:15 -08:00
+++ 1.188/mysql-test/r/view.result	2007-02-06 12:34:15 -08:00
@@ -2543,7 +2543,7 @@
 create view v1 as select ta.f1 as a, tb.f1 as b from t1 ta, t1 tb where ta.f1=tb
 .f1 and ta.f2=tb.f2;
 insert into t1 values(1,1),(2,2);
-create view v2 as select * from v1 where a > 1 with check option;
+create view v2 as select * from v1 where a > 1 with local check option;
 select * from v2;
 a	b
 2	2
@@ -3034,4 +3034,30 @@
 View	Create View
 v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
 DROP VIEW v1;
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (b int);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1), (2);
+CREATE VIEW v1 AS
+SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION;
+SELECT * FROM v1;
+b
+1
+2
+UPDATE v1 SET b=3;
+ERROR HY000: CHECK OPTION failed 'test.v1'
+SELECT * FROM v1;
+b
+1
+2
+SELECT * FROM t1;
+a
+1
+2
+SELECT * FROM t2;
+b
+1
+2
+DROP VIEW v1;
+DROP TABLE t1,t2;
 End of 5.0 tests.

--- 1.172/mysql-test/t/view.test	2007-02-06 12:34:15 -08:00
+++ 1.173/mysql-test/t/view.test	2007-02-06 12:34:15 -08:00
@@ -2385,7 +2385,7 @@
 create view v1 as select ta.f1 as a, tb.f1 as b from t1 ta, t1 tb where ta.f1=tb
 .f1 and ta.f2=tb.f2;
 insert into t1 values(1,1),(2,2);
-create view v2 as select * from v1 where a > 1 with check option;
+create view v2 as select * from v1 where a > 1 with local check option;
 select * from v2;
 update v2 set b=3 where a=2;
 select * from v2;
@@ -2985,5 +2985,27 @@
 SHOW CREATE VIEW v1;
 
 DROP VIEW v1;
+
+#
+# Bug #25931: update of a multi-table view with check option
+#
+
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (b int);
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1), (2);
+
+CREATE VIEW v1 AS
+  SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION;
+
+SELECT * FROM v1;
+--error 1369
+UPDATE v1 SET b=3;
+SELECT * FROM v1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
 
 --echo End of 5.0 tests.
Thread
bk commit into 5.0 tree (igor:1.2402) BUG#25931igor6 Feb