Merge branch '5.5' into 10.1

This commit is contained in:
Oleksandr Byelkin 2019-07-25 13:27:11 +02:00
commit ae476868a5
63 changed files with 3192 additions and 114 deletions

View File

@ -1,3 +1,4 @@
--source include/have_innodb.inc
--disable_warnings
DROP DATABASE IF EXISTS `drop-temp+table-test`;
@ -104,3 +105,72 @@ RESET MASTER;
DROP TABLE t1;
# End of 4.1 tests
--echo #
--echo # BUG#28642318: POINT IN TIME RECOVERY USING MYSQLBINLOG BROKEN
--echo # WITH TEMPORARY TABLE -> ERRORS
--echo # Test case for DELETE query.
RESET MASTER;
connect (con1,localhost,root,,);
--echo # Set up.
--connection default
--disable_warnings
SET @save_binlog_format= @@session.binlog_format;
SET @@session.binlog_format=STATEMENT;
let $MYSQLD_DATADIR= `select @@datadir`;
CREATE TABLE t1 (a INT) ENGINE=INNODB;
--connection con1
SET @@session.binlog_format=STATEMENT;
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
--connection default
DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a;
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
--connection default
DROP TABLE t1;
--echo # DELETE query fails with table re-open error without patch.
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql
--echo # Clean up.
--connection con1
DROP TABLE IF EXISTS t1;
--connection default
DROP TABLE IF EXISTS t1;
RESET MASTER;
--echo # Test case for DROP query.
--connection default
CREATE TABLE t1 (a INT) ENGINE=INNODB;
--connection con1
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
--connection default
DROP TABLE t1;
--connection con1
DROP TABLE t1;
--connection default
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
--echo # DROP table query fails with unknown table error without patch.
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql
--echo # Clean up
--connection default
SET @@session.binlog_format= @save_binlog_format;
RESET MASTER;
--disconnect con1
--enable_warnings

View File

@ -3,3 +3,8 @@ set global debug_dbug='+d,auth_disconnect';
create user 'bad' identified by 'worse';
set global debug_dbug=@old_dbug;
drop user bad;
set global debug_dbug='+d,auth_invalid_plugin';
create user 'bad' identified by 'worse';
ERROR 2059 (HY000): Authentication plugin 'foo/bar' cannot be loaded: invalid plugin name
set global debug_dbug=@old_dbug;
drop user bad;

View File

@ -601,6 +601,17 @@ select x.id, message from (select id from t1) x left join
(select id, 1 as message from t2) y on x.id=y.id
where coalesce(message,0) <> 0;
id message
explain extended
select x.id, message from (select id from t1) x left join
(select id, 1 as message from t2) y on x.id=y.id
where message <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00
2 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `x`.`id` AS `id`,`y`.`message` AS `message` from (select `test`.`t1`.`id` AS `id` from `test`.`t1`) `x` join (select `test`.`t2`.`id` AS `id`,1 AS `message` from `test`.`t2`) `y` where ((`y`.`id` = `x`.`id`) and (`y`.`message` <> 0))
drop table t1,t2;
#
# MDEV-7827: Assertion `!table || (!table->read_set ||

View File

@ -1298,7 +1298,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 't.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(1,<expr_cache><`test`.`t1`.`a`>(exists(select 28 from `test`.`t3` where ('j' < `test`.`t1`.`a`))))
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(1,<expr_cache><`test`.`t1`.`a`>(exists(select 28 from `test`.`t3` where ('j' < `test`.`t1`.`a`) limit 1)))
SELECT * FROM (SELECT * FROM t1) AS t
WHERE EXISTS (SELECT t2.a FROM t3 RIGHT JOIN t2 ON (t3.a = t2.a)
WHERE t2.b < t.a);
@ -3052,3 +3052,60 @@ id select_type table type possible_keys key key_len ref rows Extra
7 DERIVED p9 ALL NULL NULL NULL NULL 550 Using where; Using join buffer (incremental, BNL join)
7 DERIVED p10 ALL NULL NULL NULL NULL 550 Using where; Using join buffer (incremental, BNL join)
DROP TABLE t1, t2;
#
# MDEV-19778: equality condition for mergeable view returning constants
# in its columns and used as inner table of outer join
#
create table t1 (pk int, a int);
insert into t1 values (1,7), (2,3), (3,2), (4,3);
create table t2 (b int);
insert into t2 values (5), (1), (NULL), (3);
create table t3 (c int);
insert into t3 values (1), (8);
create view v1 as
select 3 as d, t2.b from t2;
select * from t1 left join v1 on t1.pk <= 2 where t1.a=v1.d;
pk a d b
2 3 3 5
2 3 3 1
2 3 3 NULL
2 3 3 3
explain extended select * from t1 left join v1 on t1.pk <= 2 where t1.a=v1.d;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 3) and (`test`.`t1`.`pk` <= 2))
select * from t1 left join (select 3 as d, t2.b from t2) dt on t1.pk <= 2
where t1.a=dt.d;
pk a d b
2 3 3 5
2 3 3 1
2 3 3 NULL
2 3 3 3
explain extended select * from t1 left join (select 3 as d, t2.b from t2) dt on t1.pk <= 2
where t1.a=dt.d;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 3) and (`test`.`t1`.`pk` <= 2))
select * from t1 left join (v1,t3) on t1.pk <= 2 where t1.a=v1.d;
pk a d b c
2 3 3 5 1
2 3 3 5 8
2 3 3 1 1
2 3 3 1 8
2 3 3 NULL 1
2 3 3 NULL 8
2 3 3 3 1
2 3 3 3 8
explain extended select * from t1 left join (v1,t3) on t1.pk <= 2 where t1.a=v1.d;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t1`.`a` = 3) and (`test`.`t1`.`pk` <= 2))
drop view v1;
drop table t1,t2,t3;

View File

@ -1981,6 +1981,7 @@ NULL
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'j'
Warning 1292 Truncated incorrect DOUBLE value: 'j'
Warning 1292 Truncated incorrect DOUBLE value: 'j'
EXPLAIN
SELECT MIN(t2.pk)
@ -1995,6 +1996,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'j'
Warning 1292 Truncated incorrect DOUBLE value: 'j'
Warning 1292 Truncated incorrect DOUBLE value: 'j'
#
# 2) Test that subquery materialization is setup for query with

View File

@ -392,7 +392,7 @@ SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE P
DROP DATABASE IF EXISTS i_s_parameters_test;
CREATE DATABASE i_s_parameters_test;
USE i_s_parameters_test;
CREATE PROCEDURE testproc (OUT param1 INT)
CREATE PROCEDURE testproc (IN param1 INT)
BEGIN
SELECT 2+2 as param1;
END;
@ -400,7 +400,7 @@ END;
SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'testproc';
SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE
def i_s_parameters_test testproc 1 OUT param1 int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE
def i_s_parameters_test testproc 1 IN param1 int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE
# ========== parameters.5 ==========
DROP DATABASE IF EXISTS i_s_parameters_test;
CREATE DATABASE i_s_parameters_test;

File diff suppressed because it is too large Load Diff

View File

@ -486,7 +486,7 @@ Note 1051 Unknown table 'test.t2'
Note 1051 Unknown table 'test.t3'
create table t2(a int,unique key (a)) engine=innodb;
create table t3(b int) engine=innodb;
create table t1(a int,b int)engine=innodb;
create table t1(c int,b int)engine=innodb;
set @mdev4270_opl= @@optimizer_prune_level;
set @mdev4270_osd= @@optimizer_search_depth;
set optimizer_prune_level=0;

View File

@ -318,6 +318,16 @@ UNUSABLE
uninstall soname 'ha_example';
select plugin_name from information_schema.plugins where plugin_library like 'ha_example%';
plugin_name
set names utf8;
select convert('admin𝌆' using utf8);
convert('admin𝌆' using utf8)
admin????
Warnings:
Warning 1300 Invalid utf8 character string: '\xF0\x9D\x8C\x86'
install plugin foo soname 'admin𝌆';
ERROR HY000: No paths allowed for shared library
insert mysql.plugin values ();
delete from mysql.plugin where name = '';
#
# MDEV-5309 - RENAME TABLE does not check for existence of the table's
# engine

View File

@ -4356,6 +4356,69 @@ LINE1 1
LINE2 2
LINE3 3
drop table t1;
#
# MDEV-17042: prepared statement does not return error with
# SQL_MODE STRICT_TRANS_TABLES. (Part 1)
#
set @save_sql_mode=@@sql_mode;
set sql_mode='STRICT_ALL_TABLES';
CREATE TABLE t1 (id int, count int);
insert into t1 values (1,1),(0,2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id decimal(10,5), count int);
insert into t1 values (1,1),(0,2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id double, count int);
insert into t1 values (1,1),(0,2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id date, count int);
insert into t1 values ("2019-06-11",1),("2019-06-12",2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Incorrect datetime value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Incorrect datetime value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Incorrect datetime value: '1bad'
deallocate prepare stmt;
drop table t1;
set sql_mode=@save_sql_mode;
# End of 5.5 tests
#
# Start of 10.1 tests

View File

@ -0,0 +1,64 @@
#
# MDEV-17042: prepared statement does not return error with
# SQL_MODE STRICT_TRANS_TABLES. (Part 2)
#
set @save_sql_mode=@@sql_mode;
set sql_mode='STRICT_TRANS_TABLES';
CREATE TABLE t1 (id int, count int) engine=innodb;
insert into t1 values (1,1),(0,2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id decimal(10,5), count int) engine=innodb;
insert into t1 values (1,1),(0,2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id double, count int) engine=innodb;
insert into t1 values (1,1),(0,2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id date, count int) engine=innodb;
insert into t1 values ("2019-06-11",1),("2019-06-12",2);
update t1 set count = count + 1 where id = '1bad';
ERROR 22007: Incorrect datetime value: '1bad'
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
execute stmt;
ERROR 22007: Incorrect datetime value: '1bad'
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
execute stmt using @a;
ERROR 22007: Incorrect datetime value: '1bad'
deallocate prepare stmt;
drop table t1;
set sql_mode=@save_sql_mode;
# End of 5.5 tests

View File

@ -400,7 +400,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 100.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`) limit 1))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@ -441,7 +441,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 91.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`) limit 1))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@ -985,7 +985,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00
2 SUBQUERY t1 ALL NULL NULL NULL NULL 14 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((<cache>(<in_optimizer>(1,exists(select 1 from `test`.`t1` join `test`.`t2`))) and (`test`.`t1`.`a` <> `test`.`t2`.`b`)) or (`test`.`t1`.`a` <= 4))
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((<cache>(<in_optimizer>(1,exists(select 1 from `test`.`t1` join `test`.`t2` limit 1))) and (`test`.`t1`.`a` <> `test`.`t2`.`b`)) or (`test`.`t1`.`a` <= 4))
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;

View File

@ -403,7 +403,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 100.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`) limit 1))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@ -444,7 +444,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 91.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`)))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
Note 1003 select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where ((substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and (`dbt3_s001`.`customer`.`c_acctbal` > (select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where ((`dbt3_s001`.`customer`.`c_acctbal` > 0.00) and (substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25'))))) and (not(<in_optimizer>(1,exists(select 1 from `dbt3_s001`.`orders` where (`dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`) limit 1))))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@ -995,7 +995,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00
2 SUBQUERY t1 ALL NULL NULL NULL NULL 14 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((<cache>(<in_optimizer>(1,exists(select 1 from `test`.`t1` join `test`.`t2`))) and (`test`.`t1`.`a` <> `test`.`t2`.`b`)) or (`test`.`t1`.`a` <= 4))
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((<cache>(<in_optimizer>(1,exists(select 1 from `test`.`t1` join `test`.`t2` limit 1))) and (`test`.`t1`.`a` <> `test`.`t2`.`b`)) or (`test`.`t1`.`a` <= 4))
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;

View File

@ -1893,7 +1893,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))))
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null) limit 1)))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@ -4452,7 +4452,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))))
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -7251,6 +7251,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
#
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
a
explain select * from t10 where exists (select * from t12 order by a limit 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
a
1
2
3
set @l=2;
execute stmt1 using @l;
a
1
2
3
set @l=0;
execute stmt1 using @l;
a
deallocate prepare stmt1;
drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -3385,6 +3385,7 @@ WHERE table1 .`col_varchar_key` ) field10
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
SET @@optimizer_switch = 'subquery_cache=on';
/* cache is on */ SELECT COUNT( DISTINCT table2 .`col_int_key` ) , (
SELECT SUBQUERY2_t1 .`col_int_key`
@ -3401,6 +3402,7 @@ WHERE table1 .`col_varchar_key` ) field10
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
drop table t1,t2,t3,t4;
set @@optimizer_switch= default;
#launchpad BUG#611625

View File

@ -94,7 +94,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t3 ALL bb NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`b` = `test`.`t1`.`a`))
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t3`.`a` from `test`.`t3` where (`test`.`t3`.`b` = `test`.`t1`.`a`) limit 1)
set optimizer_switch=default;
set optimizer_switch='exists_to_in=on';
drop table t1,t2,t3;
@ -358,7 +358,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2
Note 1003 select (select 1 from dual where (not(exists(select `test`.`t3`.`c` from `test`.`t3` where (`test`.`t3`.`c` = 1))))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
Note 1003 select (select 1 from dual where (not(exists(select `test`.`t3`.`c` from `test`.`t3` where (`test`.`t3`.`c` = 1) limit 1)))) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1;
( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1
@ -429,7 +429,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a1' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a1` AS `a1` from `test`.`t1` where exists(select 1 from `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`b1` = `test`.`t1`.`a1`)))
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a1` AS `a1` from `test`.`t1` where exists(select 1 from `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`a`) and (`test`.`t3`.`b1` = `test`.`t1`.`a1`)) limit 1)
set optimizer_switch=default;
set optimizer_switch='exists_to_in=on';
drop table t1,t3;
@ -905,7 +905,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'sq1.pk' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'sq1.f1' of SELECT #3 was resolved in SELECT #1
Note 1003 select straight_join `test`.`t1`.`f2` AS `f2` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`,`test`.`t1`.`pk`>(exists(select 1 from `test`.`t1` `sq2` semi join (`test`.`t1`) where ((`test`.`sq2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t1`.`pk` = `test`.`t1`.`f1`))))
Note 1003 select straight_join `test`.`t1`.`f2` AS `f2` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`,`test`.`t1`.`pk`>(exists(select 1 from `test`.`t1` `sq2` semi join (`test`.`t1`) where ((`test`.`sq2`.`f1` = `test`.`t1`.`f1`) and (`test`.`t1`.`pk` = `test`.`t1`.`f1`)) limit 1))
SELECT STRAIGHT_JOIN sq1.f2
FROM ( SELECT * FROM t1 ) AS sq1
WHERE EXISTS ( SELECT * FROM t1 AS sq2

View File

@ -2251,7 +2251,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00
Warnings:
Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`f1` = `test`.`t3`.`f3`))))
Note 1003 select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`f1` = `test`.`t3`.`f3`)) limit 1))
# this checks the result set above
set optimizer_switch= 'materialization=off,semijoin=off';
SELECT * FROM t1

View File

