| 1 |
# manual ndb_import tests |
| 2 |
# database argument is required |
| 3 |
# no args is ok |
| 4 |
# table does not exist |
| 5 |
create table t1 ( |
| 6 |
a int primary key, |
| 7 |
b int not null |
| 8 |
) engine=ndb; |
| 9 |
# csv file does not exist |
| 10 |
# bad state dir |
| 11 |
# normal import |
| 12 |
select count(*) from t1; |
| 13 |
count(*) |
| 14 |
1000 |
| 15 |
# invalid --input-type |
| 16 |
# invalid --output-type |
| 17 |
# test --connections and --ndb-nodeid |
| 18 |
# needs consecutive api nodes 230,231,232 |
| 19 |
delete from t1; |
| 20 |
create table t1ver like t1; |
| 21 |
select count(*) from t1 x, t1ver y |
| 22 |
where x.a = y.a and x.b = y.b; |
| 23 |
count(*) |
| 24 |
1000 |
| 25 |
# simple utf8 test |
| 26 |
create table t2 ( |
| 27 |
a int primary key, |
| 28 |
b char(3) |
| 29 |
) charset utf8mb4 |
| 30 |
engine=ndb; |
| 31 |
create table t2ver ( |
| 32 |
a int primary key, |
| 33 |
b char(3) |
| 34 |
) charset utf8mb4 |
| 35 |
engine=ndb; |
| 36 |
select count(*) from t2 x, t2ver y |
| 37 |
where x.a = y.a |
| 38 |
and (x.b = y.b or (x.b is null and y.b is null)); |
| 39 |
count(*) |
| 40 |
4 |
| 41 |
# test with rejects and no --keep-state |
| 42 |
create table t4 ( |
| 43 |
a int primary key, |
| 44 |
b int not null |
| 45 |
) engine=ndb; |
| 46 |
select count(*) from t4; |
| 47 |
count(*) |
| 48 |
997 |
| 49 |
# test with rejects and --stats |
| 50 |
delete from t4; |
| 51 |
select count(*) from t4; |
| 52 |
count(*) |
| 53 |
997 |
| 54 |
# test --continue option with missing table |
| 55 |
create table t5a (a int primary key) engine=ndb; |
| 56 |
create table t5c like t5a; |
| 57 |
select count(*) from t5a; |
| 58 |
count(*) |
| 59 |
2 |
| 60 |
select count(*) from t5c; |
| 61 |
count(*) |
| 62 |
2 |
| 63 |
# test --continue option with rejects |
| 64 |
delete from t5a; |
| 65 |
delete from t5c; |
| 66 |
create table t5b like t5a; |
| 67 |
select count(*) from t5a; |
| 68 |
count(*) |
| 69 |
2 |
| 70 |
select count(*) from t5b; |
| 71 |
count(*) |
| 72 |
1 |
| 73 |
select count(*) from t5c; |
| 74 |
count(*) |
| 75 |
2 |
| 76 |
# test quoting and escapes |
| 77 |
create table t6 ( |
| 78 |
a int primary key, |
| 79 |
b char(5) not null |
| 80 |
) engine=ndb; |
| 81 |
create table t6ver like t6; |
| 82 |
select count(*) from t6 x, t6ver y |
| 83 |
where x.a = y.a and x.b = y.b; |
| 84 |
count(*) |
| 85 |
7 |
| 86 |
select a from t6 |
| 87 |
where b like '%"%' |
| 88 |
order by a; |
| 89 |
a |
| 90 |
3 |
| 91 |
4 |
| 92 |
5 |
| 93 |
# test CR-LF line terminator |
| 94 |
create table t7 ( |
| 95 |
a int primary key, |
| 96 |
b varbinary(20) |
| 97 |
) engine=ndb; |
| 98 |
create table t7ver like t7; |
| 99 |
select count(*) from t7 x, t7ver y |
| 100 |
where x.a = y.a |
| 101 |
and (x.b = y.b or (x.b is null and y.b is null)); |
| 102 |
count(*) |
| 103 |
1000 |
| 104 |
# test windows directory separator |
| 105 |
delete from t7; |
| 106 |
select count(*) from t7; |
| 107 |
count(*) |
| 108 |
1000 |
| 109 |
t7.csv |
| 110 |
t7.map |
| 111 |
t7.rej |
| 112 |
t7.res |
| 113 |
# test NUL byte |
| 114 |
create table t8 ( |
| 115 |
a int primary key, |
| 116 |
b varbinary(20) |
| 117 |
) engine=ndb; |
| 118 |
create table t8ver like t8; |
| 119 |
select count(*) from t8 x, t8ver y |
| 120 |
where x.a = y.a |
| 121 |
and (x.b = y.b or (x.b is null and y.b is null)); |
| 122 |
count(*) |
| 123 |
1000 |
| 124 |
# test long field and line terminators |
| 125 |
create table t9 ( |
| 126 |
a int primary key, |
| 127 |
b char(10), |
| 128 |
c char(10) |
| 129 |
) engine=ndb; |
| 130 |
create table t9ver like t9; |
| 131 |
select * from t9ver order by a; |
| 132 |
a b c |
| 133 |
0 123 abc |
| 134 |
1 :456= :foo= |
| 135 |
2 789=== bar=== |
| 136 |
3 123 abc |
| 137 |
4 :456= :foo= |
| 138 |
5 789=== bar=== |
| 139 |
select count(*) from t9 x, t9ver y |
| 140 |
where x.a = y.a |
| 141 |
and (x.b = y.b or (x.b is null and y.b is null)) |
| 142 |
and (x.c = y.c or (x.c is null and y.c is null)); |
| 143 |
count(*) |
| 144 |
6 |
| 145 |
# run backup |
| 146 |
SELECT * FROM t6 WHERE a > 30 order by a; |
| 147 |
a b |
| 148 |
31 xyz |
| 149 |
32 Rfc |
| 150 |
33 |
| 151 |
34 |
| 152 |
CREATE TABLE tpersons ( |
| 153 |
id INT NOT NULL PRIMARY KEY, |
| 154 |
date_born DATE NOT NULL, |
| 155 |
first_name VARCHAR(14) NOT NULL COLUMN_FORMAT FIXED, |
| 156 |
last_name VARCHAR(16) NOT NULL COLUMN_FORMAT FIXED, |
| 157 |
gender CHAR(1) NOT NULL, |
| 158 |
date_died DATE NOT NULL |
| 159 |
) engine=ndb CHARACTER SET latin1; |
| 160 |
include/assert_grep.inc [Require CSV parser to fail with syntax error] |
| 161 |
create table t10 ( |
| 162 |
a int primary key, |
| 163 |
b int not null, |
| 164 |
c varchar(16) not null |
| 165 |
) engine=ndb CHARACTER SET latin1; |
| 166 |
include/assert_grep.inc [No --table argument and csv filename does not match any table name] |
| 167 |
delete from t10; |
| 168 |
create table t10ver like t10; |
| 169 |
select count(*) from t10 x, t10ver y |
| 170 |
where x.a = y.a and x.b = y.b and x.c = y.c; |
| 171 |
count(*) |
| 172 |
5 |
| 173 |
delete from t10; |
| 174 |
# check .rej file exists and match the input csv filename |
| 175 |
# check .rej file matching the table name does not exists |
| 176 |
delete from t10; |
| 177 |
# check order matters when using --csvopt and --fields-terminated-by |
| 178 |
create table t11 ( |
| 179 |
a varchar(16) null |
| 180 |
) engine=ndb CHARACTER SET latin1; |
| 181 |
SELECT COUNT(*), SUM(a IS NULL), SUM(a = '') FROM t11 ORDER BY a; |
| 182 |
COUNT(*) SUM(a IS NULL) SUM(a = '') |
| 183 |
6 2 4 |
| 184 |
delete from t11; |
| 185 |
create table t11ver like t11; |
| 186 |
SELECT COUNT(*), SUM(a IS NULL), SUM(a = '') FROM t11ver ORDER BY a; |
| 187 |
COUNT(*) SUM(a IS NULL) SUM(a = '') |
| 188 |
6 2 4 |
| 189 |
select count(*) from t11 x, t11ver y |
| 190 |
where ifnull(x.a,'NULL') = ifnull(y.a,'NULL'); |
| 191 |
count(*) |
| 192 |
20 |
| 193 |
delete from t11; |
| 194 |
create table t12 ( |
| 195 |
a int auto_increment primary key, |
| 196 |
b varchar(16) null |
| 197 |
) engine=ndb CHARACTER SET latin1; |
| 198 |
SELECT COUNT(*), SUM(b IS NULL), SUM(b = '') FROM t12 ORDER BY b; |
| 199 |
COUNT(*) SUM(b IS NULL) SUM(b = '') |
| 200 |
6 2 4 |
| 201 |
delete from t12; |
| 202 |
create table t12ver like t12; |
| 203 |
SELECT COUNT(*), SUM(b IS NULL), SUM(b = '') FROM t12ver ORDER BY b; |
| 204 |
COUNT(*) SUM(b IS NULL) SUM(b = '') |
| 205 |
6 2 4 |
| 206 |
select count(*) from t12 x, t12ver y |
| 207 |
where ifnull(x.b,'NULL') = ifnull(y.b,'NULL'); |
| 208 |
count(*) |
| 209 |
20 |
| 210 |
delete from t12; |
| 211 |
select count(*) from t11ver x, t12ver y |
| 212 |
where ifnull(x.a,'NULL') = ifnull(y.b,'NULL'); |
| 213 |
count(*) |
| 214 |
20 |
| 215 |
create table t13 ( |
| 216 |
a varchar(127) collate utf8mb4_unicode_ci, |
| 217 |
b binary(255), |
| 218 |
primary key(a,b) |
| 219 |
) engine=ndb; |
| 220 |
# errins-type=bug34917498, use small computeHash scratch buffer |
| 221 |
create table t14 ( |
| 222 |
a varchar(767) collate utf8mb4_unicode_ci primary key, |
| 223 |
b int not null |
| 224 |
) engine=ndb; |
| 225 |
Warnings: |
| 226 |
Warning 1296 Specified key 'PRIMARY' was too long (max = 3056 bytes); statistics will not be generated |
| 227 |
# errins-type=bug34917498, use small computeHash scratch buffer |
| 228 |
include/assert_grep.inc [Found expected error ndb-4278] |
| 229 |
create table t15a ( |
| 230 |
a int primary key, |
| 231 |
b tinyint unsigned |
| 232 |
) engine=ndb CHARACTER SET latin1; |
| 233 |
create table t15b ( |
| 234 |
a int primary key, |
| 235 |
b smallint unsigned |
| 236 |
) engine=ndb CHARACTER SET latin1; |
| 237 |
create table t15c ( |
| 238 |
a int primary key, |
| 239 |
b mediumint unsigned |
| 240 |
) engine=ndb CHARACTER SET latin1; |
| 241 |
create table t15d ( |
| 242 |
a int primary key, |
| 243 |
b int unsigned |
| 244 |
) engine=ndb CHARACTER SET latin1; |
| 245 |
create table t15e ( |
| 246 |
a int primary key, |
| 247 |
b bigint unsigned |
| 248 |
) engine=ndb CHARACTER SET latin1; |
| 249 |
include/assert_grep.inc [Rows containing negative values for t15a.b are rejected] |
| 250 |
select * from t15a order by a; |
| 251 |
a b |
| 252 |
1 1 |
| 253 |
3 168 |
| 254 |
4 222 |
| 255 |
5 174 |
| 256 |
7 7 |
| 257 |
include/assert_grep.inc [Rows containing negative values for t15b.b are rejected] |
| 258 |
select * from t15b order by a; |
| 259 |
a b |
| 260 |
1 1 |
| 261 |
3 168 |
| 262 |
4 222 |
| 263 |
5 174 |
| 264 |
7 7 |
| 265 |
include/assert_grep.inc [Rows containing negative values for t15c.b are rejected] |
| 266 |
select * from t15c order by a; |
| 267 |
a b |
| 268 |
1 1 |
| 269 |
3 168 |
| 270 |
4 222 |
| 271 |
5 174 |
| 272 |
7 7 |
| 273 |
include/assert_grep.inc [Rows containing negative values for t15d.b are rejected] |
| 274 |
select * from t15d order by a; |
| 275 |
a b |
| 276 |
1 1 |
| 277 |
3 168 |
| 278 |
4 222 |
| 279 |
5 174 |
| 280 |
7 7 |
| 281 |
include/assert_grep.inc [Rows containing negative values for t15e.b are rejected] |
| 282 |
select * from t15e order by a; |
| 283 |
a b |
| 284 |
1 1 |
| 285 |
3 168 |
| 286 |
4 222 |
| 287 |
5 174 |
| 288 |
7 7 |
| 289 |
drop table tpersons; |
| 290 |
drop table t1, t1ver, t2, t2ver, t4, t5a, t5b, t5c, |
| 291 |
t6, t6ver, t7, t7ver, t8, t8ver, t9, t9ver, t10, t10ver, |
| 292 |
t11, t11ver, t12, t12ver, t13, t14, t15a, t15b, t15c, t15d, t15e; |