summaryrefslogtreecommitdiff
path: root/mysql-test/r/ps_ddl.result
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2009-12-10 13:37:18 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2009-12-10 13:37:18 +0100
commit58a9857bc5091bf08b3b3d7bd5221c5ae2a84b53 (patch)
treeed39d148a9de59b92d9f8a2f84135a1986504c87 /mysql-test/r/ps_ddl.result
parent69f677b215dcc51b40c53d7ee9293a17116b5d93 (diff)
downloadmariadb-git-58a9857bc5091bf08b3b3d7bd5221c5ae2a84b53.tar.gz
Backport of revno: 3673
Bug #47313 assert in check_key_in_view during CALL procedure View definitions are inlined in a stored procedure when the procedure is fist called. This means that if a temporary table is later added with the same name as the view, the stored procedure will still use the view. This happens even if temporary tables normally shadow base tables/views. The reason for the assert was that even if the stored procedure referenced the view, open_table() still tried to open the temporary table. This "half view/half temporary table" state caused the assert. The bug was not present in 5.1 as open_table() is not called for the view there. This code was changed with the introduction of MDL in order to properly lock the view and any objects it refers to. This patch fixes the problem by instructing open_table() to open base tables/views (using OT_BASE_ONLY) when reopening tables/views used by stored procedures. This also means that a prepared statement is no longer invalidated if a temporary table is created with the same name as a view used in the prepared statement. Test case added to sp.test. The test case also demonstrates the effect of sp cache invalidation between CALLs. mysql-test/t/ps_ddl.test: Extended the VIEW->TEMPORARY TABLE transition test to cover not only merged views, but now also materialized views and views containing a reference to an information schema table. Test also updated to reflect the change to prepared statement invalidatation.
Diffstat (limited to 'mysql-test/r/ps_ddl.result')
-rw-r--r--mysql-test/r/ps_ddl.result61
1 files changed, 60 insertions, 1 deletions
diff --git a/mysql-test/r/ps_ddl.result b/mysql-test/r/ps_ddl.result
index 3d57c8f7332..c72d129c8e4 100644
--- a/mysql-test/r/ps_ddl.result
+++ b/mysql-test/r/ps_ddl.result
@@ -707,6 +707,9 @@ deallocate prepare stmt;
=====================================================================
Part 16: VIEW -> TEMPORARY TABLE transitions
=====================================================================
+#
+# Test 1: Merged view
+#
create table t2 (a int);
insert into t2 (a) values (1);
create view t1 as select * from t2;
@@ -720,18 +723,74 @@ SUCCESS
create temporary table t1 (a int);
execute stmt;
a
-call p_verify_reprepare_count(1);
+1
+call p_verify_reprepare_count(0);
SUCCESS
drop view t1;
execute stmt;
+ERROR 42S02: Table 'test.t1' doesn't exist
+call p_verify_reprepare_count(0);
+SUCCESS
+
+drop table t2;
+drop temporary table t1;
+deallocate prepare stmt;
+#
+# Test 2: Materialized view
+#
+create table t2 (a int);
+insert into t2 (a) values (1);
+create algorithm = temptable view t1 as select * from t2;
+prepare stmt from "select * from t1";
+execute stmt;
a
+1
+call p_verify_reprepare_count(0);
+SUCCESS
+
+create temporary table t1 (a int);
+execute stmt;
+a
+1
+call p_verify_reprepare_count(0);
+SUCCESS
+
+drop view t1;
+execute stmt;
+ERROR 42S02: Table 'test.t1' doesn't exist
call p_verify_reprepare_count(0);
SUCCESS
drop table t2;
drop temporary table t1;
deallocate prepare stmt;
+#
+# Test 3: View referencing an Information schema table
+#
+create view t1 as select table_name from information_schema.views;
+prepare stmt from "select * from t1";
+execute stmt;
+table_name
+t1
+call p_verify_reprepare_count(0);
+SUCCESS
+
+create temporary table t1 (a int);
+execute stmt;
+table_name
+t1
+call p_verify_reprepare_count(0);
+SUCCESS
+
+drop view t1;
+execute stmt;
+table_name
+call p_verify_reprepare_count(0);
+SUCCESS
+
+drop temporary table t1;
+deallocate prepare stmt;
=====================================================================
Part 17: VIEW -> VIEW (DDL) transitions
=====================================================================