mirror of
https://github.com/MariaDB/server.git
synced 2025-12-04 17:23:46 +03:00
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1
into whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-single-user
This commit is contained in:
@@ -460,8 +460,8 @@ t2 CREATE TABLE `t2` (
|
||||
`ifnull(c,c)` mediumint(8) DEFAULT NULL,
|
||||
`ifnull(d,d)` int(11) DEFAULT NULL,
|
||||
`ifnull(e,e)` bigint(20) DEFAULT NULL,
|
||||
`ifnull(f,f)` float(24,2) DEFAULT NULL,
|
||||
`ifnull(g,g)` double(53,3) DEFAULT NULL,
|
||||
`ifnull(f,f)` float(3,2) DEFAULT NULL,
|
||||
`ifnull(g,g)` double(4,3) DEFAULT NULL,
|
||||
`ifnull(h,h)` decimal(5,4) DEFAULT NULL,
|
||||
`ifnull(i,i)` year(4) DEFAULT NULL,
|
||||
`ifnull(j,j)` date DEFAULT NULL,
|
||||
|
||||
@@ -477,6 +477,11 @@ a
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '19772-07-29' for column 'a' at row 1
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
CREATE TABLE t1 (id int not null);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
|
||||
id
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
create table t1(f1 char(1));
|
||||
insert into t1 values ('a'),('b'),('1');
|
||||
|
||||
@@ -730,3 +730,32 @@ f1 f2
|
||||
2 2
|
||||
10 10
|
||||
DROP TABLE t1, t2;
|
||||
SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
|
||||
CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
|
||||
CREATE TABLE t2 (d VARCHAR(10));
|
||||
INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters');
|
||||
EXPLAIN
|
||||
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ref ix_c ix_c 13 const 1 Using where
|
||||
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
|
||||
(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters')
|
||||
13
|
||||
13
|
||||
INSERT INTO t2 (d)
|
||||
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
|
||||
INSERT INTO t2 (d)
|
||||
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1;
|
||||
INSERT INTO t2 (d)
|
||||
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1))
|
||||
FROM t1;
|
||||
SELECT * FROM t2;
|
||||
d
|
||||
13
|
||||
13
|
||||
7
|
||||
7
|
||||
20
|
||||
20
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
@@ -3712,12 +3712,6 @@ bb 2
|
||||
cc 3
|
||||
dd 1
|
||||
DROP TABLE t1,t2,t3;
|
||||
CREATE TABLE t1 (s1 char(1));
|
||||
INSERT INTO t1 VALUES ('a');
|
||||
SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1);
|
||||
s1
|
||||
a
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(f1 int);
|
||||
CREATE TABLE t2(f2 int, f21 int, f3 timestamp);
|
||||
INSERT INTO t1 VALUES (1),(1),(2),(2);
|
||||
@@ -3886,3 +3880,34 @@ this is a test. 3
|
||||
this is a test. 1
|
||||
this is a test. 2
|
||||
DROP table t1;
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
CREATE TABLE t2 (m int, n int);
|
||||
INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4);
|
||||
INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44);
|
||||
SELECT COUNT(*), a,
|
||||
(SELECT m FROM t2 WHERE m = count(*) LIMIT 1)
|
||||
FROM t1 GROUP BY a;
|
||||
COUNT(*) a (SELECT m FROM t2 WHERE m = count(*) LIMIT 1)
|
||||
2 2 2
|
||||
3 3 3
|
||||
1 4 1
|
||||
SELECT COUNT(*), a,
|
||||
(SELECT MIN(m) FROM t2 WHERE m = count(*))
|
||||
FROM t1 GROUP BY a;
|
||||
COUNT(*) a (SELECT MIN(m) FROM t2 WHERE m = count(*))
|
||||
2 2 2
|
||||
3 3 3
|
||||
1 4 1
|
||||
SELECT COUNT(*), a
|
||||
FROM t1 GROUP BY a
|
||||
HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1;
|
||||
COUNT(*) a
|
||||
2 2
|
||||
3 3
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (s1 char(1));
|
||||
INSERT INTO t1 VALUES ('a');
|
||||
SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1);
|
||||
s1
|
||||
a
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -645,3 +645,56 @@ a b Z
|
||||
2 2 0
|
||||
3 3 1
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
|
||||
INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
|
||||
(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'),
|
||||
(1,9,'m');
|
||||
CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b))
|
||||
as test FROM t1 GROUP BY a;
|
||||
a MAX(b) test
|
||||
1 9 m
|
||||
2 3 h
|
||||
3 4 i
|
||||
SELECT * FROM t1 GROUP by t1.a
|
||||
HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c
|
||||
HAVING MAX(t2.b+t1.a) < 10));
|
||||
a b c
|
||||
SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b))
|
||||
AS test FROM t1 GROUP BY a;
|
||||
a AVG(b) test
|
||||
1 4.0000 NULL
|
||||
2 2.0000 k
|
||||
3 2.5000 NULL
|
||||
SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c;
|
||||
a b c
|
||||
1 3 c
|
||||
2 3 h
|
||||
3 3 j
|
||||
1 4 d
|
||||
3 4 i
|
||||
1 9 m
|
||||
SELECT a, MAX(b),
|
||||
(SELECT COUNT(DISTINCT t.c) FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)
|
||||
LIMIT 1)
|
||||
as cnt,
|
||||
(SELECT t.b FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1)
|
||||
as t_b,
|
||||
(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1)
|
||||
as t_b,
|
||||
(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) ORDER BY t.c LIMIT 1)
|
||||
as t_b
|
||||
FROM t1 GROUP BY a;
|
||||
a MAX(b) cnt t_b t_b t_b
|
||||
1 9 1 9 m m
|
||||
2 3 1 3 h h
|
||||
3 4 1 4 i i
|
||||
SELECT a, MAX(b),
|
||||
(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as test
|
||||
FROM t1 GROUP BY a;
|
||||
a MAX(b) test
|
||||
1 9 m
|
||||
2 3 h
|
||||
3 4 i
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
@@ -152,6 +152,27 @@ SELECT * FROM t1;
|
||||
i
|
||||
DROP TABLE t1;
|
||||
End of 4.1 tests.
|
||||
CREATE TABLE t1 ( c FLOAT( 20, 14 ) );
|
||||
INSERT INTO t1 VALUES( 12139 );
|
||||
CREATE TABLE t2 ( c FLOAT(30,18) );
|
||||
INSERT INTO t2 VALUES( 123456 );
|
||||
SELECT AVG( c ) FROM t1 UNION SELECT 1;
|
||||
AVG( c )
|
||||
12139
|
||||
1
|
||||
SELECT 1 UNION SELECT AVG( c ) FROM t1;
|
||||
1
|
||||
1
|
||||
12139
|
||||
SELECT 1 UNION SELECT * FROM t2 UNION SELECT 1;
|
||||
1
|
||||
1
|
||||
123456
|
||||
SELECT c/1 FROM t1 UNION SELECT 1;
|
||||
c/1
|
||||
12139
|
||||
1
|
||||
DROP TABLE t1, t2;
|
||||
create temporary table t1 (a int);
|
||||
insert into t1 values (4711);
|
||||
select * from t1;
|
||||
|
||||
@@ -168,6 +168,9 @@ dt
|
||||
0000-00-00 00:00:00
|
||||
0000-00-00 00:00:00
|
||||
drop table t1;
|
||||
select cast('2006-12-05 22:10:10' as datetime) + 0;
|
||||
cast('2006-12-05 22:10:10' as datetime) + 0
|
||||
20061205221010.000000
|
||||
CREATE TABLE t1(a DATETIME NOT NULL);
|
||||
INSERT INTO t1 VALUES ('20060606155555');
|
||||
SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
|
||||
|
||||
@@ -92,7 +92,7 @@ show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`col1` double DEFAULT NULL,
|
||||
`col2` double(53,5) DEFAULT NULL,
|
||||
`col2` double(22,5) DEFAULT NULL,
|
||||
`col3` double DEFAULT NULL,
|
||||
`col4` double DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
@@ -232,12 +232,12 @@ insert into t2 values ("1.23456780");
|
||||
create table t3 select * from t2 union select * from t1;
|
||||
select * from t3;
|
||||
d
|
||||
1.234567800
|
||||
100000000.000000000
|
||||
1.2345678
|
||||
100000000
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`d` double(22,9) DEFAULT NULL
|
||||
`d` double DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1, t2, t3;
|
||||
create table t1 select 105213674794682365.00 + 0.0 x;
|
||||
|
||||
@@ -554,7 +554,7 @@ aa
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` varbinary(20) NOT NULL DEFAULT ''
|
||||
`a` varbinary(2) NOT NULL DEFAULT ''
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT 12 as a UNION select 12.2 as a;
|
||||
@@ -655,7 +655,7 @@ f
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`f` varbinary(24) DEFAULT NULL
|
||||
`f` varbinary(12) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 SELECT y from t2 UNION select da from t2;
|
||||
@@ -1437,4 +1437,12 @@ a
|
||||
SELECT a FROM (SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY c) AS test;
|
||||
ERROR 42S22: Unknown column 'c' in 'order clause'
|
||||
DROP TABLE t1;
|
||||
(select 1 into @var) union (select 1);
|
||||
ERROR HY000: Incorrect usage of UNION and INTO
|
||||
(select 1) union (select 1 into @var);
|
||||
select @var;
|
||||
@var
|
||||
1
|
||||
(select 2) union (select 1 into @var);
|
||||
ERROR 42000: Result consisted of more than one row
|
||||
End of 5.0 tests
|
||||
|
||||
@@ -3321,38 +3321,4 @@ DROP TABLE `t-2`;
|
||||
DROP VIEW `v-2`;
|
||||
DROP DATABASE `d-1`;
|
||||
USE test;
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (i INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
ALTER VIEW v1 AS SELECT * FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_2' registered
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_2' registered
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
|
||||
@@ -775,4 +775,58 @@ DROP DATABASE mysqltest_db1;
|
||||
DROP DATABASE mysqltest_db2;
|
||||
DROP USER mysqltest_u1@localhost;
|
||||
DROP USER mysqltest_u2@localhost;
|
||||
CREATE DATABASE db26813;
|
||||
USE db26813;
|
||||
CREATE TABLE t1(f1 INT, f2 INT);
|
||||
CREATE VIEW v1 AS SELECT f1 FROM t1;
|
||||
CREATE VIEW v2 AS SELECT f1 FROM t1;
|
||||
CREATE VIEW v3 AS SELECT f1 FROM t1;
|
||||
CREATE USER u26813@localhost;
|
||||
GRANT DROP ON db26813.v1 TO u26813@localhost;
|
||||
GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost;
|
||||
GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost;
|
||||
GRANT SELECT ON db26813.t1 TO u26813@localhost;
|
||||
ALTER VIEW v1 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1'
|
||||
ALTER VIEW v2 AS SELECT f2 FROM t1;
|
||||
ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2'
|
||||
ALTER VIEW v3 AS SELECT f2 FROM t1;
|
||||
SHOW CREATE VIEW v3;
|
||||
View Create View
|
||||
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1`
|
||||
DROP USER u26813@localhost;
|
||||
DROP DATABASE db26813;
|
||||
End of 5.0 tests.
|
||||
DROP VIEW IF EXISTS v1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (i INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
ALTER VIEW v1 AS SELECT * FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
ALTER DEFINER=no_such@user_1 VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_1' registered
|
||||
ALTER ALGORITHM=TEMPTABLE DEFINER=no_such@user_2 VIEW v1 AS SELECT * FROM t1;
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_2' registered
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`no_such`@`user_2` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1`
|
||||
Warnings:
|
||||
Note 1449 There is no 'no_such'@'user_2' registered
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
|
||||
Reference in New Issue
Block a user