| 1 |
-- source include/have_ndb.inc |
| 2 |
|
| 3 |
# |
| 4 |
# Basic test of UPDATE in NDB |
| 5 |
# |
| 6 |
|
| 7 |
# |
| 8 |
# Create a normal table with primary key |
| 9 |
# |
| 10 |
CREATE TABLE t1 ( |
| 11 |
pk1 INT NOT NULL PRIMARY KEY, |
| 12 |
b INT NOT NULL, |
| 13 |
c INT NOT NULL UNIQUE |
| 14 |
) ENGINE=ndbcluster; |
| 15 |
|
| 16 |
INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2); |
| 17 |
UPDATE t1 set b = c; |
| 18 |
select * from t1 order by pk1; |
| 19 |
UPDATE t1 set pk1 = 4 where pk1 = 1; |
| 20 |
select * from t1 order by pk1; |
| 21 |
--error ER_DUP_ENTRY |
| 22 |
UPDATE t1 set pk1 = 4 where pk1 = 2; |
| 23 |
UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2; |
| 24 |
select * from t1 order by pk1; |
| 25 |
--enable_info |
| 26 |
UPDATE t1 set pk1 = 2 where pk1 = 2; |
| 27 |
--disable_info |
| 28 |
--error ER_DUP_ENTRY |
| 29 |
UPDATE t1 set c = 1 WHERE b IN(0,1,2,3,4); |
| 30 |
UPDATE IGNORE t1 set c = 1 WHERE b IN(0,1,2,3,4); |
| 31 |
--error ER_DUP_ENTRY |
| 32 |
UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; |
| 33 |
UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4; |
| 34 |
select * from t1 order by pk1; |
| 35 |
UPDATE t1 set pk1 = pk1 + 10; |
| 36 |
select * from t1 order by pk1; |
| 37 |
# bug#25817 |
| 38 |
create unique index ib on t1(b); |
| 39 |
update t1 set c = 4 where pk1 = 12; |
| 40 |
update ignore t1 set b = 55 where pk1 = 14; |
| 41 |
select * from t1 order by pk1; |
| 42 |
|
| 43 |
--disable_warnings |
| 44 |
DROP TABLE IF EXISTS t1; |
| 45 |
--enable_warnings |
| 46 |
|
| 47 |
# End of 4.1 tests |
| 48 |
|
| 49 |
# |
| 50 |
# Bug#28158: table->read_set is set incorrectly, |
| 51 |
# causing wrong error message in Falcon |
| 52 |
# |
| 53 |
CREATE TABLE t1 (a int, b int, KEY (a, b)) ENGINE=ndbcluster; |
| 54 |
CREATE TABLE t2 (a int, b int, UNIQUE KEY (a, b)) ENGINE=ndbcluster; |
| 55 |
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a, b)) ENGINE=ndbcluster; |
| 56 |
# |
| 57 |
INSERT INTO t1 VALUES (1, 2); |
| 58 |
INSERT INTO t1 VALUES (2, 2); |
| 59 |
# |
| 60 |
INSERT INTO t2 VALUES (1, 2); |
| 61 |
INSERT INTO t2 VALUES (2, 2); |
| 62 |
# |
| 63 |
INSERT INTO t3 VALUES (1, 2); |
| 64 |
INSERT INTO t3 VALUES (2, 2); |
| 65 |
# |
| 66 |
UPDATE t1 SET a = 1; |
| 67 |
UPDATE t1 SET a = 1 ORDER BY a; |
| 68 |
# |
| 69 |
--error ER_DUP_ENTRY |
| 70 |
UPDATE t2 SET a = 1; |
| 71 |
--error ER_DUP_ENTRY |
| 72 |
UPDATE t2 SET a = 1 ORDER BY a; |
| 73 |
# |
| 74 |
--error ER_DUP_ENTRY |
| 75 |
UPDATE t3 SET a = 1; |
| 76 |
--error ER_DUP_ENTRY |
| 77 |
UPDATE t3 SET a = 1 ORDER BY a; |
| 78 |
# |
| 79 |
SELECT count(*) FROM t1; |
| 80 |
SELECT count(*) FROM t2; |
| 81 |
SELECT count(*) FROM t3; |
| 82 |
SELECT * FROM t1 ORDER by a; |
| 83 |
SELECT * FROM t2 ORDER by a; |
| 84 |
SELECT * FROM t3 ORDER by a; |
| 85 |
# |
| 86 |
--disable_warnings |
| 87 |
DROP TABLE IF EXISTS t1; |
| 88 |
DROP TABLE IF EXISTS t2; |
| 89 |
DROP TABLE IF EXISTS t3; |
| 90 |
--enable_warnings |
| 91 |
|
| 92 |
# Bug#40081 UPDATE....ORDER BY cannot find rows in cluster |
| 93 |
CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT, |
| 94 |
mytext CHAR(30) DEFAULT NULL, |
| 95 |
PRIMARY KEY (`id`) ) ENGINE=ndbcluster; |
| 96 |
insert into t1 values(NULL,"hello"),(NULL,"world"),(NULL,"hello"),(NULL,"world"); |
| 97 |
select * from t1 order by id; |
| 98 |
update t1 set mytext = "goodbye" where mytext = "world" order by mytext; |
| 99 |
select * from t1 order by id; |
| 100 |
|
| 101 |
--disable_warnings |
| 102 |
DROP TABLE IF EXISTS t1; |
| 103 |
--enable_warnings |
| 104 |
|
| 105 |
--echo End of 5.1 tests |
| 106 |
|
| 107 |
# Bug#32495182 ERROR DURING EXECUTION OF BULK UPDATE WITH LIMITS LED TO |
| 108 |
# A DEBUG ASSERT FAILURE |
| 109 |
# |
| 110 |
|
| 111 |
CREATE TABLE t1 ( |
| 112 |
a INT PRIMARY KEY, |
| 113 |
b INT, |
| 114 |
UNIQUE (b) |
| 115 |
) ENGINE NDB; |
| 116 |
|
| 117 |
# Insert 64 rows |
| 118 |
INSERT INTO t1 VALUES (1,1); |
| 119 |
INSERT INTO t1 SELECT a+1, b+1 FROM t1; |
| 120 |
INSERT INTO t1 SELECT a+2, b+2 FROM t1; |
| 121 |
INSERT INTO t1 SELECT a+4, b+4 FROM t1; |
| 122 |
INSERT INTO t1 SELECT a+8, b+8 FROM t1; |
| 123 |
INSERT INTO t1 SELECT a+16, b+16 FROM t1; |
| 124 |
INSERT INTO t1 SELECT a+32, b+32 FROM t1; |
| 125 |
|
| 126 |
# Start a transaction and execute an update modifying the unique indexed |
| 127 |
# column such that it fails due to duplicate entries |
| 128 |
BEGIN; |
| 129 |
--replace_regex /Duplicate entry \'[0-9]+\'/Duplicate entry \'<duplicate entry>\'/ |
| 130 |
--error ER_DUP_ENTRY |
| 131 |
UPDATE t1 SET b=b+10; |
| 132 |
|
| 133 |
# Repeat the above but this time with LIMIT |
| 134 |
BEGIN; |
| 135 |
--replace_regex /Duplicate entry \'[0-9]+\'/Duplicate entry \'<duplicate entry>\'/ |
| 136 |
--error ER_DUP_ENTRY |
| 137 |
UPDATE t1 SET b=b+10 LIMIT 20; |
| 138 |
|
| 139 |
DROP TABLE t1; |