mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge mysql.com:/home/marty/MySQL/mysql-5.0
into mysql.com:/home/marty/MySQL/mysql-5.1 mysql-test/t/ndb_lock.test: Auto merged sql/ha_ndbcluster.h: Auto merged sql/handler.h: Auto merged storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp: Auto merged storage/ndb/include/ndbapi/NdbScanOperation.hpp: Auto merged mysql-test/r/ndb_lock.result: Merge sql/ha_ndbcluster.cc: Merge storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Merge storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Merge storage/ndb/src/ndbapi/NdbScanOperation.cpp: Merge storage/ndb/src/ndbapi/ndberror.c: Merge
This commit is contained in:
@ -1,14 +1,23 @@
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2 (
|
||||
a bigint unsigned NOT NULL PRIMARY KEY,
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (
|
||||
a bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
b int unsigned not null,
|
||||
c int unsigned
|
||||
) engine=ndbcluster;
|
||||
select count(*) from t2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
5000
|
||||
truncate table t2;
|
||||
select count(*) from t2;
|
||||
select * from t1 order by a limit 2;
|
||||
a b c
|
||||
1 509 2500
|
||||
2 510 7
|
||||
truncate table t1;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
drop table t2;
|
||||
insert into t1 values(NULL,1,1),(NULL,2,2);
|
||||
select * from t1 order by a;
|
||||
a b c
|
||||
1 1 1
|
||||
2 2 2
|
||||
drop table t1;
|
||||
|
@ -69,6 +69,119 @@ insert into t1 values (1,1,1);
|
||||
|
||||
drop table t1;
|
||||
|
||||
# Lock for update
|
||||
|
||||
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
|
||||
|
||||
insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3);
|
||||
|
||||
# PK access
|
||||
connection con1;
|
||||
begin;
|
||||
select * from t1 where x = 1 for update;
|
||||
|
||||
connection con2;
|
||||
begin;
|
||||
select * from t1 where x = 2 for update;
|
||||
--error 1205
|
||||
select * from t1 where x = 1 for update;
|
||||
rollback;
|
||||
|
||||
connection con1;
|
||||
commit;
|
||||
|
||||
# table scan
|
||||
connection con1;
|
||||
begin;
|
||||
select * from t1 where y = 'one' or y = 'three' for update;
|
||||
|
||||
connection con2;
|
||||
begin;
|
||||
# Have to check with pk access here since scans take locks on
|
||||
# all rows and then release them in chunks
|
||||
# Bug #20390 SELECT FOR UPDATE does not release locks of untouched rows in full table scans
|
||||
#select * from t1 where x = 2 for update;
|
||||
--error 1205
|
||||
select * from t1 where x = 1 for update;
|
||||
rollback;
|
||||
|
||||
connection con1;
|
||||
commit;
|
||||
|
||||
# index scan
|
||||
connection con1;
|
||||
begin;
|
||||
select * from t1 where z > 1 and z < 3 for update;
|
||||
|
||||
connection con2;
|
||||
begin;
|
||||
# Have to check with pk access here since scans take locks on
|
||||
# all rows and then release them in chunks
|
||||
select * from t1 where x = 1 for update;
|
||||
--error 1205
|
||||
select * from t1 where x = 2 for update;
|
||||
rollback;
|
||||
|
||||
connection con1;
|
||||
commit;
|
||||
|
||||
# share locking
|
||||
|
||||
# PK access
|
||||
connection con1;
|
||||
begin;
|
||||
select * from t1 where x = 1 lock in share mode;
|
||||
|
||||
connection con2;
|
||||
begin;
|
||||
select * from t1 where x = 1 lock in share mode;
|
||||
select * from t1 where x = 2 for update;
|
||||
--error 1205
|
||||
select * from t1 where x = 1 for update;
|
||||
rollback;
|
||||
|
||||
connection con1;
|
||||
commit;
|
||||
|
||||
# table scan
|
||||
connection con1;
|
||||
begin;
|
||||
select * from t1 where y = 'one' or y = 'three' lock in share mode;
|
||||
|
||||
connection con2;
|
||||
begin;
|
||||
select * from t1 where y = 'one' lock in share mode;
|
||||
# Have to check with pk access here since scans take locks on
|
||||
# all rows and then release them in chunks
|
||||
# Bug #20390 SELECT FOR UPDATE does not release locks of untouched rows in full table scans
|
||||
#select * from t1 where x = 2 for update;
|
||||
--error 1205
|
||||
select * from t1 where x = 1 for update;
|
||||
rollback;
|
||||
|
||||
connection con1;
|
||||
commit;
|
||||
|
||||
# index scan
|
||||
connection con1;
|
||||
begin;
|
||||
select * from t1 where z > 1 and z < 3 lock in share mode;
|
||||
|
||||
connection con2;
|
||||
begin;
|
||||
select * from t1 where z = 1 lock in share mode;
|
||||
# Have to check with pk access here since scans take locks on
|
||||
# all rows and then release them in chunks
|
||||
select * from t1 where x = 1 for update;
|
||||
--error 1205
|
||||
select * from t1 where x = 2 for update;
|
||||
rollback;
|
||||
|
||||
connection con1;
|
||||
commit;
|
||||
|
||||
drop table t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
|
@ -2,12 +2,11 @@
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t2;
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
|
||||
CREATE TABLE t2 (
|
||||
a bigint unsigned NOT NULL PRIMARY KEY,
|
||||
CREATE TABLE t1 (
|
||||
a bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
b int unsigned not null,
|
||||
c int unsigned
|
||||
) engine=ndbcluster;
|
||||
@ -20,17 +19,23 @@ let $1=500;
|
||||
disable_query_log;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t2 values($1*10, $1+9, 5*$1), ($1*10+1, $1+10, 7),($1*10+2, $1+10, 7*$1), ($1*10+3, $1+10, 10+$1), ($1*10+4, $1+10, 70*$1), ($1*10+5, $1+10, 7), ($1*10+6, $1+10, 9), ($1*10+7, $1+299, 899), ($1*10+8, $1+10, 12), ($1*10+9, $1+10, 14*$1);
|
||||
eval insert into t1 values(NULL, $1+9, 5*$1), (NULL, $1+10, 7),(NULL, $1+10, 7*$1), (NULL, $1+10, 10+$1), (NULL, $1+10, 70*$1), (NULL, $1+10, 7), (NULL, $1+10, 9), (NULL, $1+299, 899), (NULL, $1+10, 12), (NULL, $1+10, 14*$1);
|
||||
dec $1;
|
||||
}
|
||||
enable_query_log;
|
||||
|
||||
select count(*) from t2;
|
||||
select count(*) from t1;
|
||||
|
||||
truncate table t2;
|
||||
select * from t1 order by a limit 2;
|
||||
|
||||
select count(*) from t2;
|
||||
truncate table t1;
|
||||
|
||||
drop table t2;
|
||||
select count(*) from t1;
|
||||
|
||||
insert into t1 values(NULL,1,1),(NULL,2,2);
|
||||
|
||||
select * from t1 order by a;
|
||||
|
||||
drop table t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
Reference in New Issue
Block a user