diff options
Diffstat (limited to 'mysql-test/t/ndb_basic.test')
-rw-r--r-- | mysql-test/t/ndb_basic.test | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 271357ed561..0487e18cdb9 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -2,6 +2,7 @@ --disable_warnings DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; --enable_warnings # @@ -14,31 +15,34 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; # CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, - attr1 INT NOT NULL + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10) ) ENGINE=ndbcluster; -INSERT INTO t1 VALUES (9410,9412); +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); -SELECT pk1 FROM t1; -SELECT * FROM t1; -SELECT t1.* FROM t1; +SELECT pk1 FROM t1 ORDER BY pk1; +SELECT * FROM t1 ORDER BY pk1; +SELECT t1.* FROM t1 ORDER BY pk1; # Update on record by primary key UPDATE t1 SET attr1=1 WHERE pk1=9410; -SELECT * FROM t1; +SELECT * FROM t1 ORDER BY pk1; -# Can't UPDATE PK! Test that correct error is returned --- error 1112 +# Update primary key UPDATE t1 SET pk1=2 WHERE attr1=1; -SELECT * FROM t1; +SELECT * FROM t1 ORDER BY pk1; +UPDATE t1 SET pk1=pk1 + 1; +SELECT * FROM t1 ORDER BY pk1; # Delete the record DELETE FROM t1; SELECT * FROM t1; # Insert more records and update them all at once -INSERT INTO t1 VALUES (9410,9412), (9411, 9413), (9408, 8765), -(7,8), (8,9), (9,10), (10,11), (11,12), (12,13), (13,14); +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9408, 8765, NULL, '8765'), +(7,8, NULL, NULL), (8,9, NULL, NULL), (9,10, NULL, NULL), (10,11, NULL, NULL), (11,12, NULL, NULL), (12,13, NULL, NULL), (13,14, NULL, NULL); UPDATE t1 SET attr1 = 9999; SELECT * FROM t1 ORDER BY pk1; @@ -58,13 +62,13 @@ SELECT * FROM t1; # Insert three records with attr1=4 and two with attr1=5 # Delete all with attr1=4 -INSERT INTO t1 values (1, 4), (2, 4), (3, 5), (4, 4), (5, 5); +INSERT INTO t1 values (1, 4, NULL, NULL), (2, 4, NULL, NULL), (3, 5, NULL, NULL), (4, 4, NULL, NULL), (5, 5, NULL, NULL); DELETE FROM t1 WHERE attr1=4; SELECT * FROM t1 order by pk1; DELETE FROM t1; # Insert two records and delete one -INSERT INTO t1 VALUES (9410,9412), (9411, 9413); +INSERT INTO t1 VALUES (9410,9412, NULL, NULL), (9411, 9413, NULL, NULL); DELETE FROM t1 WHERE pk1 = 9410; SELECT * FROM t1; DROP TABLE t1; @@ -82,9 +86,10 @@ UPDATE t1 SET id=1234 WHERE id2=7890; SELECT * FROM t1; DELETE FROM t1; -INSERT INTO t1 values(3456, 7890), (3456, 7890), (3456, 7890); -SELECT * FROM t1; +INSERT INTO t1 values(3456, 7890), (3456, 7890), (3456, 7890), (3454, 7890); +SELECT * FROM t1 ORDER BY id; DELETE FROM t1 WHERE id = 3456; +SELECT * FROM t1 ORDER BY id; DROP TABLE t1; @@ -216,6 +221,12 @@ while ($1) } enable_query_log; +delete from t2 where a > 5; +select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; +select a, b FROM t2 outer_table where +a = (select a from t2 where b = outer_table.b ) order by a; + + delete from t2; delete from t3; delete from t4; @@ -315,3 +326,34 @@ delete from t7 where b=23; select * from t7; drop table t7; + +# +# Test multiple databases in one statement +# + +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10) +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); + +create database mysqltest; +use mysqltest; + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +insert into t2 select pk1,attr1,attr2 from test.t1; +select * from t2 order by a; +select b from test.t1, t2 where c = test.t1.attr2; +select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a; + +drop table test.t1, t2; +drop database mysqltest; + |