MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kroki Date:October 10 2006 10:00am
Subject:bk commit into 5.1 tree (kroki:1.2345)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomash. When tomash 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, 2006-10-10 14:00:49+04:00, kroki@stripped +3 -0
  Merge moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.0-bug19111
  into  moonlight.intranet:/home/tomash/src/mysql_ab/mysql-5.1-bug19111
  MERGE: 1.1810.2159.1

  mysql-test/r/view.result@stripped, 2006-10-10 14:00:46+04:00, kroki@stripped +14 -16
    Manual merge.
    MERGE: 1.138.22.1

  mysql-test/t/view.test@stripped, 2006-10-10 14:00:46+04:00, kroki@stripped +35 -38
    Manual merge.
    MERGE: 1.126.19.1

  sql/sql_base.cc@stripped, 2006-10-10 13:58:24+04:00, kroki@stripped +0 -0
    Auto merged
    MERGE: 1.235.68.1

# 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:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-5.1-bug19111/RESYNC

--- 1.355/sql/sql_base.cc	2006-10-10 14:00:56 +04:00
+++ 1.356/sql/sql_base.cc	2006-10-10 14:00:56 +04:00
@@ -1365,6 +1365,10 @@ TABLE_LIST *find_table_in_list(TABLE_LIS
     Also SELECT::exclude_from_table_unique_test used to exclude from check
     tables of main SELECT of multi-delete and multi-update
 
+    We also skip tables with TABLE_LIST::prelocking_placeholder set,
+    because we want to allow SELECTs from them, and their modification
+    will rise the error anyway.
+
     TODO: when we will have table/view change detection we can do this check
           only once for PS/SP
 
@@ -1411,12 +1415,13 @@ TABLE_LIST* unique_table(THD *thd, TABLE
     if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) &&
          (! (res= mysql_lock_have_duplicate(thd, table, table_list)))) ||
         ((!res->table || res->table != table->table) &&
-         res->select_lex && !res->select_lex->exclude_from_table_unique_test))
+         res->select_lex && !res->select_lex->exclude_from_table_unique_test &&
+         !res->prelocking_placeholder))
       break;
     /*
-      If we found entry of this table or or table of SELECT which already
+      If we found entry of this table or table of SELECT which already
       processed in derived table or top select of multi-update/multi-delete
-      (exclude_from_table_unique_test).
+      (exclude_from_table_unique_test) or prelocking placeholder.
     */
     table_list= res->next_global;
     DBUG_PRINT("info",

--- 1.184/mysql-test/r/view.result	2006-10-10 14:00:56 +04:00
+++ 1.185/mysql-test/r/view.result	2006-10-10 14:00:56 +04:00
@@ -2956,4 +2956,18 @@ View	Create View
 v1	CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) AS `MAX(t.ver)` from `t2` `t` where (`t`.`org` = `t2`.`org`))))))
 DROP VIEW v1;
 DROP TABLE t1, t2;
+DROP FUNCTION IF EXISTS f1;
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+CREATE VIEW v1 AS SELECT MAX(i) FROM t1;
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+SET NEW.i = (SELECT * FROM v1) + 1;
+INSERT INTO t1 VALUES (1);
+CREATE FUNCTION f1() RETURNS INT RETURN (SELECT * FROM v1);
+UPDATE t1 SET i= f1();
+DROP FUNCTION f1;
+DROP VIEW v1;
+DROP TABLE t1;
 End of 5.0 tests.

--- 1.166/mysql-test/t/view.test	2006-10-10 14:00:56 +04:00
+++ 1.167/mysql-test/t/view.test	2006-10-10 14:00:56 +04:00
@@ -2884,4 +2884,39 @@ SHOW CREATE VIEW v1;
 
 DROP VIEW v1;
 DROP TABLE t1, t2;
+
+#
+# Bug#19111: TRIGGERs selecting from a VIEW on the firing base table
+# fail
+#
+# Allow to select from a view on a table being modified in a trigger
+# and stored function, since plain select is allowed there.
+#
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+
+CREATE VIEW v1 AS SELECT MAX(i) FROM t1;
+
+# Plain 'SET NEW.i = (SELECT MAX(i) FROM t1) + 1' works, so select
+# from a view should work too.
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+  SET NEW.i = (SELECT * FROM v1) + 1;
+INSERT INTO t1 VALUES (1);
+
+# Plain 'RETURN (SELECT MAX(i) FROM t1)' works in INSERT, so select
+# from a view should work too.
+CREATE FUNCTION f1() RETURNS INT RETURN (SELECT * FROM v1);
+UPDATE t1 SET i= f1();
+
+DROP FUNCTION f1;
+DROP VIEW v1;
+DROP TABLE t1;
+
+
 --echo End of 5.0 tests.
Thread
bk commit into 5.1 tree (kroki:1.2345)kroki10 Oct