summaryrefslogtreecommitdiff
path: root/mysql-test/t/ps.test
diff options
context:
space:
mode:
authorunknown <kroki/tomash@moonlight.home>2007-03-07 19:05:46 +0300
committerunknown <kroki/tomash@moonlight.home>2007-03-07 19:05:46 +0300
commit9ba3f0bdc9b07e11d9f51959267acf4c5ff25a28 (patch)
treec91325d387a7f0afa471b6adf0c79110e92dee22 /mysql-test/t/ps.test
parent7dafdc9958b1bcb2b1ba31a15dd407f05388b387 (diff)
parent36569375b88c6db95b0d810c85c9464b09e6b2b6 (diff)
downloadmariadb-git-9ba3f0bdc9b07e11d9f51959267acf4c5ff25a28.tar.gz
Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1
into moonlight.home:/home/tomash/src/mysql_ab/mysql-5.1-bug18326 mysql-test/r/ps.result: Auto merged mysql-test/t/ps.test: Auto merged sql/sql_prepare.cc: Auto merged
Diffstat (limited to 'mysql-test/t/ps.test')
-rw-r--r--mysql-test/t/ps.test57
1 files changed, 57 insertions, 0 deletions
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 14ee30f6026..9f670f9973f 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -2516,3 +2516,60 @@ set @to_format="10000";
execute stmt2 using @to_format, @dec;
deallocate prepare stmt2;
+
+#
+# BUG#18326: Do not lock table for writing during prepare of statement
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i INT);
+INSERT INTO t2 VALUES (2);
+
+LOCK TABLE t1 READ, t2 WRITE;
+
+connect (conn1, localhost, root, , );
+
+# Prepare never acquires the lock, and thus should not block.
+PREPARE stmt1 FROM "SELECT i FROM t1";
+PREPARE stmt2 FROM "INSERT INTO t2 (i) VALUES (3)";
+
+# This should not block because READ lock on t1 is shared.
+EXECUTE stmt1;
+
+# This should block because WRITE lock on t2 is exclusive.
+send EXECUTE stmt2;
+
+connection default;
+
+SELECT * FROM t2;
+UNLOCK TABLES;
+let $wait_condition= SELECT COUNT(*) = 2 FROM t2;
+--source include/wait_condition.inc
+SELECT * FROM t2;
+
+# DDL and DML works even if some client have a prepared statement
+# referencing the table.
+ALTER TABLE t1 ADD COLUMN j INT;
+ALTER TABLE t2 ADD COLUMN j INT;
+INSERT INTO t1 VALUES (4, 5);
+INSERT INTO t2 VALUES (4, 5);
+
+connection conn1;
+
+reap;
+EXECUTE stmt1;
+EXECUTE stmt2;
+SELECT * FROM t2;
+
+disconnect conn1;
+
+connection default;
+
+DROP TABLE t1, t2;
+
+
+--echo End of 5.1 tests.