@ -349,7 +349,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index
Warnings:
Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)))
Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`) limit 1))
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
ERROR 23000: Column 'a' in field list is ambiguous
drop table t1,t2,t3;
@ -1897,7 +1897,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))))
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null) limit 1))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@ -2433,7 +2433,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)))
Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`) limit 1))
drop table t1;
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
@ -4442,7 +4442,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) limit 1))
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
@ -4454,7 +4454,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))))
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -7251,6 +7251,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
#
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
a
explain select * from t10 where exists (select * from t12 order by a limit 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
a
1
2
3
set @l=2;
execute stmt1 using @l;
a
1
2
3
set @l=0;
execute stmt1 using @l;
a
deallocate prepare stmt1;
drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -1900,7 +1900,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))))
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null) limit 1)))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@ -4454,7 +4454,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))))
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -7244,6 +7244,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
#
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
a
explain select * from t10 where exists (select * from t12 order by a limit 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
a
1
2
3
set @l=2;
execute stmt1 using @l;
a
1
2
3
set @l=0;
execute stmt1 using @l;
a
deallocate prepare stmt1;
drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -1896,7 +1896,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))))
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null) limit 1))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@ -4450,7 +4450,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))
Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) limit 1)
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -7242,6 +7242,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
#
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
a
explain select * from t10 where exists (select * from t12 order by a limit 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
a
1
2
3
set @l=2;
execute stmt1 using @l;
a
1
2
3
set @l=0;
execute stmt1 using @l;
a
deallocate prepare stmt1;
drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -1899,7 +1899,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))))
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null) limit 1))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@ -4458,7 +4458,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))
Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) limit 1)
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -7257,6 +7257,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
#
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
a
explain select * from t10 where exists (select * from t12 order by a limit 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
a
1
2
3
set @l=2;
execute stmt1 using @l;
a
1
2
3
set @l=0;
execute stmt1 using @l;
a
deallocate prepare stmt1;
drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -1896,7 +1896,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))))
Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null) limit 1)))))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@ -4450,7 +4450,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))))
Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@ -7242,6 +7242,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
#
# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
#
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
a
explain select * from t10 where exists (select * from t12 order by a limit 0);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
a
1
2
3
set @l=2;
execute stmt1 using @l;
a
1
2
3
set @l=0;
execute stmt1 using @l;
a
deallocate prepare stmt1;
drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#

View File

@ -2291,7 +2291,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00
Warnings:
Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`f1` = `test`.`t3`.`f3`))))
Note 1003 select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`f1` = `test`.`t3`.`f3`)) limit 1))
# this checks the result set above
set optimizer_switch= 'materialization=off,semijoin=off';
SELECT * FROM t1

View File

@ -5765,6 +5765,21 @@ t37, t38, t39, t40, t41, t42, t43, t44, t45,
t46, t47, t48, t49, t50, t51, t52, t53, t54,
t55, t56, t57, t58, t59,t60;
drop view v60;
#
# MDEV-15572: view.test, server crash with --big-tables=1
#
set @save_big_tables=@@big_tables;
set big_tables=ON;
CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int);
CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int);
CREATE VIEW v1 AS
SELECT t2.f1, t1.f2, t2.f3, t2.f4 FROM (t1 JOIN t2);
REPLACE INTO v1 (f1, f2, f3, f4)
SELECT f1, f2, f3, f4 FROM t1;
ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
drop view v1;
drop table t1, t2;
set big_tables=@save_big_tables;
# -----------------------------------------------------------------
# -- End of 5.5 tests.
# -----------------------------------------------------------------

View File

@ -90,23 +90,23 @@ CREATE TABLE t2 LIKE t1;
# Test alias in subquery
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT 1 FROM t2 AS b WHERE b.a = 0);
DROP VIEW v1;
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select 1 from `test`.`t2` `b` where (`b`.`a` = 0));
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select 1 from `test`.`t2` `b` where (`b`.`a` = 0) limit 1);
DROP VIEW v1;
# Test column alias in subquery
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT a AS alias FROM t1 GROUP BY alias);
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select `t1`.`a` AS `alias` from `t1` group by `t1`.`a`) latin1 latin1_swedish_ci
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select `t1`.`a` AS `alias` from `t1` group by `t1`.`a` limit 1) latin1 latin1_swedish_ci
DROP VIEW v1;
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t1`.`a` AS `alias` from `test`.`t1` group by `test`.`t1`.`a`);
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t1`.`a` AS `alias` from `test`.`t1` group by `test`.`t1`.`a` limit 1);
DROP VIEW v1;
# Alias as the expression column name.
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT ' a ' AS alias FROM t1 GROUP BY alias);
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select ' a ' AS `alias` from `t1` group by ' a ') latin1 latin1_swedish_ci
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select ' a ' AS `alias` from `t1` group by ' a ' limit 1) latin1 latin1_swedish_ci
DROP VIEW v1;
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select ' a ' AS `alias` from `test`.`t1` group by ' a ');
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select ' a ' AS `alias` from `test`.`t1` group by ' a ' limit 1);
DROP VIEW v1;
DROP TABLE t1, t2;
create view v1 as select interval(55,10) as my_col;

View File

@ -52,3 +52,30 @@ master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
RESET MASTER;
DROP TABLE t1;
#
# BUG#28642318: POINT IN TIME RECOVERY USING MYSQLBINLOG BROKEN
# WITH TEMPORARY TABLE -> ERRORS
# Test case for DELETE query.
RESET MASTER;
# Set up.
SET @save_binlog_format= @@session.binlog_format;
SET @@session.binlog_format=STATEMENT;
CREATE TABLE t1 (a INT) ENGINE=INNODB;
SET @@session.binlog_format=STATEMENT;
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a;
DROP TABLE t1;
# DELETE query fails with table re-open error without patch.
# Clean up.
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1;
RESET MASTER;
# Test case for DROP query.
CREATE TABLE t1 (a INT) ENGINE=INNODB;
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
DROP TABLE t1;
DROP TABLE t1;
# DROP table query fails with unknown table error without patch.
# Clean up
SET @@session.binlog_format= @save_binlog_format;
RESET MASTER;

View File

@ -80,3 +80,30 @@ master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `ttmp1`
RESET MASTER;
DROP TABLE t1;
#
# BUG#28642318: POINT IN TIME RECOVERY USING MYSQLBINLOG BROKEN
# WITH TEMPORARY TABLE -> ERRORS
# Test case for DELETE query.
RESET MASTER;
# Set up.
SET @save_binlog_format= @@session.binlog_format;
SET @@session.binlog_format=STATEMENT;
CREATE TABLE t1 (a INT) ENGINE=INNODB;
SET @@session.binlog_format=STATEMENT;
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a;
DROP TABLE t1;
# DELETE query fails with table re-open error without patch.
# Clean up.
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t1;
RESET MASTER;
# Test case for DROP query.
CREATE TABLE t1 (a INT) ENGINE=INNODB;
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
DROP TABLE t1;
DROP TABLE t1;
# DROP table query fails with unknown table error without patch.
# Clean up
SET @@session.binlog_format= @save_binlog_format;
RESET MASTER;

View File

