diff options
author | monty@mashka.mysql.fi <> | 2002-11-29 16:40:18 +0200 |
---|---|---|
committer | monty@mashka.mysql.fi <> | 2002-11-29 16:40:18 +0200 |
commit | 6603d75213d45c9b75f7c5ab9e612663da943f61 (patch) | |
tree | 9914e2306a30c63d173b56a8ac8f100ee49823d7 /mysql-test | |
parent | fa7798596d409251d542c938b89e1b2e428c5ca7 (diff) | |
download | mariadb-git-6603d75213d45c9b75f7c5ab9e612663da943f61.tar.gz |
New multi-table-update code
New (simpler) internal timestamp handling.
More debuging to heap tables.
Small cleanups to multi-table-delete
false -> 0 and true -> 1 (We should use TRUE and FALSE)
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/multi_update.result | 48 | ||||
-rw-r--r-- | mysql-test/t/multi_update.test | 50 |
2 files changed, 40 insertions, 58 deletions
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index ce3f7e90f6b..20921816f1e 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -20,7 +20,7 @@ count(*) 10 select count(*) from t2 where t = "bbb"; count(*) -10 +50 select count(*) from t2 where id2 > 90; count(*) 50 @@ -70,71 +70,61 @@ create table t1(id1 int not null primary key, t varchar(100)) pack_keys = 1; create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1; delete t1 from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500; drop table t1,t2; -DROP TABLE IF EXISTS a,b,c; -CREATE TABLE a ( +CREATE TABLE t1 ( id int(11) NOT NULL default '0', name varchar(10) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; -INSERT INTO a VALUES (1,'aaa'),(2,'aaa'),(3,'aaa'); -CREATE TABLE b ( +INSERT INTO t1 VALUES (1,'aaa'),(2,'aaa'),(3,'aaa'); +CREATE TABLE t2 ( id int(11) NOT NULL default '0', name varchar(10) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; -INSERT INTO b VALUES (2,'bbb'),(3,'bbb'),(4,'bbb'); -CREATE TABLE c ( +INSERT INTO t2 VALUES (2,'bbb'),(3,'bbb'),(4,'bbb'); +CREATE TABLE t3 ( id int(11) NOT NULL default '0', mydate datetime default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; -INSERT INTO c VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'2002-05-12 00:00:00'),(6,'2002-06-22 +INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'2002-05-12 00:00:00'),(6,'2002-06-22 00:00:00'),(7,'2002-07-22 00:00:00'); -delete a,b,c from a,b,c -where to_days(now())-to_days(c.mydate)>=30 -and c.id=a.id and c.id=b.id; -select * from c; +delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id; +select * from t3; id mydate 1 2002-02-04 00:00:00 5 2002-05-12 00:00:00 6 2002-06-22 00:00:00 7 2002-07-22 00:00:00 -DROP TABLE IF EXISTS a,b,c; -drop table if exists parent, child; -CREATE TABLE IF NOT EXISTS `parent` ( +DROP TABLE IF EXISTS t1,t2,t3; +CREATE TABLE IF NOT EXISTS `t1` ( `id` int(11) NOT NULL auto_increment, `tst` text, `tst1` text, PRIMARY KEY (`id`) ) TYPE=MyISAM; -CREATE TABLE IF NOT EXISTS `child` ( +CREATE TABLE IF NOT EXISTS `t2` ( `ID` int(11) NOT NULL auto_increment, `ParId` int(11) default NULL, `tst` text, `tst1` text, PRIMARY KEY (`ID`), -KEY `IX_ParId_child` (`ParId`), -FOREIGN KEY (`ParId`) REFERENCES `test.parent` (`id`) +KEY `IX_ParId_t2` (`ParId`), +FOREIGN KEY (`ParId`) REFERENCES `t1` (`id`) ) TYPE=MyISAM; -INSERT INTO parent(tst,tst1) -VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE"); -INSERT INTO child(ParId) -VALUES(1), (2), (3); -select * from child; +INSERT INTO t1(tst,tst1) VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE"); +INSERT INTO t2(ParId) VALUES(1), (2), (3); +select * from t2; ID ParId tst tst1 1 1 NULL NULL 2 2 NULL NULL 3 3 NULL NULL -UPDATE child, parent -SET child.tst = parent.tst, -child.tst1 = parent.tst1 -WHERE child.ParId = parent.Id; -select * from child; +UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id; +select * from t2; ID ParId tst tst1 1 1 MySQL MySQL AB 2 2 MSSQL Microsoft 3 3 ORACLE ORACLE -drop table parent, child; drop table if exists t1, t2 ; create table t1 (n numeric(10)); create table t2 (n numeric(10)); diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index b3a51ff65bc..ec1ef76753b 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -80,67 +80,59 @@ while ($1) enable_query_log; delete t1 from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500; drop table t1,t2; -DROP TABLE IF EXISTS a,b,c; -CREATE TABLE a ( + +CREATE TABLE t1 ( id int(11) NOT NULL default '0', name varchar(10) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; -INSERT INTO a VALUES (1,'aaa'),(2,'aaa'),(3,'aaa'); -CREATE TABLE b ( +INSERT INTO t1 VALUES (1,'aaa'),(2,'aaa'),(3,'aaa'); +CREATE TABLE t2 ( id int(11) NOT NULL default '0', name varchar(10) default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; -INSERT INTO b VALUES (2,'bbb'),(3,'bbb'),(4,'bbb'); -CREATE TABLE c ( +INSERT INTO t2 VALUES (2,'bbb'),(3,'bbb'),(4,'bbb'); +CREATE TABLE t3 ( id int(11) NOT NULL default '0', mydate datetime default NULL, PRIMARY KEY (id) ) TYPE=MyISAM; -INSERT INTO c VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'2002-05-12 00:00:00'),(6,'2002-06-22 +INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'2002-05-12 00:00:00'),(6,'2002-06-22 00:00:00'),(7,'2002-07-22 00:00:00'); -delete a,b,c from a,b,c -where to_days(now())-to_days(c.mydate)>=30 -and c.id=a.id and c.id=b.id; -select * from c; -DROP TABLE IF EXISTS a,b,c; -drop table if exists parent, child; -CREATE TABLE IF NOT EXISTS `parent` ( +delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id; +select * from t3; +DROP TABLE IF EXISTS t1,t2,t3; + +CREATE TABLE IF NOT EXISTS `t1` ( `id` int(11) NOT NULL auto_increment, `tst` text, `tst1` text, PRIMARY KEY (`id`) ) TYPE=MyISAM; -CREATE TABLE IF NOT EXISTS `child` ( +CREATE TABLE IF NOT EXISTS `t2` ( `ID` int(11) NOT NULL auto_increment, `ParId` int(11) default NULL, `tst` text, `tst1` text, PRIMARY KEY (`ID`), - KEY `IX_ParId_child` (`ParId`), - FOREIGN KEY (`ParId`) REFERENCES `test.parent` (`id`) + KEY `IX_ParId_t2` (`ParId`), + FOREIGN KEY (`ParId`) REFERENCES `t1` (`id`) ) TYPE=MyISAM; -INSERT INTO parent(tst,tst1) -VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE"); - -INSERT INTO child(ParId) -VALUES(1), (2), (3); +INSERT INTO t1(tst,tst1) VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE"); -select * from child; +INSERT INTO t2(ParId) VALUES(1), (2), (3); -UPDATE child, parent -SET child.tst = parent.tst, -child.tst1 = parent.tst1 -WHERE child.ParId = parent.Id; +select * from t2; -select * from child; +UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id; +select * from t2; -drop table parent, child; drop table if exists t1, t2 ; + create table t1 (n numeric(10)); create table t2 (n numeric(10)); insert into t2 values (1),(2),(4),(8),(16),(32); |