# manual ndb_import tests # database argument is required # no args is ok # table does not exist create table t1 ( a int primary key, b int not null ) engine=ndb; # csv file does not exist # bad state dir # normal import select count(*) from t1; count(*) 1000 # invalid --input-type # invalid --output-type # test --connections and --ndb-nodeid # needs consecutive api nodes 230,231,232 delete from t1; create table t1ver like t1; select count(*) from t1 x, t1ver y where x.a = y.a and x.b = y.b; count(*) 1000 # simple utf8 test create table t2 ( a int primary key, b char(3) ) charset utf8mb4 engine=ndb; create table t2ver ( a int primary key, b char(3) ) charset utf8mb4 engine=ndb; select count(*) from t2 x, t2ver y where x.a = y.a and (x.b = y.b or (x.b is null and y.b is null)); count(*) 4 # test with rejects and no --keep-state create table t4 ( a int primary key, b int not null ) engine=ndb; select count(*) from t4; count(*) 997 # test with rejects and --stats delete from t4; select count(*) from t4; count(*) 997 # test --continue option with missing table create table t5a (a int primary key) engine=ndb; create table t5c like t5a; select count(*) from t5a; count(*) 2 select count(*) from t5c; count(*) 2 # test --continue option with rejects delete from t5a; delete from t5c; create table t5b like t5a; select count(*) from t5a; count(*) 2 select count(*) from t5b; count(*) 1 select count(*) from t5c; count(*) 2 # test quoting and escapes create table t6 ( a int primary key, b char(5) not null ) engine=ndb; create table t6ver like t6; select count(*) from t6 x, t6ver y where x.a = y.a and x.b = y.b; count(*) 7 select a from t6 where b like '%"%' order by a; a 3 4 5 # test CR-LF line terminator create table t7 ( a int primary key, b varbinary(20) ) engine=ndb; create table t7ver like t7; select count(*) from t7 x, t7ver y where x.a = y.a and (x.b = y.b or (x.b is null and y.b is null)); count(*) 1000 # test windows directory separator delete from t7; select count(*) from t7; count(*) 1000 t7.csv t7.map t7.rej t7.res # test NUL byte create table t8 ( a int primary key, b varbinary(20) ) engine=ndb; create table t8ver like t8; select count(*) from t8 x, t8ver y where x.a = y.a and (x.b = y.b or (x.b is null and y.b is null)); count(*) 1000 # test long field and line terminators create table t9 ( a int primary key, b char(10), c char(10) ) engine=ndb; create table t9ver like t9; select * from t9ver order by a; a b c 0 123 abc 1 :456= :foo= 2 789=== bar=== 3 123 abc 4 :456= :foo= 5 789=== bar=== select count(*) from t9 x, t9ver y where x.a = y.a and (x.b = y.b or (x.b is null and y.b is null)) and (x.c = y.c or (x.c is null and y.c is null)); count(*) 6 # run backup SELECT * FROM t6 WHERE a > 30 order by a; a b 31 xyz 32 Rfc 33 34 CREATE TABLE tpersons ( id INT NOT NULL PRIMARY KEY, date_born DATE NOT NULL, first_name VARCHAR(14) NOT NULL COLUMN_FORMAT FIXED, last_name VARCHAR(16) NOT NULL COLUMN_FORMAT FIXED, gender CHAR(1) NOT NULL, date_died DATE NOT NULL ) engine=ndb CHARACTER SET latin1; include/assert_grep.inc [Require CSV parser to fail with syntax error] create table t10 ( a int primary key, b int not null, c varchar(16) not null ) engine=ndb CHARACTER SET latin1; include/assert_grep.inc [No --table argument and csv filename does not match any table name] delete from t10; create table t10ver like t10; select count(*) from t10 x, t10ver y where x.a = y.a and x.b = y.b and x.c = y.c; count(*) 5 delete from t10; # check .rej file exists and match the input csv filename # check .rej file matching the table name does not exists delete from t10; # check order matters when using --csvopt and --fields-terminated-by create table t11 ( a varchar(16) null ) engine=ndb CHARACTER SET latin1; SELECT COUNT(*), SUM(a IS NULL), SUM(a = '') FROM t11 ORDER BY a; COUNT(*) SUM(a IS NULL) SUM(a = '') 6 2 4 delete from t11; create table t11ver like t11; SELECT COUNT(*), SUM(a IS NULL), SUM(a = '') FROM t11ver ORDER BY a; COUNT(*) SUM(a IS NULL) SUM(a = '') 6 2 4 select count(*) from t11 x, t11ver y where ifnull(x.a,'NULL') = ifnull(y.a,'NULL'); count(*) 20 delete from t11; create table t12 ( a int auto_increment primary key, b varchar(16) null ) engine=ndb CHARACTER SET latin1; SELECT COUNT(*), SUM(b IS NULL), SUM(b = '') FROM t12 ORDER BY b; COUNT(*) SUM(b IS NULL) SUM(b = '') 6 2 4 delete from t12; create table t12ver like t12; SELECT COUNT(*), SUM(b IS NULL), SUM(b = '') FROM t12ver ORDER BY b; COUNT(*) SUM(b IS NULL) SUM(b = '') 6 2 4 select count(*) from t12 x, t12ver y where ifnull(x.b,'NULL') = ifnull(y.b,'NULL'); count(*) 20 delete from t12; select count(*) from t11ver x, t12ver y where ifnull(x.a,'NULL') = ifnull(y.b,'NULL'); count(*) 20 create table t13 ( a varchar(127) collate utf8mb4_unicode_ci, b binary(255), primary key(a,b) ) engine=ndb; # errins-type=bug34917498, use small computeHash scratch buffer create table t14 ( a varchar(767) collate utf8mb4_unicode_ci primary key, b int not null ) engine=ndb; Warnings: Warning 1296 Specified key 'PRIMARY' was too long (max = 3056 bytes); statistics will not be generated # errins-type=bug34917498, use small computeHash scratch buffer include/assert_grep.inc [Found expected error ndb-4278] create table t15a ( a int primary key, b tinyint unsigned ) engine=ndb CHARACTER SET latin1; create table t15b ( a int primary key, b smallint unsigned ) engine=ndb CHARACTER SET latin1; create table t15c ( a int primary key, b mediumint unsigned ) engine=ndb CHARACTER SET latin1; create table t15d ( a int primary key, b int unsigned ) engine=ndb CHARACTER SET latin1; create table t15e ( a int primary key, b bigint unsigned ) engine=ndb CHARACTER SET latin1; include/assert_grep.inc [Rows containing negative values for t15a.b are rejected] select * from t15a order by a; a b 1 1 3 168 4 222 5 174 7 7 include/assert_grep.inc [Rows containing negative values for t15b.b are rejected] select * from t15b order by a; a b 1 1 3 168 4 222 5 174 7 7 include/assert_grep.inc [Rows containing negative values for t15c.b are rejected] select * from t15c order by a; a b 1 1 3 168 4 222 5 174 7 7 include/assert_grep.inc [Rows containing negative values for t15d.b are rejected] select * from t15d order by a; a b 1 1 3 168 4 222 5 174 7 7 include/assert_grep.inc [Rows containing negative values for t15e.b are rejected] select * from t15e order by a; a b 1 1 3 168 4 222 5 174 7 7 drop table tpersons; drop table t1, t1ver, t2, t2ver, t4, t5a, t5b, t5c, t6, t6ver, t7, t7ver, t8, t8ver, t9, t9ver, t10, t10ver, t11, t11ver, t12, t12ver, t13, t14, t15a, t15b, t15c, t15d, t15e;