@ -621,6 +621,130 @@ c1 c2
3 3
4 4
DROP TABLE t1;
#
# Bug#15851528 DUPLICATE KEY ERROR ON AUTO-INC PK WITH MIXED AUTO_INCREMENT_INCREMENT CLIENTS
#
# This test shows that the next record to be inserted is not affected
# by a change in auto_increment_increment.
# In addition, current value of auto_increment_increment by the client
# that uses the existing autoinc value with be used to set next autoinc
# value, which will be used by next client reguardless of its own session
# setting for auto_increment_increment.
#
# Client 1: Insert a record with auto_increment_increment=2
CREATE TABLE t(
a SERIAL PRIMARY KEY,
b VARCHAR(200)) ENGINE=InnoDB;
SET SESSION auto_increment_increment=2;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S1');
SELECT a,b FROM t;
a b
1 S1
# Client 2: Insert records with auto_increment_increment 2,1
SET SESSION auto_increment_increment=2;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S2');
SELECT a,b FROM t;
a b
1 S1
3 S2
SET SESSION auto_increment_increment=1;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S2');
SELECT a,b FROM t;
a b
1 S1
3 S2
4 S2
# Client 1: Insert a record with auto_increment_increment=1
SET SESSION auto_increment_increment=1;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S1');
SELECT a,b FROM t;
a b
1 S1
3 S2
4 S2
5 S1
DROP TABLE t;
# Autoincrement behaviour with mixed insert.
CREATE TABLE t(
a TINYINT AUTO_INCREMENT PRIMARY KEY,
b VARCHAR(200)) ENGINE=InnoDB;
SET SESSION auto_increment_increment=10;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S0'),('S1');
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1
INSERT INTO t(a,b) VALUES(28,'S2');
SET SESSION auto_increment_increment=1;
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S3');
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1
INSERT INTO t(b) VALUES('S4');
SELECT * FROM t;
a b
1 S0
11 S1
22 S3
23 S4
28 S2
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` tinyint(4) NOT NULL AUTO_INCREMENT,
`b` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
DROP TABLE t;
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
DROP TABLE IF EXISTS t1;
Warnings:

View File

@ -381,6 +381,66 @@ INSERT INTO t1 VALUES(NULL, 4);
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Bug#15851528 DUPLICATE KEY ERROR ON AUTO-INC PK WITH MIXED AUTO_INCREMENT_INCREMENT CLIENTS
--echo #
--echo # This test shows that the next record to be inserted is not affected
--echo # by a change in auto_increment_increment.
--echo # In addition, current value of auto_increment_increment by the client
--echo # that uses the existing autoinc value with be used to set next autoinc
--echo # value, which will be used by next client reguardless of its own session
--echo # setting for auto_increment_increment.
--echo #
--connection default
--echo # Client 1: Insert a record with auto_increment_increment=2
CREATE TABLE t(
a SERIAL PRIMARY KEY,
b VARCHAR(200)) ENGINE=InnoDB;
SET SESSION auto_increment_increment=2;
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S1');
SELECT a,b FROM t;
--connect(con1,localhost,root,,)
--connection con1
--echo # Client 2: Insert records with auto_increment_increment 2,1
SET SESSION auto_increment_increment=2;
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S2');
SELECT a,b FROM t;
SET SESSION auto_increment_increment=1;
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S2');
SELECT a,b FROM t;
disconnect con1;
--connection default
--echo # Client 1: Insert a record with auto_increment_increment=1
SET SESSION auto_increment_increment=1;
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S1');
SELECT a,b FROM t;
DROP TABLE t;
--echo # Autoincrement behaviour with mixed insert.
CREATE TABLE t(
a TINYINT AUTO_INCREMENT PRIMARY KEY,
b VARCHAR(200)) ENGINE=InnoDB;
SET SESSION auto_increment_increment=10;
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S0'),('S1');
SHOW CREATE TABLE t;
INSERT INTO t(a,b) VALUES(28,'S2');
SET SESSION auto_increment_increment=1;
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S3');
SHOW CREATE TABLE t;
INSERT INTO t(b) VALUES('S4');
SELECT * FROM t;
SHOW CREATE TABLE t;
DROP TABLE t;
#
# Bug# 42714: AUTOINC column calculated next value not greater than highest
# value stored in table.

View File

@ -1,3 +1,4 @@
source include/not_embedded.inc;
source include/have_debug.inc;
set @old_dbug=@@global.debug_dbug;
@ -10,3 +11,13 @@ create user 'bad' identified by 'worse';
--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse
set global debug_dbug=@old_dbug;
drop user bad;
#
# malicious server, invalid plugin name
#
set global debug_dbug='+d,auth_invalid_plugin';
create user 'bad' identified by 'worse';
--error 1
--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse 2>&1
set global debug_dbug=@old_dbug;
drop user bad;

View File

@ -533,6 +533,10 @@ insert into t2 values(4),(5),(6);
select x.id, message from (select id from t1) x left join
(select id, 1 as message from t2) y on x.id=y.id
where coalesce(message,0) <> 0;
explain extended
select x.id, message from (select id from t1) x left join
(select id, 1 as message from t2) y on x.id=y.id
where message <> 0;
drop table t1,t2;
--echo #

View File

@ -2194,3 +2194,37 @@ JOIN
) gp_20 ON gp_20.id=t2.id ;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-19778: equality condition for mergeable view returning constants
--echo # in its columns and used as inner table of outer join
--echo #
create table t1 (pk int, a int);
insert into t1 values (1,7), (2,3), (3,2), (4,3);
create table t2 (b int);
insert into t2 values (5), (1), (NULL), (3);
create table t3 (c int);
insert into t3 values (1), (8);
create view v1 as
select 3 as d, t2.b from t2;
let $q=
select * from t1 left join v1 on t1.pk <= 2 where t1.a=v1.d;
eval $q;
eval explain extended $q;
let $q=
select * from t1 left join (select 3 as d, t2.b from t2) dt on t1.pk <= 2
where t1.a=dt.d;
eval $q;
eval explain extended $q;
let $q=
select * from t1 left join (v1,t3) on t1.pk <= 2 where t1.a=v1.d;
eval $q;
eval explain extended $q;
drop view v1;
drop table t1,t2,t3;

View File

@ -92,7 +92,7 @@ CREATE DATABASE i_s_parameters_test;
USE i_s_parameters_test;
delimiter //;
CREATE PROCEDURE testproc (OUT param1 INT)
CREATE PROCEDURE testproc (IN param1 INT)
BEGIN
SELECT 2+2 as param1;
END;

View File

@ -1209,6 +1209,410 @@ CALL p1;
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
--echo #
--echo # MDEV-19421: Embedding inner joins
--echo #
create table t1 (a int);
insert into t1 values (7), (5), (3);
create table s1 (b int);
insert into s1 values (7), (5), (3);
create table t2 (a int);
insert into t2 values (5), (1), (7);
create table s2 (b int);
insert into s2 values (5), (1), (7);
create table t3 (a int);
insert into t3 values (2), (7), (3);
create table t4 (a int);
insert into t4 values (4), (7), (9), (5);
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 right join t3 on t2.a=t3.a on t1.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 join t3 using(a) using(a);
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 left join t3 using(a) using(a);
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 right join t3 using(a) using(a);
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 join t3 on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 left join t3 on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 right join t3 on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 join t3 on t1.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 left join t3 on t1.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 right join t3 on t1.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join (t2 join t3 on t2.a=t3.a);
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join (t2 left join t3 on t2.a=t3.a);
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join (t2 right join t3 on t2.a=t3.a);
eval explain extended $q;
eval $q;
let $q=
select *
from s1 join t2 join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select *
from s1 join t2 left join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select *
from s1 join t2 right join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select s1.b, t2.a as t2_a, t3.a as t3_a
from s1 join t2 join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select s1.b, t2.a as t2_a, t3.a as t3_a
from s1 join t2 left join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select s1.b, t2.a as t2_a, t3.a as t3_a
from s1 join t2 right join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select s1.b, t2.a as t2_a, t3.a as t3_a
from (s1 join t2) right join t3 using(a);
eval explain extended $q;
eval $q;
let $q=
select *
from s1 join t2 natural join t3;
eval explain extended $q;
eval $q;
let $q=
select *
from s1 join t2 natural left join t3;
eval explain extended $q;
eval $q;
let $q=
select *
from s1 join t2 natural right join t3;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 join t3;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from t1 join t2 join t3
where t1.a=t2.a and t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 left join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 left join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 right join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 right join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 join t3 join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 join t3 left join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 join t3 right join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
from s1 join s2 join t3 join t4 using(a);
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
from s1 join s2 join t3 left join t4 using(a);
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
from s1 join s2 join t3 right join t4 using(a);
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 join t3 on t2.a=t3.a join t4;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 left join t3 on t2.a=t3.a join t4;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 right join t3 on t2.a=t3.a join t4;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from s1 join t2 join t3 using(a) join t4;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from s1 join t2 left join t3 using(a) join t4;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from s1 join t2 right join t3 using(a) join t4;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 left join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 left join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 left join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 right join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 right join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 right join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from s1 join t1 left join t2 on s1.b=t2.a join t3 join t4 on t4.a=s1.b;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from s1 join t1 left join t2 on s1.b=t2.a join t3 left join t4 on t4.a=s1.b;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from s1 join t1 left join t2 on s1.b=t2.a join t3 right join t4 on t4.a=s1.b;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from s1 join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from s1 left join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
eval explain extended $q;
eval $q;
let $q=
select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
from s1 right join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from (t1 join t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
let $q=
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
from (t1, t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
eval explain extended $q;
eval $q;
drop table t1,t2,t3,t4,s1,s2;
--echo #
--echo # End of MariaDB 5.5 tests
--echo #

View File

@ -358,7 +358,7 @@ drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16;
drop table if exists t1,t2,t3;
create table t2(a int,unique key (a)) engine=innodb;
create table t3(b int) engine=innodb;
create table t1(a int,b int)engine=innodb;
create table t1(c int,b int)engine=innodb;
set @mdev4270_opl= @@optimizer_prune_level;
set @mdev4270_osd= @@optimizer_search_depth;

View File

@ -252,6 +252,21 @@ select plugin_name from information_schema.plugins where plugin_library like 'ha
uninstall soname 'ha_example';
select plugin_name from information_schema.plugins where plugin_library like 'ha_example%';
#
#
#
set names utf8;
select convert('admin𝌆' using utf8);
--error ER_UDF_NO_PATHS
install plugin foo soname 'admin𝌆';
#
# Bug#27302459: EMPTY VALUE IN MYSQL.PLUGIN TABLE CAUSES SERVER TO EXIT ON STARTUP
#
insert mysql.plugin values ();
source include/restart_mysqld.inc;
delete from mysql.plugin where name = '';
--echo #
--echo # MDEV-5309 - RENAME TABLE does not check for existence of the table's

View File

@ -3875,6 +3875,83 @@ FROM
FROM t1 A, (SELECT @cnt := 0) C) T
) X;
drop table t1;
--echo #
--echo # MDEV-17042: prepared statement does not return error with
--echo # SQL_MODE STRICT_TRANS_TABLES. (Part 1)
--echo #
set @save_sql_mode=@@sql_mode;
set sql_mode='STRICT_ALL_TABLES';
CREATE TABLE t1 (id int, count int);
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id decimal(10,5), count int);
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id double, count int);
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id date, count int);
insert into t1 values ("2019-06-11",1),("2019-06-12",2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
set sql_mode=@save_sql_mode;
--echo # End of 5.5 tests
--echo #

View File

@ -0,0 +1,80 @@
--source include/have_innodb.inc
--echo #
--echo # MDEV-17042: prepared statement does not return error with
--echo # SQL_MODE STRICT_TRANS_TABLES. (Part 2)
--echo #
set @save_sql_mode=@@sql_mode;
set sql_mode='STRICT_TRANS_TABLES';
CREATE TABLE t1 (id int, count int) engine=innodb;
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id decimal(10,5), count int) engine=innodb;
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id double, count int) engine=innodb;
insert into t1 values (1,1),(0,2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
CREATE TABLE t1 (id date, count int) engine=innodb;
insert into t1 values ("2019-06-11",1),("2019-06-12",2);
--error ER_TRUNCATED_WRONG_VALUE
update t1 set count = count + 1 where id = '1bad';
prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
--error ER_TRUNCATED_WRONG_VALUE
execute stmt;
deallocate prepare stmt;
prepare stmt from 'update t1 set count = count + 1 where id = ?';
set @a = '1bad';
--error ER_TRUNCATED_WRONG_VALUE
execute stmt using @a;
deallocate prepare stmt;
drop table t1;
set sql_mode=@save_sql_mode;
--echo # End of 5.5 tests

View File

@ -6113,6 +6113,30 @@ explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
drop table t1,t2;
--echo #
--echo # MDEV-19429: Wrong query result with EXISTS and LIMIT 0
--echo #
create table t10 (a int);
insert into t10 values (1),(2),(3);
create table t12 (a int);
insert into t12 values (1),(2),(3);
select * from t10 where exists (select * from t12 order by a limit 0);
explain select * from t10 where exists (select * from t12 order by a limit 0);
prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
set @l=1;
execute stmt1 using @l;
set @l=2;
execute stmt1 using @l;
set @l=0;
execute stmt1 using @l;
deallocate prepare stmt1;
drop table t10, t12;
--echo End of 5.5 tests
--echo # End of 10.0 tests

View File

@ -5691,6 +5691,26 @@ t46, t47, t48, t49, t50, t51, t52, t53, t54,
t55, t56, t57, t58, t59,t60;
drop view v60;
--echo #
--echo # MDEV-15572: view.test, server crash with --big-tables=1
--echo #
set @save_big_tables=@@big_tables;
set big_tables=ON;
CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int);
CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int);
CREATE VIEW v1 AS
SELECT t2.f1, t1.f2, t2.f3, t2.f4 FROM (t1 JOIN t2);
--error ER_VIEW_MULTIUPDATE
REPLACE INTO v1 (f1, f2, f3, f4)
SELECT f1, f2, f3, f4 FROM t1;
drop view v1;
drop table t1, t2;
set big_tables=@save_big_tables;
--echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests.
--echo # -----------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -504,7 +504,7 @@ const char* get_last_error_message(Error_message_buf buf)
buf[0]= '\0';
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)buf, sizeof(buf), NULL );
(LPTSTR)buf, sizeof(Error_message_buf), NULL);
return buf;
}

View File

@ -273,9 +273,16 @@ then
fi
if test -n "$srcdir"
then
# In an out-of-source build, builddir is not srcdir. Try to guess where
# builddir is by looking for my_print_defaults.
if test -z "$builddir"
then
builddir="$srcdir"
if test -x "$dirname0/extra/my_print_defaults"
then
builddir="$dirname0"
else
builddir="$srcdir"
fi
fi
print_defaults="$builddir/extra/my_print_defaults"
elif test -n "$basedir"

View File

@ -362,7 +362,13 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
mysql->options.extension && mysql->options.extension->plugin_dir ?
mysql->options.extension->plugin_dir : PLUGINDIR, "/",
name, SO_EXT, NullS);
if (strpbrk(name, "()[]!@#$%^&/*;.,'?"))
{
errmsg= "invalid plugin name";
goto err;
}
DBUG_PRINT ("info", ("dlopeninig %s", dlpath));
/* Open new dll handle */
if (!(dlhandle= dlopen(dlpath, RTLD_NOW)))

View File

@ -9736,11 +9736,14 @@ table_map Item_direct_view_ref::used_tables() const
table_map Item_direct_view_ref::not_null_tables() const
{
return get_depended_from() ?
0 :
((view->is_merged_derived() || view->merged || !view->table) ?
(*ref)->not_null_tables() :
view->table->map);
if (get_depended_from())
return 0;
if (!( view->merged || !view->table))
return view->table->map;
TABLE *tab= get_null_ref_table();
if (tab == NO_NULL_TABLE || (*ref)->used_tables())
return (*ref)->not_null_tables();
return get_null_ref_table()->map;
}
/*

View File

@ -4374,6 +4374,7 @@ public:
void update_used_tables();
table_map not_null_tables() const;
bool const_item() const { return used_tables() == 0; }
TABLE *get_null_ref_table() const { return null_ref_table; }
bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
{
return (*ref)->walk(processor, walk_subquery, arg) ||

View File

@ -218,6 +218,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
with_param= with_param || item->with_param;
with_field= with_field || item->with_field;
used_tables_and_const_cache_join(item);
not_null_tables_cache|= item->not_null_tables();
with_subselect|= item->has_subquery();
}
}

View File

@ -1500,13 +1500,20 @@ void Item_exists_subselect::fix_length_and_dec()
{
DBUG_ENTER("Item_exists_subselect::fix_length_and_dec");
init_length_and_dec();
/*
We need only 1 row to determine existence (i.e. any EXISTS that is not
an IN always requires LIMIT 1)
*/
thd->change_item_tree(&unit->global_parameters()->select_limit,
new (thd->mem_root) Item_int(thd, (int32) 1));
DBUG_PRINT("info", ("Set limit to 1"));
// If limit is not set or it is constant more than 1
if (!unit->global_parameters()->select_limit ||
(unit->global_parameters()->select_limit->basic_const_item() &&
unit->global_parameters()->select_limit->val_int() > 1))
{
/*
We need only 1 row to determine existence (i.e. any EXISTS that is not
an IN always requires LIMIT 1)
*/
thd->change_item_tree(&unit->global_parameters()->select_limit,
new (thd->mem_root) Item_int(thd, (int32) 1));
unit->global_parameters()->explicit_limit= 1; // we set the limit
DBUG_PRINT("info", ("Set limit to 1"));
}
DBUG_VOID_RETURN;
}

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2005, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2017, MariaDB
/* Copyright (c) 2005, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -1,8 +1,7 @@
#ifndef ITEM_XMLFUNC_INCLUDED
#define ITEM_XMLFUNC_INCLUDED
/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc.
Use is subject to license terms.
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -11510,6 +11510,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin;
DBUG_EXECUTE_IF("auth_disconnect", { vio_close(net->vio); DBUG_RETURN(1); });
DBUG_EXECUTE_IF("auth_invalid_plugin", client_auth_plugin="foo/bar"; );
DBUG_ASSERT(client_auth_plugin);
/*

View File

@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2010, Oracle and/or its affiliates.
Copyright (c) 2010, 2015, MariaDB
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2010, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -1324,6 +1324,7 @@ bool multi_delete::send_eof()
thd->clear_error();
else
errcode= query_error_code(thd, killed_status == NOT_KILLED);
thd->thread_specific_used= TRUE;
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query(), thd->query_length(),
transactional_tables, FALSE, FALSE, errcode) &&

View File

@ -3871,8 +3871,12 @@ void select_insert::abort_result_set() {
example), no table will have been opened and therefore 'table'
will be NULL. In that case, we still need to execute the rollback
and the end of the function.
If it fail due to inability to insert in multi-table view for example,
table will be assigned with view table structure, but that table will
not be opened really (it is dummy to check fields types & Co).
*/
if (table)
if (table && table->file->get_table())
{
bool changed, transactional_table;
/*

View File

@ -2735,14 +2735,13 @@ void st_select_lex::print_limit(THD *thd,
if (item && unit->global_parameters() == this)
{
Item_subselect::subs_type subs_type= item->substype();
if (subs_type == Item_subselect::EXISTS_SUBS ||
subs_type == Item_subselect::IN_SUBS ||
if (subs_type == Item_subselect::IN_SUBS ||
subs_type == Item_subselect::ALL_SUBS)
{
return;
}
}
if (explicit_limit)
if (explicit_limit && select_limit)
{
str->append(STRING_WITH_LEN(" limit "));
if (offset_limit)

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB Corporation
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2010, 2019, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -960,6 +960,8 @@ public:
TABLE_LIST *end_nested_join(THD *thd);
TABLE_LIST *nest_last_join(THD *thd);
void add_joined_table(TABLE_LIST *table);
bool add_cross_joined_table(TABLE_LIST *left_op, TABLE_LIST *right_op,
bool straight_fl);
TABLE_LIST *convert_right_join();
List<Item>* get_item_list();
ulong get_table_join_options();
@ -2873,9 +2875,9 @@ public:
return context_stack.push_front(context, mem_root);
}
void pop_context()
Name_resolution_context *pop_context()
{
context_stack.pop();
return context_stack.pop();
}
bool copy_db_to(char **p_db, size_t *p_db_length) const;
@ -3069,15 +3071,18 @@ public:
class Yacc_state
{
public:
Yacc_state()
{
reset();
}
Yacc_state() : yacc_yyss(NULL), yacc_yyvs(NULL) { reset(); }
void reset()
{
yacc_yyss= NULL;
yacc_yyvs= NULL;
if (yacc_yyss != NULL) {
my_free(yacc_yyss);
yacc_yyss = NULL;
}
if (yacc_yyvs != NULL) {
my_free(yacc_yyvs);
yacc_yyvs = NULL;
}
m_set_signal_info.clear();
m_lock_type= TL_READ_DEFAULT;
m_mdl_type= MDL_SHARED_READ;

View File

@ -7594,6 +7594,7 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd)
join_list= ptr->join_list;
embedding= ptr->embedding;
nested_join= ptr->nested_join;
nested_join->nest_type= 0;
if (nested_join->join_list.elements == 1)
{
TABLE_LIST *embedded= nested_join->join_list.head();
@ -7603,6 +7604,8 @@ TABLE_LIST *st_select_lex::end_nested_join(THD *thd)
join_list->push_front(embedded, thd->mem_root);
ptr= embedded;
embedded->lifted= 1;
if (embedded->nested_join)
embedded->nested_join->nest_type= 0;
}
else if (nested_join->join_list.elements == 0)
{
@ -7633,6 +7636,16 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd)
List<TABLE_LIST> *embedded_list;
DBUG_ENTER("nest_last_join");
TABLE_LIST *head= join_list->head();
if (head->nested_join && head->nested_join->nest_type & REBALANCED_NEST)
{
List_iterator<TABLE_LIST> li(*join_list);
li++;
while (li++)
li.remove();
DBUG_RETURN(head);
}
if (!(ptr= (TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+
sizeof(NESTED_JOIN))))
DBUG_RETURN(0);
@ -7644,6 +7657,7 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd)
ptr->alias= (char*) "(nest_last_join)";
embedded_list= &nested_join->join_list;
embedded_list->empty();
nested_join->nest_type= JOIN_OP_NEST;
for (uint i=0; i < 2; i++)
{
@ -7694,6 +7708,227 @@ void st_select_lex::add_joined_table(TABLE_LIST *table)
}
/**
@brief
Create a node for JOIN/INNER JOIN/CROSS JOIN/STRAIGHT_JOIN operation
@param left_op the node for the left operand constructed by the parser
@param right_op the node for the right operand constructed by the parser
@param straight_fl TRUE if STRAIGHT_JOIN is used
@retval
false on success
true otherwise
@details
JOIN operator can be left-associative with other join operators in one
context and right-associative in another context.
In this query
SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a (Q1)
JOIN is left-associative and the query Q1 is interpreted as
SELECT * FROM (t1 JOIN t2) LEFT JOIN t3 ON t2.a=t3.a.
While in this query
SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.b=t2.b (Q2)
JOIN is right-associative and the query Q2 is interpreted as
SELECT * FROM t1 JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.b=t2.b
JOIN is right-associative if it is used with ON clause or with USING clause.
Otherwise it is left-associative.
When parsing a join expression with JOIN operator we can't determine
whether this operation left or right associative until either we read the
corresponding ON clause or we reach the end of the expression. This creates
a problem for the parser to build a proper internal representation of the
used join expression.
For Q1 and Q2 the trees representing the used join expressions look like
LJ - ON J - ON
/ \ / \
J t3 (TQ1) t1 LJ - ON (TQ2)
/ \ / \
t1 t2 t2 t3
To build TQ1 the parser has to reduce the expression for JOIN right after
it has read the reference to t2. To build TQ2 the parser reduces JOIN
when he has read the whole join expression. There is no way to determine
whether an early reduction is needed until the whole join expression is
read.
A solution here is always to do a late reduction. In this case the parser
first builds an incorrect tree TQ1* that has to be rebalanced right after
it has been constructed.
J LJ - ON
/ \ / \
t1 LJ - ON (TQ1*) => J t3
/ \ / \
t2 t3 t1 t2
Actually the transformation is performed over the nodes t1 and LJ before the
node for J is created in the function st_select_lex::add_cross_joined_table.
The function creates a node for J which replaces the node t2. Then it
attaches the nodes t1 and t2 to this newly created node. The node LJ becomes
the top node of the tree.
For the query
SELECT * FROM t1 JOIN t2 RIGHT JOIN t3 ON t2.a=t3.a (Q3)
the transformation looks slightly differently because the parser
replaces the RIGHT JOIN tree for an equivalent LEFT JOIN tree.
J LJ - ON
/ \ / \
t1 LJ - ON (TQ3*) => J t2
/ \ / \
t3 t2 t1 t3
With several left associative JOINs
SELECT * FROM t1 JOIN t2 JOIN t3 LEFT JOIN t4 ON t3.a=t4.a (Q4)
the newly created node for JOIN replaces the left most node of the tree:
J1 LJ - ON
/ \ / \
t1 LJ - ON J2 t4
/ \ => / \
J2 t4 J1 t3
/ \ / \
t2 t3 t1 t2
Here's another example:
SELECT *
FROM t1 JOIN t2 LEFT JOIN t3 JOIN t4 ON t3.a=t4.a ON t2.b=t3.b (Q5)
J LJ - ON
/ \ / \
t1 LJ - ON J J - ON
/ \ => / \ / \
t2 J - ON t1 t2 t3 t4
/ \
t3 t4
If the transformed nested join node node is a natural join node like in
the following query
SELECT * FROM t1 JOIN t2 LEFT JOIN t3 USING(a) (Q6)
the transformation additionally has to take care about setting proper
references in the field natural_join for both operands of the natural
join operation.
The function also has to change the name resolution context for ON
expressions used in the transformed join expression to take into
account the tables of the left_op node.
*/
bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op,
TABLE_LIST *right_op,
bool straight_fl)
{
DBUG_ENTER("add_cross_joined_table");
THD *thd= parent_lex->thd;
if (!(right_op->nested_join &&
(right_op->nested_join->nest_type & JOIN_OP_NEST)))
{
/*
This handles the cases when the right operand is not a nested join.
like in queries
SELECT * FROM t1 JOIN t2;
SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a JOIN t3
*/
right_op->straight= straight_fl;
DBUG_RETURN(false);
}
TABLE_LIST *tbl;
List<TABLE_LIST> *jl= &right_op->nested_join->join_list;
TABLE_LIST *cj_nest;
/*
Create the node NJ for a new nested join for the future inclusion
of left_op in it. Initially the nest is empty.
*/
if (unlikely(!(cj_nest=
(TABLE_LIST*) thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST))+
sizeof(NESTED_JOIN)))))
DBUG_RETURN(true);
cj_nest->nested_join=
((NESTED_JOIN*) ((uchar*) cj_nest + ALIGN_SIZE(sizeof(TABLE_LIST))));
cj_nest->nested_join->nest_type= JOIN_OP_NEST;
List<TABLE_LIST> *cjl= &cj_nest->nested_join->join_list;
cjl->empty();
/* Look for the left most node tbl of the right_op tree */
for ( ; ; )
{
TABLE_LIST *pair_tbl= 0; /* useful only for operands of natural joins */
List_iterator<TABLE_LIST> li(*jl);
tbl= li++;
/* Expand name resolution context */
Name_resolution_context *on_context;
if ((on_context= tbl->on_context))
{
on_context->first_name_resolution_table=
left_op->first_leaf_for_name_resolution();
}
if (!(tbl->outer_join & JOIN_TYPE_RIGHT))
{
pair_tbl= tbl;
tbl= li++;
}
if (tbl->nested_join &&
tbl->nested_join->nest_type & JOIN_OP_NEST)
{
jl= &tbl->nested_join->join_list;
continue;
}
/* Replace the tbl node in the tree for the newly created NJ node */
cj_nest->outer_join= tbl->outer_join;
cj_nest->on_expr= tbl->on_expr;
cj_nest->embedding= tbl->embedding;
cj_nest->join_list= jl;
cj_nest->alias= (char*) "(nest_last_join)";
li.replace(cj_nest);
/*
If tbl is an operand of a natural join set properly the references
in the fields natural_join for both operands of the operation.
*/
if(tbl->embedding && tbl->embedding->is_natural_join)
{
if (!pair_tbl)
pair_tbl= li++;
pair_tbl->natural_join= cj_nest;
cj_nest->natural_join= pair_tbl;
}
break;
}
/* Attach tbl as the right operand of NJ */
if (unlikely(cjl->push_back(tbl, thd->mem_root)))
DBUG_RETURN(true);
tbl->outer_join= 0;
tbl->on_expr= 0;
tbl->straight= straight_fl;
tbl->natural_join= 0;
tbl->embedding= cj_nest;
tbl->join_list= cjl;
/* Add left_op as the left operand of NJ */
if (unlikely(cjl->push_back(left_op, thd->mem_root)))
DBUG_RETURN(true);
left_op->embedding= cj_nest;
left_op->join_list= cjl;
/*
Mark right_op as a rebalanced nested join in order not to
create a new top level nested join node.
*/
right_op->nested_join->nest_type|= REBALANCED_NEST;
DBUG_RETURN(false);
}
/**
Convert a right join into equivalent left join.

View File

@ -747,9 +747,9 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
This is done to ensure that only approved libraries from the
plugin directory are used (to make this even remotely secure).
*/
if (check_valid_path(dl->str, dl->length) ||
check_string_char_length((LEX_STRING *) dl, 0, NAME_CHAR_LEN,
if (check_string_char_length((LEX_STRING *) dl, 0, NAME_CHAR_LEN,
system_charset_info, 1) ||
check_valid_path(dl->str, dl->length) ||
plugin_dir_len + dl->length + 1 >= FN_REFLEN)
{
report_error(report, ER_UDF_NO_PATHS);
@ -1814,6 +1814,9 @@ static void plugin_load(MEM_ROOT *tmp_root)
LEX_STRING name= {(char *)str_name.ptr(), str_name.length()};
LEX_STRING dl= {(char *)str_dl.ptr(), str_dl.length()};
if (!name.length || !dl.length)
continue;
/*
there're no other threads running yet, so we don't need a mutex.
but plugin_add() before is designed to work in multi-threaded

View File

@ -1144,7 +1144,6 @@ JOIN::optimize_inner()
DBUG_RETURN(1); /* purecov: inspected */
/* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */
select_lex->update_used_tables();
}
eval_select_list_used_tables();
@ -1206,6 +1205,8 @@ JOIN::optimize_inner()
sel->where= conds;
select_lex->update_used_tables();
if (arena)
thd->restore_active_arena(arena, &backup);
}
@ -12894,6 +12895,9 @@ static bool check_simple_equality(THD *thd, const Item::Context &ctx,
{
if (((Item_ref*)left_item)->get_depended_from())
return FALSE;
if (((Item_direct_view_ref*)left_item)->get_null_ref_table() !=
NO_NULL_TABLE && !left_item->real_item()->used_tables())
return FALSE;
left_item= left_item->real_item();
}
if (right_item->type() == Item::REF_ITEM &&
@ -12901,6 +12905,9 @@ static bool check_simple_equality(THD *thd, const Item::Context &ctx,
{
if (((Item_ref*)right_item)->get_depended_from())
return FALSE;
if (((Item_direct_view_ref*)right_item)->get_null_ref_table() !=
NO_NULL_TABLE && !right_item->real_item()->used_tables())
return FALSE;
right_item= right_item->real_item();
}
if (left_item->type() == Item::FIELD_ITEM &&

View File

@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2010, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -2529,8 +2529,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
table->table_name););
}
DEBUG_SYNC(thd, "rm_table_no_locks_before_binlog");
thd->thread_specific_used|= (trans_tmp_table_deleted ||
non_trans_tmp_table_deleted);
thd->thread_specific_used= TRUE;
error= 0;
err:
if (wrong_tables.length())

View File

@ -1029,7 +1029,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
Currently there are 160 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 162
%expect 161
/*
Comments for TOKENS.
@ -1692,9 +1692,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token IMPOSSIBLE_ACTION /* To avoid warning for yyerrlab1 */
%left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT
/* A dummy token to force the priority of table_ref production in a join. */
%left TABLE_REF_PRIORITY
%left CONDITIONLESS_JOIN
%left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT ON_SYM USING
%left SET_VAR
%left OR_OR_SYM OR_SYM OR2_SYM
%left XOR
@ -10407,9 +10407,9 @@ join_table_list:
and are ignored.
*/
esc_table_ref:
table_ref { $$=$1; }
| '{' ident table_ref '}' { $$=$3; }
;
table_ref { $$=$1; }
| '{' ident table_ref '}' { $$=$3; }
;
/* Equivalent to <table reference list> in the SQL:2003 standard. */
/* Warning - may return NULL in case of incomplete SELECT */
@ -10422,11 +10422,9 @@ derived_table_list:
;
/*
Notice that JOIN is a left-associative operation, and it must be parsed
as such, that is, the parser must process first the left join operand
then the right one. Such order of processing ensures that the parser
produces correct join trees which is essential for semantic analysis
and subsequent optimization phases.
Notice that JOIN can be a left-associative operator in one context and
a right-associative operator in another context (see the comment for
st_select_lex::add_cross_joined_table).
*/
join_table:
/* INNER JOIN variants */
@ -10435,8 +10433,13 @@ join_table:
so that [INNER | CROSS] JOIN is properly nested as other
left-associative joins.
*/
table_ref normal_join table_ref %prec TABLE_REF_PRIORITY
{ MYSQL_YYABORT_UNLESS($1 && ($$=$3)); $3->straight=$2; }
table_ref normal_join table_ref %prec CONDITIONLESS_JOIN
{
MYSQL_YYABORT_UNLESS($1 && ($$=$3));
if (unlikely(Select->add_cross_joined_table($1, $3, $2)))
MYSQL_YYABORT;
}
| table_ref normal_join table_ref
ON
{
@ -10450,7 +10453,7 @@ join_table:
{
$3->straight=$2;
add_join_on(thd, $3, $6);
Lex->pop_context();
$3->on_context= Lex->pop_context();
Select->parsing_place= NO_MATTER;
}
| table_ref normal_join table_ref
@ -10484,7 +10487,7 @@ join_table:
expr
{
add_join_on(thd, $5, $8);
Lex->pop_context();
$5->on_context= Lex->pop_context();
$5->outer_join|=JOIN_TYPE_LEFT;
$$=$5;
Select->parsing_place= NO_MATTER;
@ -10523,7 +10526,7 @@ join_table:
if (!($$= lex->current_select->convert_right_join()))
MYSQL_YYABORT;
add_join_on(thd, $$, $8);
Lex->pop_context();
$1->on_context= Lex->pop_context();
Select->parsing_place= NO_MATTER;
}
| table_ref RIGHT opt_outer JOIN_SYM table_factor

View File

@ -50,6 +50,7 @@ class ACL_internal_table_access;
class Field;
class Table_statistics;
class TDC_element;
struct Name_resolution_context;
/*
Used to identify NESTED_JOIN structures within a join (applicable only to
@ -1828,6 +1829,7 @@ struct TABLE_LIST
char *db, *alias, *table_name, *schema_table_name;
char *option; /* Used by cache index */
Item *on_expr; /* Used with outer join */
Name_resolution_context *on_context; /* For ON expressions */
Item *sj_on_expr;
/*
@ -2555,9 +2557,31 @@ public:
};
#define JOIN_OP_NEST 1
#define REBALANCED_NEST 2
typedef struct st_nested_join
{
List<TABLE_LIST> join_list; /* list of elements in the nested join */
/*
Currently the valid values for nest type are:
JOIN_OP_NEST - for nest created for JOIN operation used as an operand in
a join expression, contains 2 elements;
JOIN_OP_NEST | REBALANCED_NEST - nest created after tree re-balancing
in st_select_lex::add_cross_joined_table(), contains 1 element;
0 - for all other nests.
Examples:
1. SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a;
Here the nest created for LEFT JOIN at first has nest_type==JOIN_OP_NEST.
After re-balancing in st_select_lex::add_cross_joined_table() this nest
has nest_type==JOIN_OP_NEST | REBALANCED_NEST. The nest for JOIN created
in st_select_lex::add_cross_joined_table() has nest_type== JOIN_OP_NEST.
2. SELECT * FROM t1 JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a)
Here the nest created for LEFT JOIN has nest_type==0, because it's not
an operand in a join expression. The nest created for JOIN has nest_type
set to JOIN_OP_NEST.
*/
uint nest_type;
/*
Bitmap of tables within this nested join (including those embedded within
its children), including tables removed by table elimination.

View File

@ -388,7 +388,7 @@ case "$mode" in
fi
else
# Try to find appropriate mysqld process
mysqld_pid=`pgrep $libexecdir/mysqld`
mysqld_pid=`pgrep -f $libexecdir/mysqld`
# test if multiple pids exist
pid_count=`echo $mysqld_pid | wc -w`

View File

@ -1,4 +1,4 @@
SET(HEIDISQL_BASE_NAME "HeidiSQL_9.5_Portable")
SET(HEIDISQL_BASE_NAME "HeidiSQL_10.2_32_Portable")
SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip")
SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}")
SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME})
@ -12,12 +12,5 @@ IF(NOT EXISTS ${HEIDISQL_DOWNLOAD_DIR}/${HEIDISQL_ZIP})
)
ENDIF()
SET(LIBMYSQLDLL_SOURCE ${HEIDISQL_DOWNLOAD_DIR}/libmysql.dll)
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
# Use our libmysql if it is 32 bit.
IF(LIBMYSQL_LOCATION)
SET(LIBMYSQLDLL_SOURCE "${LIBMYSQL_LOCATION}")
ENDIF()
ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/heidisql.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/heidisql.wxi)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/heidisql_feature.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/heidisql_feature.wxi)

View File

@ -8,6 +8,7 @@
Win64="no"
/>
</Property>
<?define pluginlist=auth_gssapi_client.dll;mysql_clear_password.dll;sha256_password.dll;caching_sha2_password.dll;pvio_npipe.dll;dialog.dll;pvio_shmem.dll?>
<DirectoryRef Id="MariaDBShared">
<Directory Id="D.HeidiSQL" Name="HeidiSQL">
<Component Id="component.HeidiSQL" Guid="96ea3879-5320-4098-8f26-2f655d2f716c" Win64="no">
@ -35,7 +36,9 @@
<Component Id="component.HeidiSQL_libmysql.dll" Guid="*" Win64="no">
<File Id="heidisql.libmysql.dll" Name="libmysql.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libmysql.dll" />
</Component>
<Component Id="component.HeidiSQL_libmariadb.dll" Guid="*" Win64="no">
<File Id="heidisql.libmariadb.dll" Name="libmariadb.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libmariadb.dll" />
</Component>
<Component Id="component.HeidiSQL_libeay32.dll" Guid="*" Win64="no">
<File Id="heidisql.libeay32.dll" Name="libeay32.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\libeay32.dll" />
</Component>
@ -53,12 +56,11 @@
</Component>
<Directory Id="D.HeidiSQL.plugins" Name="plugins">
<Component Id="component.HeidiSQL_dialog.dll" Guid="*" Win64="no">
<File Id="heidisql.dialog.dll" Name="dialog.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\plugins\dialog.dll" />
</Component>
<Component Id="component.HeidiSQL_auth_gssapi_client.dll" Guid="*" Win64="no">
<File Id="heidisql.auth_gssapi_client.dll" Name="auth_gssapi_client.dll" Source="${HEIDISQL_DOWNLOAD_DIR}\plugins\auth_gssapi_client.dll" />
<?foreach dll in $(var.pluginlist) ?>
<Component Id="component.HeidiSQL_$(var.dll)" Guid="*" Win64="no">
<File Id="heidisql.$(var.dll)" Name="$(var.dll)" Source="${HEIDISQL_DOWNLOAD_DIR}\plugins\$(var.dll)" />
</Component>
<?endforeach?>
</Directory>
<Component Id="component.HeidiSQL_CleanupSettings" Guid="*" Win64="no">
@ -73,13 +75,15 @@
<ComponentRef Id="component.HeidiSQL"/>
<ComponentRef Id="component.HeidiSQL_MenuShortcut"/>
<ComponentRef Id="component.HeidiSQL_libmysql.dll"/>
<ComponentRef Id="component.HeidiSQL_libmariadb.dll"/>
<ComponentRef Id="component.HeidiSQL_libeay32.dll" />
<ComponentRef Id="component.HeidiSQL_libpq.dll" />
<ComponentRef Id="component.HeidiSQL_ssleay32.dll" />
<ComponentRef Id="component.HeidiSQL_libintl_8.dll" />
<ComponentRef Id="component.HeidiSQL_libiconv_2.dll" />
<ComponentRef Id="component.HeidiSQL_dialog.dll" />
<ComponentRef Id="component.HeidiSQL_auth_gssapi_client.dll" />
<?foreach dll in $(var.pluginlist)?>
<ComponentRef Id="component.HeidiSQL_$(var.dll)" />
<?endforeach?>
<ComponentRef Id="component.HeidiSQL_CleanupSettings"/>
</ComponentGroup>
</Include>