diff options
author | unknown <bell@sanja.is.com.ua> | 2004-01-20 19:23:28 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-01-20 19:23:28 +0200 |
commit | c3cf3d28209702a521a736daa6f797c2407db715 (patch) | |
tree | 58e31138eff605c80015c3b969fe8ff835561ec8 /mysql-test | |
parent | fe21bfb60aaf56796350d3622f906b87e20d5ce8 (diff) | |
parent | 7a1a5cd2d828d67120d10eb623c6c5bd83733260 (diff) | |
download | mariadb-git-c3cf3d28209702a521a736daa6f797c2407db715.tar.gz |
Merge
sql/sql_parse.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/derived.result:
SCCS merged
mysql-test/t/derived.test:
e
merge
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/derived.result | 27 | ||||
-rw-r--r-- | mysql-test/r/multi_update.result | 2 | ||||
-rw-r--r-- | mysql-test/r/update.result | 2 | ||||
-rw-r--r-- | mysql-test/t/derived.test | 20 | ||||
-rw-r--r-- | mysql-test/t/multi_update.test | 2 | ||||
-rw-r--r-- | mysql-test/t/update.test | 2 |
6 files changed, 49 insertions, 6 deletions
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index c0d2ce287db..d38601c331f 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -213,7 +213,7 @@ ERROR 42000: You have an error in your SQL syntax. Check the manual that corres create table t1 (a int); insert into t1 values (1),(2),(3); update (select * from t1) as t1 set a = 5; -ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use +ERROR HY000: The target table t1 of the UPDATE is not updatable. delete from (select * from t1); ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1)' at line 1 insert into (select * from t1) values (5); @@ -249,6 +249,31 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 2 3 UNION t1 ALL NULL NULL NULL NULL 2 drop table t1; +CREATE TABLE `t1` ( +`N` int(11) unsigned NOT NULL default '0', +`M` tinyint(1) default '0', +) TYPE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1286 'TYPE=database_engine' is deprecated. Use 'ENGINE=database_engine' instead. +INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0); +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; +select * from t1; +N M +1 2 +1 2 +1 2 +2 2 +2 2 +3 0 +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2; +ERROR HY000: The target table P2 of the UPDATE is not updatable. +delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +select * from t1; +N M +3 0 +delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +ERROR HY000: The target table P2 of the DELETE is not updatable. +drop table t1; CREATE TABLE t1 ( OBJECTID int(11) NOT NULL default '0', SORTORDER int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index d335c9c1d10..a61ce31b8ae 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -244,7 +244,7 @@ select * from t2; n d 1 30 1 30 -DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n; +DELETE a, b FROM t1 a,t2 b where a.n=b.n; select * from t1; n d 3 2 diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 6a5546200ce..0037fb9ea95 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -158,7 +158,7 @@ insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6), ('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2), ('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4), ('2','2','0',1,7); -delete from t1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); +delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); select * from t1; F1 F2 F3 cnt groupid 0 0 0 1 6 diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 8de95b4b600..154fc4b3834 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -116,7 +116,7 @@ select mail_id, if(folder.f_description!='', folder.f_description, folder.f_nam # create table t1 (a int); insert into t1 values (1),(2),(3); --- error 1149 +-- error 1287 update (select * from t1) as t1 set a = 5; -- error 1064 delete from (select * from t1); @@ -142,6 +142,24 @@ drop table t1; # +# multi-update & multi-delete with derived tables +# +CREATE TABLE `t1` ( + `N` int(11) unsigned NOT NULL default '0', + `M` tinyint(1) default '0', +) TYPE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0); +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; +select * from t1; +-- error 1287 +UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2; +delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +select * from t1; +-- error 1287 +delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; +drop table t1; + +# # correct lex->current_select # CREATE TABLE t1 ( diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 6f012801972..e52b373a4a6 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -218,7 +218,7 @@ select * from t2; UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n; select * from t1; select * from t2; -DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n; +DELETE a, b FROM t1 a,t2 b where a.n=b.n; select * from t1; select * from t2; drop table t1,t2; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 8e50fee56fd..3406dfd6158 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -126,6 +126,6 @@ insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6), ('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4), ('2','2','0',1,7); -delete from t1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); +delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); select * from t1; drop table t1; |