Updated ndb_* test cases

Added two new, ndb_replace and ndb_minmax
parent beff6a44
......@@ -45,12 +45,6 @@ port67 node78 pop98 1
select port, accessnode, pop, accesstype from t1 where pop='pop98' order by accesstype;
port accessnode pop accesstype
port67 node78 pop98 1
select port, accessnode, pop, accesstype from t1 where pop='POP98';
port accessnode pop accesstype
port67 node78 pop98 1
select port, accessnode, pop, accesstype from t1 where pop='POP98' order by accesstype;
port accessnode pop accesstype
port67 node78 pop98 1
select port, accessnode, pop, accesstype from t1 where pop='foo';
port accessnode pop accesstype
select port, accessnode, pop, accesstype from t1 where accesstype=1;
......
......@@ -122,7 +122,7 @@ drop table t1;
CREATE TABLE t1 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
c int unsigned not null,
c int unsigned not null
) engine = ndb;
create index a1 on t1 (b, c);
insert into t1 values (1, 2, 13);
......
......@@ -32,13 +32,13 @@ INSERT INTO t1 VALUES (8,'dummy');
CREATE TABLE t2 (
cid bigint(20) unsigned NOT NULL auto_increment,
cap varchar(255) NOT NULL default '',
PRIMARY KEY (cid),
PRIMARY KEY (cid)
) engine=ndbcluster;
CREATE TABLE t3 (
gid bigint(20) unsigned NOT NULL auto_increment,
gn varchar(255) NOT NULL default '',
must tinyint(4) default NULL,
PRIMARY KEY (gid),
PRIMARY KEY (gid)
) engine=ndbcluster;
INSERT INTO t3 VALUES (1,'V1',NULL);
CREATE TABLE t4 (
......@@ -46,7 +46,7 @@ uid bigint(20) unsigned NOT NULL default '0',
gid bigint(20) unsigned NOT NULL,
rid bigint(20) unsigned NOT NULL default '-1',
cid bigint(20) unsigned NOT NULL default '-1',
UNIQUE KEY m (uid,gid,rid,cid),
UNIQUE KEY m (uid,gid,rid,cid)
) engine=ndbcluster;
INSERT INTO t4 VALUES (1,1,2,4);
INSERT INTO t4 VALUES (1,1,2,3);
......@@ -55,14 +55,14 @@ INSERT INTO t4 VALUES (1,1,10,8);
CREATE TABLE t5 (
rid bigint(20) unsigned NOT NULL auto_increment,
rl varchar(255) NOT NULL default '',
PRIMARY KEY (rid),
PRIMARY KEY (rid)
) engine=ndbcluster;
CREATE TABLE t6 (
uid bigint(20) unsigned NOT NULL auto_increment,
un varchar(250) NOT NULL default '',
uc smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (uid),
UNIQUE KEY nc (un,uc),
UNIQUE KEY nc (un,uc)
) engine=ndbcluster;
INSERT INTO t6 VALUES (1,'test',8);
INSERT INTO t6 VALUES (2,'test2',9);
......@@ -73,7 +73,7 @@ uid bigint(20) unsigned NOT NULL default '0',
gid bigint(20) unsigned NOT NULL,
rid bigint(20) unsigned NOT NULL default '-1',
cid bigint(20) unsigned NOT NULL default '-1',
UNIQUE KEY m (uid,gid,rid,cid),
UNIQUE KEY m (uid,gid,rid,cid)
) engine=ndbcluster;
INSERT INTO t7 VALUES(1, 1, 1, 1, 1);
INSERT INTO t7 VALUES(2, 2, 1, 1, 1);
......
drop table if exists t1, t2;
CREATE TABLE t1 (
a int PRIMARY KEY
) engine = ndb;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
INSERT INTO t1 VALUES (6);
select MAX(a) from t1;
MAX(a)
6
select MAX(a) from t1;
MAX(a)
6
select MAX(a) from t1;
MAX(a)
6
select MAX(a) from t1;
MAX(a)
6
select MIN(a) from t1;
MIN(a)
1
select MIN(a) from t1;
MIN(a)
1
select MIN(a) from t1;
MIN(a)
1
select * from t1 order by a;
a
1
2
3
4
5
6
select MIN(a) from t1;
MIN(a)
1
select MAX(a) from t1;
MAX(a)
6
select MAX(a) from t1;
MAX(a)
6
select * from t1 order by a;
a
1
2
3
4
5
6
drop table t1;
CREATE TABLE t2 (
a int PRIMARY KEY,
b int not null,
c int not null,
KEY(b),
UNIQUE(c)
) engine = ndb;
INSERT INTO t2 VALUES (1, 5, 1);
INSERT INTO t2 VALUES (2, 2, 7);
INSERT INTO t2 VALUES (3, 3, 3);
INSERT INTO t2 VALUES (4, 4, 4);
INSERT INTO t2 VALUES (5, 5, 5);
INSERT INTO t2 VALUES (6, 6, 6);
INSERT INTO t2 VALUES (7, 2, 10);
INSERT INTO t2 VALUES (8, 10, 2);
select MAX(a) from t2;
MAX(a)
8
select MAX(b) from t2;
MAX(b)
10
select MAX(c) from t2;
MAX(c)
10
select MIN(a) from t2;
MIN(a)
1
select MIN(b) from t2;
MIN(b)
2
select MIN(c) from t2;
MIN(c)
1
select * from t2 order by a;
a b c
1 5 1
2 2 7
3 3 3
4 4 4
5 5 5
6 6 6
7 2 10
8 10 2
select MIN(b) from t2;
MIN(b)
2
select MAX(a) from t2;
MAX(a)
8
select MAX(c) from t2;
MAX(c)
10
select * from t2 order by a;
a b c
1 5 1
2 2 7
3 3 3
4 4 4
5 5 5
6 6 6
7 2 10
8 10 2
drop table t2;
drop table if exists t1;
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
) engine=ndbcluster;
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
insert into t1 (gesuchnr, benutzer_id) value (3,2);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
insert into t1 (gesuchnr,benutzer_id) values (1,1);
ERROR 23000: Can't write, duplicate key in table 't1'
replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1 order by gesuchnr;
gesuchnr benutzer_id
1 1
2 1
3 2
drop table t1;
......@@ -42,8 +42,11 @@ select port, accessnode, pop, accesstype from t1 where pop='pop98';
select port, accessnode, pop, accesstype from t1 where pop='pop98';
select port, accessnode, pop, accesstype from t1 where pop='pop98';
select port, accessnode, pop, accesstype from t1 where pop='pop98' order by accesstype;
select port, accessnode, pop, accesstype from t1 where pop='POP98';
select port, accessnode, pop, accesstype from t1 where pop='POP98' order by accesstype;
# The following two querys will not return any rows since
# the index used for access is case sensitive
# They are thus disabled for now
#select port, accessnode, pop, accesstype from t1 where pop='POP98';
#select port, accessnode, pop, accesstype from t1 where pop='POP98' order by accesstype;
select port, accessnode, pop, accesstype from t1 where pop='foo';
# Test select using accesstype
......
......@@ -79,7 +79,7 @@ drop table t1;
CREATE TABLE t1 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
c int unsigned not null,
c int unsigned not null
) engine = ndb;
create index a1 on t1 (b, c);
......
......@@ -37,13 +37,13 @@ INSERT INTO t1 VALUES (8,'dummy');
CREATE TABLE t2 (
cid bigint(20) unsigned NOT NULL auto_increment,
cap varchar(255) NOT NULL default '',
PRIMARY KEY (cid),
PRIMARY KEY (cid)
) engine=ndbcluster;
CREATE TABLE t3 (
gid bigint(20) unsigned NOT NULL auto_increment,
gn varchar(255) NOT NULL default '',
must tinyint(4) default NULL,
PRIMARY KEY (gid),
PRIMARY KEY (gid)
) engine=ndbcluster;
INSERT INTO t3 VALUES (1,'V1',NULL);
CREATE TABLE t4 (
......@@ -51,7 +51,7 @@ CREATE TABLE t4 (
gid bigint(20) unsigned NOT NULL,
rid bigint(20) unsigned NOT NULL default '-1',
cid bigint(20) unsigned NOT NULL default '-1',
UNIQUE KEY m (uid,gid,rid,cid),
UNIQUE KEY m (uid,gid,rid,cid)
) engine=ndbcluster;
INSERT INTO t4 VALUES (1,1,2,4);
INSERT INTO t4 VALUES (1,1,2,3);
......@@ -60,14 +60,14 @@ INSERT INTO t4 VALUES (1,1,10,8);
CREATE TABLE t5 (
rid bigint(20) unsigned NOT NULL auto_increment,
rl varchar(255) NOT NULL default '',
PRIMARY KEY (rid),
PRIMARY KEY (rid)
) engine=ndbcluster;
CREATE TABLE t6 (
uid bigint(20) unsigned NOT NULL auto_increment,
un varchar(250) NOT NULL default '',
uc smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (uid),
UNIQUE KEY nc (un,uc),
UNIQUE KEY nc (un,uc)
) engine=ndbcluster;
INSERT INTO t6 VALUES (1,'test',8);
INSERT INTO t6 VALUES (2,'test2',9);
......@@ -78,7 +78,7 @@ CREATE TABLE t7 (
gid bigint(20) unsigned NOT NULL,
rid bigint(20) unsigned NOT NULL default '-1',
cid bigint(20) unsigned NOT NULL default '-1',
UNIQUE KEY m (uid,gid,rid,cid),
UNIQUE KEY m (uid,gid,rid,cid)
) engine=ndbcluster;
INSERT INTO t7 VALUES(1, 1, 1, 1, 1);
INSERT INTO t7 VALUES(2, 2, 1, 1, 1);
......
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
CREATE TABLE t1 (
a int PRIMARY KEY
) engine = ndb;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
INSERT INTO t1 VALUES (6);
select MAX(a) from t1;
select MAX(a) from t1;
select MAX(a) from t1;
select MAX(a) from t1;
select MIN(a) from t1;
select MIN(a) from t1;
select MIN(a) from t1;
select * from t1 order by a;
select MIN(a) from t1;
select MAX(a) from t1;
select MAX(a) from t1;
select * from t1 order by a;
drop table t1;
CREATE TABLE t2 (
a int PRIMARY KEY,
b int not null,
c int not null,
KEY(b),
UNIQUE(c)
) engine = ndb;
INSERT INTO t2 VALUES (1, 5, 1);
INSERT INTO t2 VALUES (2, 2, 7);
INSERT INTO t2 VALUES (3, 3, 3);
INSERT INTO t2 VALUES (4, 4, 4);
INSERT INTO t2 VALUES (5, 5, 5);
INSERT INTO t2 VALUES (6, 6, 6);
INSERT INTO t2 VALUES (7, 2, 10);
INSERT INTO t2 VALUES (8, 10, 2);
select MAX(a) from t2;
select MAX(b) from t2;
select MAX(c) from t2;
select MIN(a) from t2;
select MIN(b) from t2;
select MIN(c) from t2;
select * from t2 order by a;
select MIN(b) from t2;
select MAX(a) from t2;
select MAX(c) from t2;
select * from t2 order by a;
drop table t2;
-- source include/have_ndb.inc
#
# Test of REPLACE with NDB
#
--disable_warnings
drop table if exists t1;
--enable_warnings
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
benutzer_id int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (gesuchnr,benutzer_id)
) engine=ndbcluster;
replace into t1 (gesuchnr,benutzer_id) values (2,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
insert into t1 (gesuchnr, benutzer_id) value (3,2);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
--error 1022
insert into t1 (gesuchnr,benutzer_id) values (1,1);
replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1 order by gesuchnr;
drop table t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment