mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.0
into whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb-merge
This commit is contained in:
commit
820a2b8c51
25 changed files with 576 additions and 27 deletions
|
@ -1345,3 +1345,8 @@ zlib/*.vcproj
|
|||
debian/control
|
||||
debian/defs.mk
|
||||
include/abi_check
|
||||
support-files/mysqld_multi.server
|
||||
tests/bug25714
|
||||
cscope.in.out
|
||||
cscope.out
|
||||
cscope.po.out
|
||||
|
|
|
@ -2898,7 +2898,7 @@ int init_dumping_tables(char *qdatabase)
|
|||
/* Old server version, dump generic CREATE DATABASE */
|
||||
if (opt_drop_database)
|
||||
fprintf(md_result_file,
|
||||
"\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n",
|
||||
"\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n",
|
||||
qdatabase);
|
||||
fprintf(md_result_file,
|
||||
"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
|
||||
|
|
|
@ -773,11 +773,8 @@ case $CXX_VERSION in
|
|||
ARFLAGS="-xar -o"
|
||||
;;
|
||||
*)
|
||||
if test -z "$AR"
|
||||
then
|
||||
AC_CHECK_PROG([AR], [ar], [ar])
|
||||
fi
|
||||
if test -z "$AR"
|
||||
AC_CHECK_PROG([AR], [ar], [ar])
|
||||
if test -z "$AR" || test "$AR" = "false"
|
||||
then
|
||||
AC_MSG_ERROR([You need ar to build the library])
|
||||
fi
|
||||
|
|
|
@ -183,6 +183,17 @@ select @a;
|
|||
@a
|
||||
1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
`date` date ,
|
||||
`time` time ,
|
||||
`seq` int(10) unsigned NOT NULL auto_increment,
|
||||
PRIMARY KEY (`seq`),
|
||||
KEY `seq` (`seq`),
|
||||
KEY `time` (`time`),
|
||||
KEY `date` (`date`)
|
||||
);
|
||||
DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1 (a int not null,b int not null);
|
||||
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
|
||||
|
@ -223,3 +234,40 @@ ERROR 42S22: Unknown column 't2.x' in 'order clause'
|
|||
DELETE FROM t1 ORDER BY (SELECT x);
|
||||
ERROR 42S22: Unknown column 'x' in 'field list'
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
a INT
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
a INT
|
||||
);
|
||||
CREATE DATABASE db1;
|
||||
CREATE TABLE db1.t1 (
|
||||
a INT
|
||||
);
|
||||
INSERT INTO db1.t1 (a) SELECT * FROM t1;
|
||||
CREATE DATABASE db2;
|
||||
CREATE TABLE db2.t1 (
|
||||
a INT
|
||||
);
|
||||
INSERT INTO db2.t1 (a) SELECT * FROM t2;
|
||||
DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
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 'alias USING t1, t2 alias WHERE t1.a = alias.a' at line 1
|
||||
DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
ERROR 42S02: Unknown table 't2' in MULTI DELETE
|
||||
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
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 'alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1
|
||||
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
ERROR 42S02: Unknown table 'alias' in MULTI DELETE
|
||||
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
DELETE FROM t1 USING t1 WHERE a = 1;
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
DELETE FROM t1 alias USING t1 alias WHERE a = 2;
|
||||
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 'alias USING t1 alias WHERE a = 2' at line 1
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
DROP TABLE t1, t2;
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
|
|
|
@ -526,10 +526,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
|
||||
EXPLAIN SELECT a,b FROM t1 GROUP BY a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
EXPLAIN SELECT DISTINCT a,b FROM t1 GROUP BY a,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
CREATE TABLE t2(a INT, b INT NOT NULL, c INT NOT NULL, d INT,
|
||||
PRIMARY KEY (a,b));
|
||||
INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
|
@ -554,7 +554,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
CREATE UNIQUE INDEX c_b_unq ON t2 (c,b);
|
||||
EXPLAIN SELECT DISTINCT a,b,d FROM t2 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
DROP TABLE t1,t2;
|
||||
create table t1 (id int, dsc varchar(50));
|
||||
insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
|
||||
|
|
|
@ -1064,3 +1064,52 @@ select t1.f1,t.* from t1, t1 t group by 1;
|
|||
ERROR 42000: 'test.t.f1' isn't in GROUP BY
|
||||
drop table t1;
|
||||
SET SQL_MODE = '';
|
||||
CREATE TABLE t1(
|
||||
a INT,
|
||||
b INT NOT NULL,
|
||||
c INT NOT NULL,
|
||||
d INT,
|
||||
UNIQUE KEY (c,b)
|
||||
);
|
||||
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
c b d
|
||||
1 1 50
|
||||
3 2 40
|
||||
3 1 4
|
||||
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 8 NULL 3 Using index
|
||||
SELECT c,b FROM t1 GROUP BY c,b;
|
||||
c b
|
||||
1 1
|
||||
3 1
|
||||
3 2
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -1065,4 +1065,53 @@ a b
|
|||
ROLLBACK;
|
||||
ROLLBACK;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(
|
||||
a INT,
|
||||
b INT NOT NULL,
|
||||
c INT NOT NULL,
|
||||
d INT,
|
||||
UNIQUE KEY (c,b)
|
||||
) engine=innodb;
|
||||
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
|
||||
SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 8 NULL 3
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
c b d
|
||||
1 1 50
|
||||
3 1 4
|
||||
3 2 40
|
||||
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL c 8 NULL 3 Using index
|
||||
SELECT c,b FROM t1 GROUP BY c,b;
|
||||
c b
|
||||
1 1
|
||||
3 1
|
||||
3 2
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
|
|
4
mysql-test/r/mysqldump-compat.result
Normal file
4
mysql-test/r/mysqldump-compat.result
Normal file
|
@ -0,0 +1,4 @@
|
|||
CREATE DATABASE mysqldump_30126;
|
||||
USE mysqldump_30126;
|
||||
CREATE TABLE t1 (c1 int);
|
||||
DROP DATABASE mysqldump_30126;
|
|
@ -6315,6 +6315,28 @@ CALL p1();
|
|||
NULL
|
||||
SET NAMES default;
|
||||
DROP PROCEDURE p1;
|
||||
create function f1()
|
||||
returns int(11)
|
||||
not deterministic
|
||||
contains sql
|
||||
sql security definer
|
||||
comment ''
|
||||
begin
|
||||
declare x int(11);
|
||||
set x=-1;
|
||||
return x;
|
||||
end|
|
||||
create view v1 as select 1 as one, f1() as days;
|
||||
show create view test.v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select 1 AS `one`,`f1`() AS `days`
|
||||
select column_name from information_schema.columns
|
||||
where table_name='v1' and table_schema='test';
|
||||
column_name
|
||||
one
|
||||
days
|
||||
drop view v1;
|
||||
drop function f1;
|
||||
|
||||
# Bug#13675.
|
||||
|
||||
|
|
|
@ -43,3 +43,51 @@ SHOW STATUS LIKE 'max_used_connections';
|
|||
Variable_name Value
|
||||
Max_used_connections 4
|
||||
SET GLOBAL thread_cache_size=@save_thread_cache_size;
|
||||
CREATE TABLE t1 ( a INT );
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
SELECT a FROM t1 LIMIT 1;
|
||||
a
|
||||
1
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 2.402418
|
||||
EXPLAIN SELECT a FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 2.402418
|
||||
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
||||
a
|
||||
1
|
||||
2
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 0.000000
|
||||
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
2 UNION t1 ALL NULL NULL NULL NULL 2
|
||||
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL Using filesort
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 0.000000
|
||||
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
|
||||
a IN (SELECT a FROM t1)
|
||||
1
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 0.000000
|
||||
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
|
||||
x
|
||||
1
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 0.000000
|
||||
SELECT * FROM t1 a, t1 b LIMIT 1;
|
||||
a a
|
||||
1 1
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
Variable_name Value
|
||||
Last_query_cost 4.805836
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -642,4 +642,19 @@ b+0 COUNT(DISTINCT a)
|
|||
1 1
|
||||
3 2
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (b BIT);
|
||||
INSERT INTO t1 (b) VALUES (1), (0);
|
||||
SELECT DISTINCT b FROM t1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 b b 16 1 1 Y 32 0 63
|
||||
b
|
||||
#
|
||||
#
|
||||
SELECT b FROM t1 GROUP BY b;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 b b 16 1 1 Y 32 0 63
|
||||
b
|
||||
#
|
||||
#
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
|
|
|
@ -173,8 +173,20 @@ delete from t1 where (@a:= f1) order by f1 limit 1;
|
|||
select @a;
|
||||
drop table t1;
|
||||
|
||||
# BUG#30385 "Server crash when deleting with order by and limit"
|
||||
CREATE TABLE t1 (
|
||||
`date` date ,
|
||||
`time` time ,
|
||||
`seq` int(10) unsigned NOT NULL auto_increment,
|
||||
PRIMARY KEY (`seq`),
|
||||
KEY `seq` (`seq`),
|
||||
KEY `time` (`time`),
|
||||
KEY `date` (`date`)
|
||||
);
|
||||
DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 4.1 tests
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
# Test of multi-delete where we are not scanning the first table
|
||||
|
@ -221,3 +233,47 @@ DELETE FROM t1 ORDER BY t2.x;
|
|||
DELETE FROM t1 ORDER BY (SELECT x);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #30234: Unexpected behavior using DELETE with AS and USING
|
||||
# '
|
||||
CREATE TABLE t1 (
|
||||
a INT
|
||||
);
|
||||
|
||||
CREATE TABLE t2 (
|
||||
a INT
|
||||
);
|
||||
|
||||
CREATE DATABASE db1;
|
||||
CREATE TABLE db1.t1 (
|
||||
a INT
|
||||
);
|
||||
INSERT INTO db1.t1 (a) SELECT * FROM t1;
|
||||
|
||||
CREATE DATABASE db2;
|
||||
CREATE TABLE db2.t1 (
|
||||
a INT
|
||||
);
|
||||
INSERT INTO db2.t1 (a) SELECT * FROM t2;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
--error ER_UNKNOWN_TABLE
|
||||
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
--error ER_PARSE_ERROR
|
||||
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
--error ER_UNKNOWN_TABLE
|
||||
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
DELETE FROM t1 USING t1 WHERE a = 1;
|
||||
SELECT * FROM t1;
|
||||
--error ER_PARSE_ERROR
|
||||
DELETE FROM t1 alias USING t1 alias WHERE a = 2;
|
||||
SELECT * FROM t1;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
|
|
|
@ -788,3 +788,30 @@ select * from t1 group by f1, f2;
|
|||
select t1.f1,t.* from t1, t1 t group by 1;
|
||||
drop table t1;
|
||||
SET SQL_MODE = '';
|
||||
|
||||
#
|
||||
# Bug#30596: GROUP BY optimization gives wrong result order
|
||||
#
|
||||
CREATE TABLE t1(
|
||||
a INT,
|
||||
b INT NOT NULL,
|
||||
c INT NOT NULL,
|
||||
d INT,
|
||||
UNIQUE KEY (c,b)
|
||||
);
|
||||
|
||||
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
|
||||
SELECT c,b FROM t1 GROUP BY c,b;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -910,4 +910,31 @@ ROLLBACK;
|
|||
ROLLBACK;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#30596: GROUP BY optimization gives wrong result order
|
||||
#
|
||||
CREATE TABLE t1(
|
||||
a INT,
|
||||
b INT NOT NULL,
|
||||
c INT NOT NULL,
|
||||
d INT,
|
||||
UNIQUE KEY (c,b)
|
||||
) engine=innodb;
|
||||
|
||||
INSERT INTO t1 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
|
||||
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d;
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL;
|
||||
EXPLAIN SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
SELECT c,b,d FROM t1 ORDER BY c,b,d;
|
||||
|
||||
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
SELECT c,b,d FROM t1 GROUP BY c,b;
|
||||
EXPLAIN SELECT c,b FROM t1 GROUP BY c,b;
|
||||
SELECT c,b FROM t1 GROUP BY c,b;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
|
1
mysql-test/t/mysqldump-compat.opt
Normal file
1
mysql-test/t/mysqldump-compat.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--loose-debug=d,4x_server_emul
|
13
mysql-test/t/mysqldump-compat.test
Normal file
13
mysql-test/t/mysqldump-compat.test
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Embedded server doesn't support external clients
|
||||
--source include/not_embedded.inc
|
||||
|
||||
#
|
||||
# Bug #30126: semicolon before closing */ in /*!... CREATE DATABASE ;*/
|
||||
#
|
||||
|
||||
CREATE DATABASE mysqldump_30126;
|
||||
USE mysqldump_30126;
|
||||
CREATE TABLE t1 (c1 int);
|
||||
--exec $MYSQL_DUMP --add-drop-database mysqldump_30126 > $MYSQLTEST_VARDIR/tmp/bug30126.sql
|
||||
--exec $MYSQL mysqldump_30126 < $MYSQLTEST_VARDIR/tmp/bug30126.sql
|
||||
DROP DATABASE mysqldump_30126;
|
|
@ -7300,6 +7300,39 @@ CALL p1();
|
|||
SET NAMES default;
|
||||
DROP PROCEDURE p1;
|
||||
|
||||
#
|
||||
# Bug#29408 Cannot find view in columns table if the selection contains a function
|
||||
#
|
||||
delimiter |;
|
||||
|
||||
create function f1()
|
||||
returns int(11)
|
||||
not deterministic
|
||||
contains sql
|
||||
sql security definer
|
||||
comment ''
|
||||
begin
|
||||
declare x int(11);
|
||||
set x=-1;
|
||||
return x;
|
||||
end|
|
||||
|
||||
delimiter ;|
|
||||
|
||||
create view v1 as select 1 as one, f1() as days;
|
||||
|
||||
connect (bug29408, localhost, root,,*NO-ONE*);
|
||||
connection bug29408;
|
||||
|
||||
show create view test.v1;
|
||||
select column_name from information_schema.columns
|
||||
where table_name='v1' and table_schema='test';
|
||||
|
||||
connection default;
|
||||
disconnect bug29408;
|
||||
drop view v1;
|
||||
drop function f1;
|
||||
|
||||
#
|
||||
# Bug#13675: DATETIME/DATE type in store proc param seems to be converted as
|
||||
# varbinary
|
||||
|
|
|
@ -139,4 +139,36 @@ disconnect con3;
|
|||
disconnect con2;
|
||||
disconnect con1;
|
||||
|
||||
|
||||
#
|
||||
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
|
||||
#
|
||||
|
||||
CREATE TABLE t1 ( a INT );
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
|
||||
SELECT a FROM t1 LIMIT 1;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
EXPLAIN SELECT a FROM t1;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
SELECT * FROM t1 a, t1 b LIMIT 1;
|
||||
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
# End of 5.0 tests
|
||||
|
|
|
@ -291,4 +291,17 @@ INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
|
|||
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug#30245: A wrong type of a BIT field is reported when grouped by it.
|
||||
#
|
||||
CREATE TABLE t1 (b BIT);
|
||||
INSERT INTO t1 (b) VALUES (1), (0);
|
||||
--enable_metadata
|
||||
--replace_column 1 #
|
||||
SELECT DISTINCT b FROM t1;
|
||||
--replace_column 1 #
|
||||
SELECT b FROM t1 GROUP BY b;
|
||||
--disable_metadata
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
|
|
@ -1597,10 +1597,10 @@ SEL_ARG *SEL_ARG::clone_tree(PARAM *param)
|
|||
the UPDATE/DELETE code will work:
|
||||
* index can only be scanned in forward direction
|
||||
* HA_EXTRA_KEYREAD will not be used
|
||||
Perhaps these assumptions could be relaxed
|
||||
Perhaps these assumptions could be relaxed.
|
||||
|
||||
RETURN
|
||||
index number
|
||||
Number of the index that produces the required ordering in the cheapest way
|
||||
MAX_KEY if no such index was found.
|
||||
*/
|
||||
|
||||
|
@ -1619,6 +1619,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit)
|
|||
if (!(table->keys_in_use_for_query.is_set(idx)))
|
||||
continue;
|
||||
KEY_PART_INFO *keyinfo= table->key_info[idx].key_part;
|
||||
uint n_parts= table->key_info[idx].key_parts;
|
||||
uint partno= 0;
|
||||
|
||||
/*
|
||||
|
@ -1628,7 +1629,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit)
|
|||
*/
|
||||
if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER))
|
||||
continue;
|
||||
for (ord= order; ord; ord= ord->next, partno++)
|
||||
for (ord= order; ord && partno < n_parts; ord= ord->next, partno++)
|
||||
{
|
||||
Item *item= order->item[0];
|
||||
if (!(item->type() == Item::FIELD_ITEM &&
|
||||
|
|
|
@ -1257,6 +1257,28 @@ typedef struct st_lex : public Query_tables_list
|
|||
|
||||
void reset_n_backup_query_tables_list(Query_tables_list *backup);
|
||||
void restore_backup_query_tables_list(Query_tables_list *backup);
|
||||
|
||||
/**
|
||||
@brief check if the statement is a single-level join
|
||||
@return result of the check
|
||||
@retval TRUE The statement doesn't contain subqueries, unions and
|
||||
stored procedure calls.
|
||||
@retval FALSE There are subqueries, UNIONs or stored procedure calls.
|
||||
*/
|
||||
bool is_single_level_stmt()
|
||||
{
|
||||
/*
|
||||
This check exploits the fact that the last added to all_select_list is
|
||||
on its top. So select_lex (as the first added) will be at the tail
|
||||
of the list.
|
||||
*/
|
||||
if (&select_lex == all_selects_list && !sroutines.records)
|
||||
{
|
||||
DBUG_ASSERT(!all_selects_list->next_select_in_list());
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
} LEX;
|
||||
|
||||
struct st_lex_local: public st_lex
|
||||
|
|
|
@ -1864,7 +1864,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||
statistic_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS],
|
||||
&LOCK_status);
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
if (thd->copy_db_to(&table_list.db, 0))
|
||||
if (thd->copy_db_to(&table_list.db, &table_list.db_length))
|
||||
break;
|
||||
pend= strend(packet);
|
||||
thd->convert_string(&conv_name, system_charset_info,
|
||||
|
@ -3990,6 +3990,8 @@ end_with_restore_list:
|
|||
}
|
||||
case SQLCOM_SHOW_CREATE_DB:
|
||||
{
|
||||
DBUG_EXECUTE_IF("4x_server_emul",
|
||||
my_error(ER_UNKNOWN_ERROR, MYF(0)); goto error;);
|
||||
if (!strip_sp(lex->name) || check_db_name(lex->name))
|
||||
{
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), lex->name);
|
||||
|
|
|
@ -189,6 +189,7 @@ static bool setup_new_fields(THD *thd, List<Item> &fields,
|
|||
List<Item> &all_fields, ORDER *new_order);
|
||||
static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array,
|
||||
ORDER *order, List<Item> &fields,
|
||||
List<Item> &all_fields,
|
||||
bool *all_order_by_fields_used);
|
||||
static bool test_if_subpart(ORDER *a,ORDER *b);
|
||||
static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables);
|
||||
|
@ -537,6 +538,28 @@ JOIN::prepare(Item ***rref_pointer_array,
|
|||
fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
if (group_list)
|
||||
{
|
||||
/*
|
||||
Because HEAP tables can't index BIT fields we need to use an
|
||||
additional hidden field for grouping because later it will be
|
||||
converted to a LONG field. Original field will remain of the
|
||||
BIT type and will be returned to a client.
|
||||
*/
|
||||
for (ORDER *ord= group_list; ord; ord= ord->next)
|
||||
{
|
||||
if ((*ord->item)->type() == Item::FIELD_ITEM &&
|
||||
(*ord->item)->field_type() == MYSQL_TYPE_BIT)
|
||||
{
|
||||
Item_field *field= new Item_field(thd, *(Item_field**)ord->item);
|
||||
int el= all_fields.elements;
|
||||
ref_pointer_array[el]= field;
|
||||
all_fields.push_front(field);
|
||||
ord->item= ref_pointer_array + el;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
|
@ -1030,6 +1053,14 @@ JOIN::optimize()
|
|||
find_field_in_order_list,
|
||||
(void *) group_list))
|
||||
{
|
||||
/*
|
||||
We have found that grouping can be removed since groups correspond to
|
||||
only one row anyway, but we still have to guarantee correct result
|
||||
order. The line below effectively rewrites the query from GROUP BY
|
||||
<fields> to ORDER BY <fields>. One exception is if skip_sort_order is
|
||||
set (see above), then we can simply skip GROUP BY.
|
||||
*/
|
||||
order= skip_sort_order ? 0 : group_list;
|
||||
group_list= 0;
|
||||
group= 0;
|
||||
}
|
||||
|
@ -1068,12 +1099,13 @@ JOIN::optimize()
|
|||
if (order)
|
||||
skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1);
|
||||
if ((group_list=create_distinct_group(thd, select_lex->ref_pointer_array,
|
||||
order, fields_list,
|
||||
order, fields_list, all_fields,
|
||||
&all_order_fields_used)))
|
||||
{
|
||||
bool skip_group= (skip_sort_order &&
|
||||
test_if_skip_sort_order(tab, group_list, select_limit,
|
||||
1) != 0);
|
||||
count_field_types(select_lex, &tmp_table_param, all_fields, 0);
|
||||
if ((skip_group && all_order_fields_used) ||
|
||||
select_limit == HA_POS_ERROR ||
|
||||
(order && !skip_sort_order))
|
||||
|
@ -4369,9 +4401,13 @@ choose_plan(JOIN *join, table_map join_tables)
|
|||
|
||||
/*
|
||||
Store the cost of this query into a user variable
|
||||
Don't update last_query_cost for 'show status' command
|
||||
Don't update last_query_cost for 'show status' command.
|
||||
Don't update last_query_cost for statements that are not "flat joins" :
|
||||
i.e. they have subqueries, unions or call stored procedures.
|
||||
TODO: calculate a correct cost for a query with subqueries and UNIONs.
|
||||
*/
|
||||
if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS)
|
||||
if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS &&
|
||||
join->thd->lex->is_single_level_stmt())
|
||||
join->thd->status_var.last_query_cost= join->best_read;
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
@ -13629,11 +13665,12 @@ setup_new_fields(THD *thd, List<Item> &fields,
|
|||
|
||||
static ORDER *
|
||||
create_distinct_group(THD *thd, Item **ref_pointer_array,
|
||||
ORDER *order_list, List<Item> &fields,
|
||||
ORDER *order_list, List<Item> &fields,
|
||||
List<Item> &all_fields,
|
||||
bool *all_order_by_fields_used)
|
||||
{
|
||||
List_iterator<Item> li(fields);
|
||||
Item *item;
|
||||
Item *item, **orig_ref_pointer_array= ref_pointer_array;
|
||||
ORDER *order,*group,**prev;
|
||||
|
||||
*all_order_by_fields_used= 1;
|
||||
|
@ -13673,12 +13710,31 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
|
|||
ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
|
||||
if (!ord)
|
||||
return 0;
|
||||
/*
|
||||
We have here only field_list (not all_field_list), so we can use
|
||||
simple indexing of ref_pointer_array (order in the array and in the
|
||||
list are same)
|
||||
*/
|
||||
ord->item= ref_pointer_array;
|
||||
|
||||
if (item->type() == Item::FIELD_ITEM &&
|
||||
item->field_type() == MYSQL_TYPE_BIT)
|
||||
{
|
||||
/*
|
||||
Because HEAP tables can't index BIT fields we need to use an
|
||||
additional hidden field for grouping because later it will be
|
||||
converted to a LONG field. Original field will remain of the
|
||||
BIT type and will be returned to a client.
|
||||
*/
|
||||
Item_field *new_item= new Item_field(thd, (Item_field*)item);
|
||||
int el= all_fields.elements;
|
||||
orig_ref_pointer_array[el]= new_item;
|
||||
all_fields.push_front(new_item);
|
||||
ord->item= orig_ref_pointer_array + el;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
We have here only field_list (not all_field_list), so we can use
|
||||
simple indexing of ref_pointer_array (order in the array and in the
|
||||
list are same)
|
||||
*/
|
||||
ord->item= ref_pointer_array;
|
||||
}
|
||||
ord->asc=1;
|
||||
*prev=ord;
|
||||
prev= &ord->next;
|
||||
|
|
|
@ -1008,8 +1008,19 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
|
|||
table->view= lex= thd->lex= (LEX*) new(thd->mem_root) st_lex_local;
|
||||
|
||||
{
|
||||
char old_db_buf[NAME_LEN+1];
|
||||
LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) };
|
||||
bool dbchanged;
|
||||
Lex_input_stream lip(thd, table->query.str, table->query.length);
|
||||
thd->m_lip= &lip;
|
||||
|
||||
/*
|
||||
Use view db name as thread default database, in order to ensure
|
||||
that the view is parsed and prepared correctly.
|
||||
*/
|
||||
if ((result= sp_use_new_db(thd, table->view_db, &old_db, 1, &dbchanged)))
|
||||
goto end;
|
||||
|
||||
lex_start(thd);
|
||||
view_select= &lex->select_lex;
|
||||
view_select->select_number= ++thd->select_number;
|
||||
|
@ -1051,6 +1062,9 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
|
|||
|
||||
thd->variables.character_set_client= save_cs;
|
||||
thd->variables.sql_mode= save_mode;
|
||||
|
||||
if (dbchanged && mysql_change_db(thd, &old_db, TRUE))
|
||||
goto err;
|
||||
}
|
||||
if (!res && !thd->is_fatal_error)
|
||||
{
|
||||
|
|
|
@ -1162,7 +1162,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||
field_opt_list opt_binary table_lock_list table_lock
|
||||
ref_list opt_on_delete opt_on_delete_list opt_on_delete_item use
|
||||
opt_delete_options opt_delete_option varchar nchar nvarchar
|
||||
opt_outer table_list table_name opt_option opt_place
|
||||
opt_outer table_list table_name table_alias_ref_list table_alias_ref
|
||||
opt_option opt_place
|
||||
opt_attribute opt_attribute_list attribute column_list column_list_id
|
||||
opt_column_list grant_privileges grant_ident grant_list grant_option
|
||||
object_privilege object_privilege_list user_list rename_list
|
||||
|
@ -6553,6 +6554,20 @@ table_name:
|
|||
}
|
||||
;
|
||||
|
||||
table_alias_ref_list:
|
||||
table_alias_ref
|
||||
| table_alias_ref_list ',' table_alias_ref;
|
||||
|
||||
table_alias_ref:
|
||||
table_ident
|
||||
{
|
||||
if (!Select->add_table_to_list(YYTHD, $1, NULL,
|
||||
TL_OPTION_UPDATING | TL_OPTION_ALIAS,
|
||||
Lex->lock_option ))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
;
|
||||
|
||||
if_exists:
|
||||
/* empty */ { $$= 0; }
|
||||
| IF EXISTS { $$= 1; }
|
||||
|
@ -6823,7 +6838,7 @@ single_multi:
|
|||
if (multi_delete_set_locks_and_link_aux_tables(Lex))
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
| FROM table_wild_list
|
||||
| FROM table_alias_ref_list
|
||||
{ mysql_init_multi_delete(Lex); }
|
||||
USING join_table_list where_clause
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue