| 1 |
-- source include/have_ndb.inc |
| 2 |
|
| 3 |
# |
| 4 |
# Run all the commands which should take the global schema lock |
| 5 |
# and thus increment the ndb_schema_locks_count variable |
| 6 |
# |
| 7 |
--source ndb_init_schema_locks_count.inc |
| 8 |
CREATE DATABASE test2; |
| 9 |
--source ndb_schema_locks_count.inc |
| 10 |
|
| 11 |
--source ndb_init_schema_locks_count.inc |
| 12 |
ALTER DATABASE test2 CHARACTER SET latin2; |
| 13 |
--source ndb_schema_locks_count.inc |
| 14 |
|
| 15 |
--source ndb_init_schema_locks_count.inc |
| 16 |
DROP DATABASE test2; |
| 17 |
--source ndb_schema_locks_count.inc |
| 18 |
|
| 19 |
--source ndb_init_schema_locks_count.inc |
| 20 |
CREATE TABLE t1(a int not null primary key) ENGINE ndb; |
| 21 |
--source ndb_schema_locks_count.inc |
| 22 |
|
| 23 |
--source ndb_init_schema_locks_count.inc |
| 24 |
RENAME TABLE t1 TO t2; |
| 25 |
--source ndb_schema_locks_count.inc |
| 26 |
|
| 27 |
--source ndb_init_schema_locks_count.inc |
| 28 |
CREATE TABLE t3 LIKE t2; |
| 29 |
--source ndb_schema_locks_count.inc |
| 30 |
|
| 31 |
--source ndb_init_schema_locks_count.inc |
| 32 |
ALTER TABLE t3 ADD COLUMN b int default NULL; |
| 33 |
--source ndb_schema_locks_count.inc |
| 34 |
|
| 35 |
# Insert a row to truncate |
| 36 |
INSERT INTO t2 VALUES(1); |
| 37 |
|
| 38 |
--source ndb_init_schema_locks_count.inc |
| 39 |
TRUNCATE TABLE t2; |
| 40 |
--source ndb_schema_locks_count.inc |
| 41 |
|
| 42 |
--source ndb_init_schema_locks_count.inc |
| 43 |
--disable_warnings |
| 44 |
CREATE TABLE t4 ENGINE=NDB AS SELECT * FROM t2; |
| 45 |
--enable_warnings |
| 46 |
--source ndb_schema_locks_count.inc |
| 47 |
|
| 48 |
--source ndb_init_schema_locks_count.inc |
| 49 |
DROP TABLE t2; |
| 50 |
--source ndb_schema_locks_count.inc |
| 51 |
|
| 52 |
--source ndb_init_schema_locks_count.inc |
| 53 |
DROP TABLE t3, t4; |
| 54 |
--source ndb_schema_locks_count.inc |
| 55 |
|
| 56 |
|
| 57 |
# |
| 58 |
# Testing GSL behaviour combined with LOCK TABLES |
| 59 |
# |
| 60 |
# NOTE! Using LOCK TABLES should not be a way to circumvent |
| 61 |
# global schema locking |
| 62 |
# |
| 63 |
|
| 64 |
CREATE TABLE t10(a int primary key) ENGINE ndb; |
| 65 |
|
| 66 |
# |
| 67 |
# Database DDL with READ lock, should return error |
| 68 |
# |
| 69 |
LOCK TABLES t10 READ; |
| 70 |
--error ER_LOCK_OR_ACTIVE_TRANSACTION |
| 71 |
CREATE DATABASE test2; |
| 72 |
--error ER_LOCK_OR_ACTIVE_TRANSACTION |
| 73 |
ALTER DATABASE test2 CHARACTER SET latin2; |
| 74 |
--error ER_LOCK_OR_ACTIVE_TRANSACTION |
| 75 |
DROP DATABASE test2; |
| 76 |
UNLOCK TABLES; |
| 77 |
|
| 78 |
# |
| 79 |
# Database DDL with WRITE lock, should return error |
| 80 |
# |
| 81 |
LOCK TABLES t10 WRITE; |
| 82 |
--error ER_LOCK_OR_ACTIVE_TRANSACTION |
| 83 |
CREATE DATABASE test2; |
| 84 |
--error ER_LOCK_OR_ACTIVE_TRANSACTION |
| 85 |
ALTER DATABASE test2 CHARACTER SET latin2; |
| 86 |
--error ER_LOCK_OR_ACTIVE_TRANSACTION |
| 87 |
DROP DATABASE test2; |
| 88 |
UNLOCK TABLES; |
| 89 |
|
| 90 |
# |
| 91 |
# Table DDL with READ lock |
| 92 |
# |
| 93 |
LOCK TABLES t10 READ; |
| 94 |
# Catch 22, not possible to lock table until created |
| 95 |
--error ER_TABLE_NOT_LOCKED |
| 96 |
CREATE TABLE t1(a int not null primary key); |
| 97 |
--error ER_TABLE_NOT_LOCKED_FOR_WRITE |
| 98 |
RENAME TABLE t10 TO t2; |
| 99 |
# Catch 22, not possible to lock table until created |
| 100 |
--error ER_TABLE_NOT_LOCKED |
| 101 |
CREATE TABLE t3 LIKE t10; |
| 102 |
--error ER_TABLE_NOT_LOCKED_FOR_WRITE |
| 103 |
ALTER TABLE t10 ADD COLUMN b int default NULL; |
| 104 |
--error ER_TABLE_NOT_LOCKED_FOR_WRITE |
| 105 |
TRUNCATE TABLE t10; |
| 106 |
# Catch 22, not possible to lock table until created |
| 107 |
--error ER_TABLE_NOT_LOCKED |
| 108 |
CREATE TABLE t4 AS SELECT * FROM t10; |
| 109 |
--error ER_TABLE_NOT_LOCKED_FOR_WRITE |
| 110 |
DROP TABLE t10; |
| 111 |
UNLOCK TABLES; |
| 112 |
|
| 113 |
# |
| 114 |
# Table DDL with WRITE lock |
| 115 |
# |
| 116 |
LOCK TABLES t10 WRITE; |
| 117 |
# Catch 22, not possible to lock table until created |
| 118 |
--error ER_TABLE_NOT_LOCKED |
| 119 |
CREATE TABLE t1(a int not null primary key); |
| 120 |
# Catch 22, not possible to lock table until created |
| 121 |
--error ER_TABLE_NOT_LOCKED |
| 122 |
CREATE TABLE t3 LIKE t10; |
| 123 |
--source ndb_init_schema_locks_count.inc |
| 124 |
ALTER TABLE t10 ADD COLUMN b int default NULL; |
| 125 |
--source ndb_schema_locks_count.inc |
| 126 |
--source ndb_init_schema_locks_count.inc |
| 127 |
TRUNCATE TABLE t10; |
| 128 |
--source ndb_schema_locks_count.inc |
| 129 |
# Catch 22, not possible to lock table until created |
| 130 |
--error ER_TABLE_NOT_LOCKED |
| 131 |
CREATE TABLE t4 AS SELECT * FROM t10; |
| 132 |
# Now allowed due to WL#9826 "Allow RENAME TABLES under LOCK TABLES" |
| 133 |
RENAME TABLE t10 TO t110; |
| 134 |
DROP TABLE t110; |
| 135 |
UNLOCK TABLES; |