mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
96e7be58c8
Some bigger code changes was necessary becasue of the multi-table-update and the new HANDLER code include/hash.h: Added back function that's was used in 4.0 mysql-test/r/delete.result: Update results after merge mysql-test/r/flush_table.result: Update results after merge mysql-test/r/func_str.result: Update results after merge mysql-test/r/handler.result: Update results after merge Change is big becasue in MySQL 4.1 you are not allowed to qualify the handler alias with a databasename mysql-test/r/multi_update.result: More startup cleanups mysql-test/r/rename.result: More startup-cleanups mysql-test/r/select.result: More startup cleanups mysql-test/r/show_check.result: More startup-cleanups mysql-test/t/ctype_latin1_de.test: Cleanup mysql-test/t/derived.test: Portability fix mysql-test/t/handler.test: Update results after merge Change is big becasue in MySQL 4.1 you are not allowed to qualify the handler alias with a databasename mysql-test/t/multi_update.test: More startup cleanups mysql-test/t/range.test: More comments mysql-test/t/rename.test: More startup cleanups mysql-test/t/select.test: More startup cleanups mysql-test/t/show_check.test: More startup cleanups mysql-test/t/type_timestamp.test: Add back test deleted during merge sql/item_cmpfunc.cc: After merge fixes sql/item_func.cc: Remove compiler warning sql/mysql_priv.h: After merge fixes sql/mysqld.cc: After merge fixes sql/sql_acl.cc: More debugging sql/sql_base.cc: After merge fixes (This fix was needed bacause of multi-table-update reopens tables) sql/sql_handler.cc: After merge fixes sql/sql_lex.h: After merge fixes sql/sql_select.cc: After merge fixes sql/sql_show.cc: After merge fixes sql/sql_table.cc: After merge fixes Simple cleanup of mysql_discard_or_import_tablespace sql/sql_update.cc: After merge fixes Rework mysql_multi_update to take into account derived tables. sql/sql_yacc.yy: After merge fixes
143 lines
3.5 KiB
Text
143 lines
3.5 KiB
Text
drop table if exists t1,t11,t12,t2;
|
|
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
|
|
INSERT INTO t1 VALUES (1,1);
|
|
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
|
|
INSERT INTO t1 VALUES (1,3);
|
|
DELETE from t1 where a=1 limit 1;
|
|
DELETE LOW_PRIORITY from t1 where a=1;
|
|
INSERT INTO t1 VALUES (1,1);
|
|
DELETE from t1;
|
|
LOCK TABLE t1 write;
|
|
INSERT INTO t1 VALUES (1,2);
|
|
DELETE from t1;
|
|
UNLOCK TABLES;
|
|
INSERT INTO t1 VALUES (1,2);
|
|
SET AUTOCOMMIT=0;
|
|
DELETE from t1;
|
|
SET AUTOCOMMIT=1;
|
|
drop table t1;
|
|
create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
|
|
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
|
|
delete from t1 where a=26;
|
|
drop table t1;
|
|
create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
|
|
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
|
|
delete from t1 where a=27;
|
|
drop table t1;
|
|
CREATE TABLE `t1` (
|
|
`i` int(10) NOT NULL default '0',
|
|
`i2` int(10) NOT NULL default '0',
|
|
PRIMARY KEY (`i`)
|
|
);
|
|
DELETE FROM t1 USING t1 WHERE post='1';
|
|
ERROR 42S22: Unknown column 'post' in 'where clause'
|
|
drop table t1;
|
|
CREATE TABLE t1 (
|
|
bool char(0) default NULL,
|
|
not_null varchar(20) binary NOT NULL default '',
|
|
misc integer not null,
|
|
PRIMARY KEY (not_null)
|
|
) ENGINE=MyISAM;
|
|
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
|
|
select * from t1 where misc > 5 and bool is null;
|
|
bool not_null misc
|
|
NULL c 6
|
|
NULL d 7
|
|
delete from t1 where misc > 5 and bool is null;
|
|
select * from t1 where misc > 5 and bool is null;
|
|
bool not_null misc
|
|
select count(*) from t1;
|
|
count(*)
|
|
2
|
|
delete from t1 where 1 > 2;
|
|
select count(*) from t1;
|
|
count(*)
|
|
2
|
|
delete from t1 where 3 > 2;
|
|
select count(*) from t1;
|
|
count(*)
|
|
0
|
|
drop table t1;
|
|
create table t1 (a int not null auto_increment primary key, b char(32));
|
|
insert into t1 (b) values ('apple'), ('apple');
|
|
select * from t1;
|
|
a b
|
|
1 apple
|
|
2 apple
|
|
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
|
|
select * from t1;
|
|
a b
|
|
1 apple
|
|
drop table t1;
|
|
create table t11 (a int NOT NULL, b int, primary key (a));
|
|
create table t12 (a int NOT NULL, b int, primary key (a));
|
|
create table t2 (a int NOT NULL, b int, primary key (a));
|
|
insert into t11 values (0, 10),(1, 11),(2, 12);
|
|
insert into t12 values (33, 10),(0, 11),(2, 12);
|
|
insert into t2 values (1, 21),(2, 12),(3, 23);
|
|
select * from t11;
|
|
a b
|
|
0 10
|
|
1 11
|
|
2 12
|
|
select * from t12;
|
|
a b
|
|
33 10
|
|
0 11
|
|
2 12
|
|
select * from t2;
|
|
a b
|
|
1 21
|
|
2 12
|
|
3 23
|
|
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
|
ERROR 21000: Subquery returns more than 1 row
|
|
select * from t11;
|
|
a b
|
|
0 10
|
|
1 11
|
|
2 12
|
|
select * from t12;
|
|
a b
|
|
33 10
|
|
0 11
|
|
2 12
|
|
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
|
Warnings:
|
|
Error 1242 Subquery returns more than 1 row
|
|
Error 1242 Subquery returns more than 1 row
|
|
select * from t11;
|
|
a b
|
|
0 10
|
|
1 11
|
|
select * from t12;
|
|
a b
|
|
33 10
|
|
0 11
|
|
insert into t11 values (2, 12);
|
|
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
|
ERROR 21000: Subquery returns more than 1 row
|
|
select * from t11;
|
|
a b
|
|
0 10
|
|
1 11
|
|
2 12
|
|
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
|
Warnings:
|
|
Error 1242 Subquery returns more than 1 row
|
|
Error 1242 Subquery returns more than 1 row
|
|
select * from t11;
|
|
a b
|
|
0 10
|
|
1 11
|
|
drop table t11, t12, t2;
|
|
create table t1 (a int, b int, unique key (a), key (b));
|
|
insert into t1 values (3, 3), (7, 7);
|
|
delete t1 from t1 where a = 3;
|
|
check table t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 check status OK
|
|
select * from t1;
|
|
a b
|
|
7 7
|
|
drop table t1;
|