mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/usr/local/home/marty/MySQL/mysql-5.0
This commit is contained in:
@ -60,3 +60,9 @@ count(distinct a)
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (f1 int, f2 int);
|
||||
insert into t1 values (0,1),(1,2);
|
||||
select count(distinct if(f1,3,f2)) from t1;
|
||||
count(distinct if(f1,3,f2))
|
||||
2
|
||||
drop table t1;
|
||||
|
@ -579,3 +579,21 @@ select * from t2;
|
||||
b
|
||||
1
|
||||
drop table t1,t2;
|
||||
use test;
|
||||
create table t1 (a int);
|
||||
create table t1 select * from t1;
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
create table t2 union = (t1) select * from t1;
|
||||
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
||||
flush tables with read lock;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
create table t1(column.name int);
|
||||
ERROR 42000: Incorrect table name 'column'
|
||||
create table t1(test.column.name int);
|
||||
ERROR 42000: Incorrect table name 'column'
|
||||
create table t1(xyz.t1.name int);
|
||||
ERROR 42000: Incorrect database name 'xyz'
|
||||
create table t1(t1.name int);
|
||||
create table t2(test.t2.name int);
|
||||
drop table t1,t2;
|
||||
|
138
mysql-test/r/default.result
Normal file
138
mysql-test/r/default.result
Normal file
@ -0,0 +1,138 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6;
|
||||
drop database if exists mysqltest;
|
||||
CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
c varchar(4) binary NOT NULL DEFAULT '0000',
|
||||
d tinyblob NULL,
|
||||
e tinyblob NULL,
|
||||
f tinyblob NULL,
|
||||
g tinyblob NULL,
|
||||
h tinyblob NULL,
|
||||
i tinyblob NULL,
|
||||
j tinyblob NULL,
|
||||
k tinyblob NULL,
|
||||
l tinyblob NULL,
|
||||
m tinyblob NULL,
|
||||
n tinyblob NULL,
|
||||
o tinyblob NULL,
|
||||
p tinyblob NULL,
|
||||
q varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
r varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
s tinyblob NULL,
|
||||
t varchar(4) binary NOT NULL DEFAULT ' ',
|
||||
u varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
v varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
w varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
x tinyblob NULL,
|
||||
y varchar(5) binary NOT NULL DEFAULT ' ',
|
||||
z varchar(20) binary NOT NULL DEFAULT ' ',
|
||||
a1 varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b1 tinyblob NULL)
|
||||
ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`b` varchar(1) collate latin1_bin NOT NULL default ' ',
|
||||
`c` varchar(4) collate latin1_bin NOT NULL default '0000',
|
||||
`d` tinyblob,
|
||||
`e` tinyblob,
|
||||
`f` tinyblob,
|
||||
`g` tinyblob,
|
||||
`h` tinyblob,
|
||||
`i` tinyblob,
|
||||
`j` tinyblob,
|
||||
`k` tinyblob,
|
||||
`l` tinyblob,
|
||||
`m` tinyblob,
|
||||
`n` tinyblob,
|
||||
`o` tinyblob,
|
||||
`p` tinyblob,
|
||||
`q` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`r` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`s` tinyblob,
|
||||
`t` varchar(4) collate latin1_bin NOT NULL default ' ',
|
||||
`u` varchar(1) collate latin1_bin NOT NULL default ' ',
|
||||
`v` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`w` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`x` tinyblob,
|
||||
`y` varchar(5) collate latin1_bin NOT NULL default ' ',
|
||||
`z` varchar(20) collate latin1_bin NOT NULL default ' ',
|
||||
`a1` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`b1` tinyblob
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
|
||||
INSERT into t1 (b) values ('1');
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT * from t1;
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
|
||||
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
c varchar(4) binary NOT NULL DEFAULT '0000',
|
||||
d tinyblob NULL,
|
||||
e tinyblob NULL,
|
||||
f tinyblob NULL,
|
||||
g tinyblob NULL,
|
||||
h tinyblob NULL,
|
||||
i tinyblob NULL,
|
||||
j tinyblob NULL,
|
||||
k tinyblob NULL,
|
||||
l tinyblob NULL,
|
||||
m tinyblob NULL,
|
||||
n tinyblob NULL,
|
||||
o tinyblob NULL,
|
||||
p tinyblob NULL,
|
||||
q varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
r varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
s tinyblob NULL,
|
||||
t varchar(4) binary NOT NULL DEFAULT ' ',
|
||||
u varchar(1) binary NOT NULL DEFAULT ' ',
|
||||
v varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
w varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
x tinyblob NULL,
|
||||
y varchar(5) binary NOT NULL DEFAULT ' ',
|
||||
z varchar(20) binary NOT NULL DEFAULT ' ',
|
||||
a1 varchar(30) binary NOT NULL DEFAULT ' ',
|
||||
b1 tinyblob NULL)
|
||||
ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`b` varchar(1) collate latin1_bin NOT NULL default ' ',
|
||||
`c` varchar(4) collate latin1_bin NOT NULL default '0000',
|
||||
`d` tinyblob,
|
||||
`e` tinyblob,
|
||||
`f` tinyblob,
|
||||
`g` tinyblob,
|
||||
`h` tinyblob,
|
||||
`i` tinyblob,
|
||||
`j` tinyblob,
|
||||
`k` tinyblob,
|
||||
`l` tinyblob,
|
||||
`m` tinyblob,
|
||||
`n` tinyblob,
|
||||
`o` tinyblob,
|
||||
`p` tinyblob,
|
||||
`q` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`r` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`s` tinyblob,
|
||||
`t` varchar(4) collate latin1_bin NOT NULL default ' ',
|
||||
`u` varchar(1) collate latin1_bin NOT NULL default ' ',
|
||||
`v` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`w` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`x` tinyblob,
|
||||
`y` varchar(5) collate latin1_bin NOT NULL default ' ',
|
||||
`z` varchar(20) collate latin1_bin NOT NULL default ' ',
|
||||
`a1` varchar(30) collate latin1_bin NOT NULL default ' ',
|
||||
`b1` tinyblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
|
||||
INSERT into t2 (b) values ('1');
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
SELECT * from t2;
|
||||
a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1
|
||||
1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
drop table t1;
|
||||
drop table t2;
|
@ -906,9 +906,100 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Lenz', 2, 22222);
|
||||
INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333);
|
||||
INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333);
|
||||
INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333);
|
||||
EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id,
|
||||
federated.t1.other AS other, federated.countries.country AS country
|
||||
FROM federated.t1, federated.countries WHERE
|
||||
federated.t1.country_id = federated.countries.id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5
|
||||
1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120
|
||||
SELECT federated.t1.name AS name, federated.t1.country_id AS country_id,
|
||||
federated.t1.other AS other, federated.countries.country AS country
|
||||
FROM federated.t1, federated.countries WHERE
|
||||
federated.t1.country_id = federated.countries.id;
|
||||
name country_id other country
|
||||
Kumar 1 11111 India
|
||||
Lenz 2 22222 Germany
|
||||
Marizio 3 33333 Italy
|
||||
Monty 4 33333 Finland
|
||||
Sanja 5 33333 Ukraine
|
||||
EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id,
|
||||
federated.t1.other AS other, federated.countries.country AS country
|
||||
FROM federated.t1 INNER JOIN federated.countries ON
|
||||
federated.t1.country_id = federated.countries.id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5
|
||||
1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120
|
||||
SELECT federated.t1.name AS name, federated.t1.country_id AS country_id,
|
||||
federated.t1.other AS other, federated.countries.country AS country
|
||||
FROM federated.t1 INNER JOIN federated.countries ON
|
||||
federated.t1.country_id = federated.countries.id;
|
||||
name country_id other country
|
||||
Kumar 1 11111 India
|
||||
Lenz 2 22222 Germany
|
||||
Marizio 3 33333 Italy
|
||||
Monty 4 33333 Finland
|
||||
Sanja 5 33333 Ukraine
|
||||
EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id,
|
||||
federated.t1.other AS other, federated.countries.country AS country
|
||||
FROM federated.t1 INNER JOIN federated.countries ON
|
||||
federated.t1.country_id = federated.countries.id
|
||||
WHERE federated.t1.name = 'Monty';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5
|
||||
1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 Using where
|
||||
SELECT federated.t1.name AS name, federated.t1.country_id AS country_id,
|
||||
federated.t1.other AS other, federated.countries.country AS country
|
||||
FROM federated.t1 INNER JOIN federated.countries ON
|
||||
federated.t1.country_id = federated.countries.id
|
||||
WHERE federated.t1.name = 'Monty';
|
||||
name country_id other country
|
||||
Monty 4 33333 Finland
|
||||
EXPLAIN SELECT federated.t1.*, federated.countries.country
|
||||
FROM federated.t1 LEFT JOIN federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id
|
||||
ORDER BY federated.countries.id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort
|
||||
1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1
|
||||
SELECT federated.t1.*, federated.countries.country
|
||||
FROM federated.t1 left join federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id;
|
||||
FROM federated.t1 LEFT JOIN federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id
|
||||
ORDER BY federated.countries.id;
|
||||
id country_id name other country
|
||||
1 1 Kumar 11111 India
|
||||
2 2 Lenz 22222 Germany
|
||||
3 3 Marizio 33333 Italy
|
||||
4 4 Monty 33333 Finland
|
||||
5 5 Sanja 33333 Ukraine
|
||||
EXPLAIN SELECT federated.t1.*, federated.countries.country
|
||||
FROM federated.t1 LEFT JOIN federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id
|
||||
ORDER BY federated.countries.country;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort
|
||||
1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1
|
||||
SELECT federated.t1.*, federated.countries.country
|
||||
FROM federated.t1 LEFT JOIN federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id
|
||||
ORDER BY federated.countries.country;
|
||||
id country_id name other country
|
||||
4 4 Monty 33333 Finland
|
||||
2 2 Lenz 22222 Germany
|
||||
1 1 Kumar 11111 India
|
||||
3 3 Marizio 33333 Italy
|
||||
5 5 Sanja 33333 Ukraine
|
||||
EXPLAIN SELECT federated.t1.*, federated.countries.country
|
||||
FROM federated.t1 RIGHT JOIN federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id
|
||||
ORDER BY federated.t1.country_id;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE countries ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
|
||||
1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120
|
||||
SELECT federated.t1.*, federated.countries.country
|
||||
FROM federated.t1 RIGHT JOIN federated.countries
|
||||
ON federated.t1.country_id = federated.countries.id
|
||||
ORDER BY federated.t1.country_id;
|
||||
id country_id name other country
|
||||
1 1 Kumar 11111 India
|
||||
2 2 Lenz 22222 Germany
|
||||
|
@ -91,3 +91,20 @@ drop table t1;
|
||||
SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL;
|
||||
NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL
|
||||
1 0
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`date` int(10) default NULL,
|
||||
`text` varchar(32) NOT NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3');
|
||||
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC;
|
||||
id date_ord text
|
||||
1 05-03-2005 Day 1
|
||||
2 16-03-2005 Day 2
|
||||
3 28-03-2005 Day 3
|
||||
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC;
|
||||
id date_ord text
|
||||
3 28-03-2005 Day 3
|
||||
2 16-03-2005 Day 2
|
||||
1 05-03-2005 Day 1
|
||||
DROP TABLE t1;
|
||||
|
@ -794,3 +794,9 @@ id aes_decrypt(str, 'bar')
|
||||
1 foo
|
||||
2 NULL
|
||||
DROP TABLE t1, t2;
|
||||
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
|
||||
field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
|
||||
3 3 3
|
||||
select field(NULL,1,2,NULL), field(NULL,1,2,0);
|
||||
field(NULL,1,2,NULL) field(NULL,1,2,0)
|
||||
0 0
|
||||
|
@ -133,13 +133,13 @@ Table Op Msg_type Msg_text
|
||||
test.t3 analyze status Table is already up to date
|
||||
explain select a1, min(a2) from t1 group by a1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
|
||||
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
|
||||
explain select a1, max(a2) from t1 group by a1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
|
||||
explain select a1, min(a2), max(a2) from t1 group by a1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
|
||||
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
|
||||
explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
|
||||
@ -151,13 +151,13 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by
|
||||
explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
|
||||
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
|
||||
explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
|
||||
explain select min(a2) from t1 group by a1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
|
||||
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
|
||||
explain select a2, min(c), max(c) from t1 group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
|
||||
@ -1404,7 +1404,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
|
||||
explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
|
||||
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by
|
||||
select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
|
||||
a1 a2 b min(c) max(c)
|
||||
a a b e112 h112
|
||||
@ -1838,7 +1838,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
|
||||
explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range NULL idx_t1_1 130 NULL 9 Using index for group-by
|
||||
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by
|
||||
select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
|
||||
a1 a2 b concat(min(c), max(c))
|
||||
a a a a111d111
|
||||
|
@ -470,7 +470,7 @@ s1
|
||||
drop table t1;
|
||||
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
|
||||
Table Create Table
|
||||
character_sets CREATE TEMPORARY TABLE `character_sets` (
|
||||
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
|
||||
`CHARACTER_SET_NAME` varchar(64) NOT NULL default '',
|
||||
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
|
||||
`DESCRIPTION` varchar(60) NOT NULL default '',
|
||||
@ -479,7 +479,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` (
|
||||
set names latin2;
|
||||
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
|
||||
Table Create Table
|
||||
character_sets CREATE TEMPORARY TABLE `character_sets` (
|
||||
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
|
||||
`CHARACTER_SET_NAME` varchar(64) NOT NULL default '',
|
||||
`DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '',
|
||||
`DESCRIPTION` varchar(60) NOT NULL default '',
|
||||
|
@ -47,3 +47,13 @@ unlock tables;
|
||||
lock tables t1 write, t1 as t1_alias read;
|
||||
insert into t1 select index1,nr from t1 as t1_alias;
|
||||
drop table t1,t2;
|
||||
create table t1 ( a int(11) not null auto_increment, primary key(a));
|
||||
create table t2 ( a int(11) not null auto_increment, primary key(a));
|
||||
lock tables t1 write, t2 read;
|
||||
delete from t1 using t1,t2 where t1.a=t2.a;
|
||||
delete t1 from t1,t2 where t1.a=t2.a;
|
||||
delete from t2 using t1,t2 where t1.a=t2.a;
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
delete t2 from t1,t2 where t1.a=t2.a;
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
drop table t1,t2;
|
||||
|
@ -72,7 +72,7 @@ T1 CREATE TABLE `T1` (
|
||||
RENAME TABLE T1 TO T2;
|
||||
SHOW TABLES LIKE "T2";
|
||||
Tables_in_test (T2)
|
||||
t2
|
||||
T2
|
||||
SELECT * FROM t2;
|
||||
a
|
||||
1
|
||||
@ -83,25 +83,25 @@ t3
|
||||
RENAME TABLE T3 TO T1;
|
||||
SHOW TABLES LIKE "T1";
|
||||
Tables_in_test (T1)
|
||||
t1
|
||||
T1
|
||||
ALTER TABLE T1 add b int;
|
||||
SHOW TABLES LIKE "T1";
|
||||
Tables_in_test (T1)
|
||||
t1
|
||||
T1
|
||||
ALTER TABLE T1 RENAME T2;
|
||||
SHOW TABLES LIKE "T2";
|
||||
Tables_in_test (T2)
|
||||
t2
|
||||
T2
|
||||
LOCK TABLE T2 WRITE;
|
||||
ALTER TABLE T2 drop b;
|
||||
SHOW TABLES LIKE "T2";
|
||||
Tables_in_test (T2)
|
||||
t2
|
||||
T2
|
||||
UNLOCK TABLES;
|
||||
RENAME TABLE T2 TO T1;
|
||||
SHOW TABLES LIKE "T1";
|
||||
Tables_in_test (T1)
|
||||
t1
|
||||
T1
|
||||
SELECT * from T1;
|
||||
a
|
||||
1
|
||||
|
50
mysql-test/r/mysql.result
Normal file
50
mysql-test/r/mysql.result
Normal file
@ -0,0 +1,50 @@
|
||||
drop table if exists t1;
|
||||
create table t1(a int);
|
||||
insert into t1 values(1);
|
||||
|
||||
Test default delimiter ;
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter without arg
|
||||
|
||||
Test delimiter :
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter :
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter :;
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter //
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter MySQL
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter delimiter
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter : from command line
|
||||
a
|
||||
1
|
||||
|
||||
Test delimiter :; from command line
|
||||
a
|
||||
1
|
||||
|
||||
Test 'go' command(vertical output) G
|
||||
*************************** 1. row ***************************
|
||||
a: 1
|
||||
|
||||
Test 'go' command g
|
||||
a
|
||||
1
|
||||
drop table t1;
|
@ -1384,3 +1384,41 @@ UNLOCK TABLES;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (1),(2),(3);
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
/*!40000 DROP DATABASE IF EXISTS `test`*/;
|
||||
|
||||
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
|
||||
|
||||
USE `test`;
|
||||
DROP TABLE IF EXISTS `t1`;
|
||||
CREATE TABLE `t1` (
|
||||
`a` int(11) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
|
||||
LOCK TABLES `t1` WRITE;
|
||||
INSERT INTO `t1` VALUES (1),(2),(3);
|
||||
UNLOCK TABLES;
|
||||
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
@ -253,7 +253,7 @@ concat(':',product,':') sum(profit) avg(profit)
|
||||
:Computer: 6900 1380.00000
|
||||
:Phone: 10 10.00000
|
||||
:TV: 600 120.00000
|
||||
:TV: 7785 519.00000
|
||||
NULL 7785 519.00000
|
||||
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
|
||||
explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
|
||||
@ -489,3 +489,69 @@ a SUM(a) SUM(a)+1 CONCAT(SUM(a),'x') SUM(a)+SUM(a) SUM(a)
|
||||
5 5 6 5x 10 5
|
||||
NULL 8 9 8x 16 8
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int(11));
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT a, a+1, SUM(a) FROM t1 GROUP BY a WITH ROLLUP;
|
||||
a a+1 SUM(a)
|
||||
1 2 1
|
||||
2 3 2
|
||||
NULL NULL 3
|
||||
SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP;
|
||||
a+1
|
||||
2
|
||||
3
|
||||
NULL
|
||||
SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP;
|
||||
a+SUM(a)
|
||||
2
|
||||
4
|
||||
NULL
|
||||
SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2;
|
||||
a b
|
||||
2 3
|
||||
SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING a IS NULL;
|
||||
a b
|
||||
NULL NULL
|
||||
SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b IS NULL;
|
||||
a b
|
||||
NULL NULL
|
||||
SELECT IFNULL(a, 'TEST') FROM t1 GROUP BY a WITH ROLLUP;
|
||||
IFNULL(a, 'TEST')
|
||||
1
|
||||
2
|
||||
TEST
|
||||
CREATE TABLE t2 (a int, b int);
|
||||
INSERT INTO t2 VALUES
|
||||
(1,4),
|
||||
(2,2), (2,2),
|
||||
(4,1), (4,1), (4,1), (4,1),
|
||||
(2,1), (2,1);
|
||||
SELECT a,b,SUM(b) FROM t2 GROUP BY a,b WITH ROLLUP;
|
||||
a b SUM(b)
|
||||
1 4 4
|
||||
1 NULL 4
|
||||
2 1 2
|
||||
2 2 4
|
||||
2 NULL 6
|
||||
4 1 4
|
||||
4 NULL 4
|
||||
NULL NULL 14
|
||||
SELECT a,b,SUM(b), a+b as c FROM t2
|
||||
GROUP BY a,b WITH ROLLUP HAVING c IS NULL;
|
||||
a b SUM(b) c
|
||||
1 NULL 4 NULL
|
||||
2 NULL 6 NULL
|
||||
4 NULL 4 NULL
|
||||
NULL NULL 14 NULL
|
||||
SELECT IFNULL(a, 'TEST'), COALESCE(b, 'TEST') FROM t2
|
||||
GROUP BY a, b WITH ROLLUP;
|
||||
IFNULL(a, 'TEST') COALESCE(b, 'TEST')
|
||||
1 4
|
||||
1 TEST
|
||||
2 1
|
||||
2 2
|
||||
2 TEST
|
||||
4 1
|
||||
4 TEST
|
||||
TEST TEST
|
||||
DROP TABLE t1,t2;
|
||||
|
@ -1,2 +0,0 @@
|
||||
Variable_name Value
|
||||
lower_case_table_names 1
|
@ -1,7 +0,0 @@
|
||||
use COM1;
|
||||
ERROR 42000: Unknown database 'com1'
|
||||
use LPT1;
|
||||
ERROR 42000: Unknown database 'lpt1'
|
||||
use PRN;
|
||||
ERROR 42000: Unknown database 'prn'
|
||||
|
@ -9,6 +9,7 @@ BEGIN;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize error Lock wait timeout exceeded; try restarting transaction
|
||||
test.t1 optimize status Operation failed
|
||||
Warnings:
|
||||
Error 1205 Lock wait timeout exceeded; try restarting transaction
|
||||
|
@ -68,14 +68,14 @@ master-bin.000002 260 Query 1 346 use `test`; create table t1 (n int)
|
||||
master-bin.000002 346 Query 1 434 use `test`; insert into t1 values (1)
|
||||
master-bin.000002 434 Query 1 510 use `test`; drop table t1
|
||||
show binary logs;
|
||||
Log_name
|
||||
master-bin.000001
|
||||
master-bin.000002
|
||||
Log_name File_size
|
||||
master-bin.000001 0
|
||||
master-bin.000002 510
|
||||
start slave;
|
||||
show binary logs;
|
||||
Log_name
|
||||
slave-bin.000001
|
||||
slave-bin.000002
|
||||
Log_name File_size
|
||||
slave-bin.000001 0
|
||||
slave-bin.000002 348
|
||||
show binlog events in 'slave-bin.000001' from 4;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4
|
||||
|
@ -26,10 +26,10 @@ create table t2(m int not null auto_increment primary key);
|
||||
insert into t2 values (34),(67),(123);
|
||||
flush logs;
|
||||
show binary logs;
|
||||
Log_name
|
||||
master-bin.000001
|
||||
master-bin.000002
|
||||
master-bin.000003
|
||||
Log_name File_size
|
||||
master-bin.000001 0
|
||||
master-bin.000002 0
|
||||
master-bin.000003 98
|
||||
create table t3 select * from temp_table;
|
||||
select * from t3;
|
||||
a
|
||||
@ -42,18 +42,18 @@ set global sql_slave_skip_counter=1;
|
||||
start slave;
|
||||
purge master logs to 'master-bin.000002';
|
||||
show master logs;
|
||||
Log_name
|
||||
master-bin.000002
|
||||
master-bin.000003
|
||||
Log_name File_size
|
||||
master-bin.000002 0
|
||||
master-bin.000003 407
|
||||
purge binary logs to 'master-bin.000002';
|
||||
show binary logs;
|
||||
Log_name
|
||||
master-bin.000002
|
||||
master-bin.000003
|
||||
Log_name File_size
|
||||
master-bin.000002 0
|
||||
master-bin.000003 407
|
||||
purge master logs before now();
|
||||
show binary logs;
|
||||
Log_name
|
||||
master-bin.000003
|
||||
Log_name File_size
|
||||
master-bin.000003 407
|
||||
insert into t2 values (65);
|
||||
show slave status;
|
||||
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
|
||||
@ -73,10 +73,10 @@ count(*)
|
||||
100
|
||||
create table t4 select * from temp_table;
|
||||
show binary logs;
|
||||
Log_name
|
||||
master-bin.000003
|
||||
master-bin.000004
|
||||
master-bin.000005
|
||||
Log_name File_size
|
||||
master-bin.000003 0
|
||||
master-bin.000004 0
|
||||
master-bin.000005 2032
|
||||
show master status;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000005 2032
|
||||
|
@ -2423,6 +2423,12 @@ ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
select distinct all * from t1;
|
||||
ERROR HY000: Incorrect usage of ALL and DISTINCT
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
|
||||
INSERT INTO t1 VALUES (0x8000000000000000);
|
||||
SELECT b FROM t1 WHERE b=0x8000000000000000;
|
||||
b
|
||||
9223372036854775808
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
|
||||
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',
|
||||
|
@ -1,6 +1,10 @@
|
||||
drop table if exists t1,v1;
|
||||
drop view if exists t1,v1;
|
||||
drop procedure if exists f1;
|
||||
use test;
|
||||
create table t1 (field1 INT);
|
||||
CREATE VIEW v1 AS SELECT field1 FROM t1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create procedure f1() select 1;
|
||||
drop procedure f1;
|
@ -646,4 +646,29 @@ drop procedure if exists bug10537|
|
||||
create procedure bug10537()
|
||||
load data local infile '/tmp/somefile' into table t1|
|
||||
ERROR 0A000: LOAD DATA is not allowed in stored procedures
|
||||
drop function if exists bug8409|
|
||||
create function bug8409()
|
||||
returns int
|
||||
begin
|
||||
flush tables;
|
||||
return 5;
|
||||
end|
|
||||
ERROR 0A000: FLUSH is not allowed in stored procedures
|
||||
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890()
|
||||
begin
|
||||
end|
|
||||
ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long
|
||||
drop procedure if exists bug10969|
|
||||
create procedure bug10969()
|
||||
begin
|
||||
declare s1 int default 0;
|
||||
select default(s1) from t30;
|
||||
end|
|
||||
ERROR 42000: Incorrect column name 's1'
|
||||
create procedure bug10969()
|
||||
begin
|
||||
declare s1 int default 0;
|
||||
select default(t30.s1) from t30;
|
||||
end|
|
||||
drop procedure bug10969|
|
||||
drop table t1|
|
||||
|
@ -3098,4 +3098,44 @@ call bug5963_2(1)|
|
||||
call bug5963_2(1)|
|
||||
drop procedure bug5963_2|
|
||||
drop table t3|
|
||||
drop function if exists bug9559|
|
||||
create function bug9559()
|
||||
returns int
|
||||
begin
|
||||
set @y = -6/2;
|
||||
return @y;
|
||||
end|
|
||||
select bug9559()|
|
||||
bug9559()
|
||||
-3
|
||||
drop function bug9559|
|
||||
drop procedure if exists bug10961|
|
||||
create procedure bug10961()
|
||||
begin
|
||||
declare v char;
|
||||
declare x int;
|
||||
declare c cursor for select * from dual;
|
||||
declare continue handler for sqlexception select x;
|
||||
set x = 1;
|
||||
open c;
|
||||
set x = 2;
|
||||
fetch c into v;
|
||||
set x = 3;
|
||||
close c;
|
||||
end|
|
||||
call bug10961()|
|
||||
x
|
||||
1
|
||||
x
|
||||
2
|
||||
x
|
||||
3
|
||||
call bug10961()|
|
||||
x
|
||||
1
|
||||
x
|
||||
2
|
||||
x
|
||||
3
|
||||
drop procedure bug10961|
|
||||
drop table t1,t2;
|
||||
|
@ -140,6 +140,48 @@ drop trigger t1.trg1;
|
||||
drop trigger t1.trg2;
|
||||
drop trigger t1.trg3;
|
||||
drop table t1;
|
||||
create table t1 (id int not null primary key, data int);
|
||||
create trigger t1_bi before insert on t1 for each row
|
||||
set @log:= concat(@log, "(BEFORE_INSERT: new=(id=", new.id, ", data=", new.data,"))");
|
||||
create trigger t1_ai after insert on t1 for each row
|
||||
set @log:= concat(@log, "(AFTER_INSERT: new=(id=", new.id, ", data=", new.data,"))");
|
||||
create trigger t1_bu before update on t1 for each row
|
||||
set @log:= concat(@log, "(BEFORE_UPDATE: old=(id=", old.id, ", data=", old.data,
|
||||
") new=(id=", new.id, ", data=", new.data,"))");
|
||||
create trigger t1_au after update on t1 for each row
|
||||
set @log:= concat(@log, "(AFTER_UPDATE: old=(id=", old.id, ", data=", old.data,
|
||||
") new=(id=", new.id, ", data=", new.data,"))");
|
||||
create trigger t1_bd before delete on t1 for each row
|
||||
set @log:= concat(@log, "(BEFORE_DELETE: old=(id=", old.id, ", data=", old.data,"))");
|
||||
create trigger t1_ad after delete on t1 for each row
|
||||
set @log:= concat(@log, "(AFTER_DELETE: old=(id=", old.id, ", data=", old.data,"))");
|
||||
set @log:= "";
|
||||
insert into t1 values (1, 1);
|
||||
select @log;
|
||||
@log
|
||||
(BEFORE_INSERT: new=(id=1, data=1))(AFTER_INSERT: new=(id=1, data=1))
|
||||
set @log:= "";
|
||||
insert ignore t1 values (1, 2);
|
||||
select @log;
|
||||
@log
|
||||
(BEFORE_INSERT: new=(id=1, data=2))
|
||||
set @log:= "";
|
||||
replace t1 values (1, 3), (2, 2);
|
||||
select @log;
|
||||
@log
|
||||
(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(BEFORE_INSERT: new=(id=2, data=2))(AFTER_INSERT: new=(id=2, data=2))
|
||||
alter table t1 add ts timestamp default now();
|
||||
set @log:= "";
|
||||
replace t1 (id, data) values (1, 4);
|
||||
select @log;
|
||||
@log
|
||||
(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=3))(AFTER_DELETE: old=(id=1, data=3))(AFTER_INSERT: new=(id=1, data=4))
|
||||
set @log:= "";
|
||||
insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2;
|
||||
select @log;
|
||||
@log
|
||||
(BEFORE_INSERT: new=(id=1, data=5))(BEFORE_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(AFTER_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(BEFORE_INSERT: new=(id=3, data=3))(AFTER_INSERT: new=(id=3, data=3))
|
||||
drop table t1;
|
||||
create table t1 (i int);
|
||||
create trigger trg before insert on t1 for each row set @a:= old.i;
|
||||
ERROR HY000: There is no OLD row in on INSERT trigger
|
||||
@ -206,3 +248,237 @@ create table t1 (i int);
|
||||
create trigger trg1 before insert on t1 for each row set @a:= 1;
|
||||
drop database mysqltest;
|
||||
use test;
|
||||
create table t1 (i int, j int default 10, k int not null, key (k));
|
||||
create table t2 (i int);
|
||||
insert into t1 (i, k) values (1, 1);
|
||||
insert into t2 values (1);
|
||||
create trigger trg1 before update on t1 for each row set @a:= @a + new.j - old.j;
|
||||
create trigger trg2 after update on t1 for each row set @b:= "Fired";
|
||||
set @a:= 0, @b:= "";
|
||||
update t1, t2 set j = j + 10 where t1.i = t2.i;
|
||||
select @a, @b;
|
||||
@a @b
|
||||
10 Fired
|
||||
insert into t1 values (2, 13, 2);
|
||||
insert into t2 values (2);
|
||||
set @a:= 0, @b:= "";
|
||||
update t1, t2 set j = j + 15 where t1.i = t2.i and t1.k >= 2;
|
||||
select @a, @b;
|
||||
@a @b
|
||||
15 Fired
|
||||
create trigger trg3 before delete on t1 for each row set @c:= @c + old.j;
|
||||
create trigger trg4 before delete on t2 for each row set @d:= @d + old.i;
|
||||
create trigger trg5 after delete on t1 for each row set @e:= "After delete t1 fired";
|
||||
create trigger trg6 after delete on t2 for each row set @f:= "After delete t2 fired";
|
||||
set @c:= 0, @d:= 0, @e:= "", @f:= "";
|
||||
delete t1, t2 from t1, t2 where t1.i = t2.i;
|
||||
select @c, @d, @e, @f;
|
||||
@c @d @e @f
|
||||
48 3 After delete t1 fired After delete t2 fired
|
||||
drop table t1, t2;
|
||||
create table t1 (i int, j int default 10)|
|
||||
create table t2 (i int)|
|
||||
insert into t2 values (1), (2)|
|
||||
create trigger trg1 before insert on t1 for each row
|
||||
begin
|
||||
if new.i = 1 then
|
||||
set new.j := 1;
|
||||
end if;
|
||||
end|
|
||||
create trigger trg2 after insert on t1 for each row set @a:= 1|
|
||||
set @a:= 0|
|
||||
insert into t1 (i) select * from t2|
|
||||
select * from t1|
|
||||
i j
|
||||
1 1
|
||||
2 10
|
||||
select @a|
|
||||
@a
|
||||
1
|
||||
drop table t1, t2|
|
||||
create table t1 (i int, j int, k int);
|
||||
create trigger trg1 before insert on t1 for each row set new.k = new.i;
|
||||
create trigger trg2 after insert on t1 for each row set @b:= "Fired";
|
||||
set @b:="";
|
||||
load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i);
|
||||
select *, @b from t1;
|
||||
i j k @b
|
||||
10 NULL 10 Fired
|
||||
15 NULL 15 Fired
|
||||
set @b:="";
|
||||
load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j);
|
||||
select *, @b from t1;
|
||||
i j k @b
|
||||
10 NULL 10 Fired
|
||||
15 NULL 15 Fired
|
||||
1 2 1 Fired
|
||||
3 4 3 Fired
|
||||
5 6 5 Fired
|
||||
drop table t1;
|
||||
create table t1 (i int, at int, k int, key(k)) engine=myisam;
|
||||
create table t2 (i int);
|
||||
insert into t1 values (1, 1, 1);
|
||||
insert into t2 values (1), (2), (3);
|
||||
create trigger ai after insert on t1 for each row set @a:= new.at;
|
||||
create trigger au after update on t1 for each row set @a:= new.at;
|
||||
create trigger ad after delete on t1 for each row set @a:= old.at;
|
||||
alter table t1 drop column at;
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
insert into t1 values (2, 1);
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 1
|
||||
update t1 set k = 2 where i = 2;
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
delete from t1 where i = 2;
|
||||
ERROR 42S22: Unknown column 'at' in 'OLD'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k);
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
1 2
|
||||
insert into t1 select 3, 3;
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
1 2
|
||||
3 3
|
||||
update t1, t2 set k = k + 10 where t1.i = t2.i;
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 11
|
||||
1 2
|
||||
3 3
|
||||
update t1, t2 set k = k + 10 where t1.i = t2.i and k < 3;
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 11
|
||||
1 12
|
||||
3 3
|
||||
delete t1, t2 from t1 straight_join t2 where t1.i = t2.i;
|
||||
ERROR 42S22: Unknown column 'at' in 'OLD'
|
||||
select * from t1;
|
||||
i k
|
||||
1 12
|
||||
3 3
|
||||
delete t2, t1 from t2 straight_join t1 where t1.i = t2.i;
|
||||
ERROR 42S22: Unknown column 'at' in 'OLD'
|
||||
select * from t1;
|
||||
i k
|
||||
3 3
|
||||
alter table t1 add primary key (i);
|
||||
insert into t1 values (3, 4) on duplicate key update k= k + 10;
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
3 13
|
||||
replace into t1 values (3, 3);
|
||||
ERROR 42S22: Unknown column 'at' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
3 3
|
||||
alter table t1 add ts timestamp default now();
|
||||
replace into t1 (i, k) values (3, 13);
|
||||
ERROR 42S22: Unknown column 'at' in 'OLD'
|
||||
select * from t1;
|
||||
i k ts
|
||||
drop table t1, t2;
|
||||
create table t1 (i int, bt int, k int, key(k)) engine=myisam;
|
||||
create table t2 (i int);
|
||||
insert into t1 values (1, 1, 1), (2, 2, 2);
|
||||
insert into t2 values (1), (2), (3);
|
||||
create trigger bi before insert on t1 for each row set @a:= new.bt;
|
||||
create trigger bu before update on t1 for each row set @a:= new.bt;
|
||||
create trigger bd before delete on t1 for each row set @a:= old.bt;
|
||||
alter table t1 drop column bt;
|
||||
insert into t1 values (3, 3);
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
update t1 set i = 2;
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
delete from t1;
|
||||
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k);
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
insert into t1 select 3, 3;
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
update t1, t2 set k = k + 10 where t1.i = t2.i;
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
update t1, t2 set k = k + 10 where t1.i = t2.i and k < 2;
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
delete t1, t2 from t1 straight_join t2 where t1.i = t2.i;
|
||||
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
delete t2, t1 from t2 straight_join t1 where t1.i = t2.i;
|
||||
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
alter table t1 add primary key (i);
|
||||
drop trigger t1.bi;
|
||||
insert into t1 values (2, 4) on duplicate key update k= k + 10;
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
replace into t1 values (2, 4);
|
||||
ERROR 42S22: Unknown column 'bt' in 'NEW'
|
||||
select * from t1;
|
||||
i k
|
||||
1 1
|
||||
2 2
|
||||
alter table t1 add ts timestamp default now();
|
||||
replace into t1 (i, k) values (2, 11);
|
||||
ERROR 42S22: Unknown column 'bt' in 'OLD'
|
||||
select * from t1;
|
||||
i k ts
|
||||
1 1 0000-00-00 00:00:00
|
||||
2 2 0000-00-00 00:00:00
|
||||
drop table t1, t2;
|
||||
|
@ -1252,3 +1252,36 @@ t2 CREATE TABLE `t2` (
|
||||
`a` varchar(12) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a mediumtext);
|
||||
CREATE TABLE t2 (b varchar(20));
|
||||
INSERT INTO t1 VALUES ('a'),('b');
|
||||
SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
|
||||
left(a,100000000)
|
||||
a
|
||||
b
|
||||
create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`left(a,100000000)` longtext
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop tables t1,t2,t3;
|
||||
create table t1 ( id int not null auto_increment, primary key (id), col1 int);
|
||||
insert into t1 (col1) values (2),(3),(4),(5),(6);
|
||||
select 99 union all select id from t1 order by 1;
|
||||
99
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
99
|
||||
select id from t1 union all select 99 order by 1;
|
||||
id
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
99
|
||||
drop table t1;
|
||||
|
@ -236,6 +236,12 @@ query_prealloc_size 8192
|
||||
range_alloc_block_size 2048
|
||||
transaction_alloc_block_size 8192
|
||||
transaction_prealloc_size 4096
|
||||
SELECT @@version LIKE 'non-existent';
|
||||
@@version LIKE 'non-existent'
|
||||
0
|
||||
SELECT @@version_compile_os LIKE 'non-existent';
|
||||
@@version_compile_os LIKE 'non-existent'
|
||||
0
|
||||
set big_tables=OFFF;
|
||||
ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF'
|
||||
set big_tables="OFFF";
|
||||
|
Reference in New Issue
Block a user