diff options
author | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-02-18 14:54:38 +0100 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-02-18 14:54:38 +0100 |
commit | 813ad38ef4538a7de0cfa618d252822d2d6d510c (patch) | |
tree | a0aa3df92234543674ec89cc1a34e3e77ec06808 /mysql-test/r/view.result | |
parent | 2529fa94edbb8d0f882253a89a805f568b9b6179 (diff) | |
download | mariadb-git-813ad38ef4538a7de0cfa618d252822d2d6d510c.tar.gz |
Bug #48315 Metadata lock is not taken for merged views that use
an INFORMATION_SCHEMA table
When a prepared statement using a merged view containing an information
schema table was executed, a metadata lock of the view was not taken.
This meant that it was possible for concurrent view DDL to execute,
thereby breaking the binary log. For example, it was possible
for DROP VIEW to appear in the binary log before a query using the view.
This also happened when a statement in a stored routine was executed a
second time.
For such views, the information schema table is merged into the view
during the prepare phase (or first execution of a statement in a routine).
The problem was that we took a short cut and were not executing full-blown
view opening during subsequent executions of the statement. As a result,
a metadata lock on the view was not taken to protect the view definition.
This patch resolves the problem by making sure a metadata lock is taken
for views even after information schema tables are merged into them.
Test cased added to view.test.
Diffstat (limited to 'mysql-test/r/view.result')
-rw-r--r-- | mysql-test/r/view.result | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 4c0acc2eb6a..5c5afd2a0ec 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4004,3 +4004,36 @@ CREATE VIEW t2 AS SELECT * FROM t1; ERROR HY000: Can't execute the query because you have a conflicting read lock UNLOCK TABLES; DROP TABLE t1, t2; +# +# Bug#48315 Metadata lock is not taken for merged views that +# use an INFORMATION_SCHEMA table +# +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP PROCEDURE IF EXISTS p1; +# Connection default +CREATE VIEW v1 AS SELECT schema_name FROM information_schema.schemata; +CREATE TABLE t1 (str VARCHAR(50)); +CREATE PROCEDURE p1() INSERT INTO t1 SELECT * FROM v1; +# CALL p1() so the view is merged. +CALL p1(); +# Connection 3 +LOCK TABLE t1 READ; +# Connection default +# Try to CALL p1() again, this time it should block for t1. +# Sending: +CALL p1(); +# Connection 2 +# ... then try to drop the view. This should block. +# Sending: +DROP VIEW v1; +# Connection 3 +# Now allow CALL p1() to complete +UNLOCK TABLES; +# Connection default +# Reaping: CALL p1() +# Connection 2 +# Reaping: DROP VIEW v1 +# Connection default +DROP PROCEDURE p1; +DROP TABLE t1; |