Commit 534b0c92 authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Update upstream source from tag 'upstream/10.1.38'

Update to upstream version '10.1.38'
with Debian dir bf5887327d488168695833ed7a82628c14b6eac8
parents 4b96bd2d e07d9be7
...@@ -136,7 +136,7 @@ select * from t1; ...@@ -136,7 +136,7 @@ select * from t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES ERROR HY000: Table 't1' was not locked with LOCK TABLES
unlock tables; unlock tables;
create or replace view v_bug5719 as select * from t1; create or replace view v_bug5719 as select * from t1;
lock tables v_bug5719 write; lock tables v_bug5719 read;
select * from v_bug5719; select * from v_bug5719;
a a
...@@ -299,7 +299,7 @@ create table t2 (j int); ...@@ -299,7 +299,7 @@ create table t2 (j int);
# #
# Try to perform DDL on table which is locked through view. # Try to perform DDL on table which is locked through view.
create view v1 as select * from t2; create view v1 as select * from t2;
lock tables t1 write, v1 write; lock tables t1 write, v1 read;
flush table t2; flush table t2;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
drop table t2; drop table t2;
......
...@@ -276,15 +276,14 @@ DROP VIEW IF EXISTS v1; ...@@ -276,15 +276,14 @@ DROP VIEW IF EXISTS v1;
# #
# Test 1: LOCK TABLES v1 WRITE, t1 READ; # Test 1: LOCK TABLES v1 WRITE, t1 READ;
# #
# Thanks to the fact that we no longer allow DDL on tables
# which are locked for write implicitly, the exact scenario
# in which assert was failing is no longer repeatable.
CREATE TABLE t1 ( f1 integer ); CREATE TABLE t1 ( f1 integer );
CREATE VIEW v1 AS SELECT f1 FROM t1 ; CREATE VIEW v1 AS SELECT f1 FROM t1 ;
# Connection 2
LOCK TABLES v1 WRITE, t1 READ; LOCK TABLES v1 WRITE, t1 READ;
FLUSH TABLE t1; FLUSH TABLE t1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated # Connection 1
UNLOCK TABLES; LOCK TABLES t1 WRITE;
FLUSH TABLE t1;
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; DROP VIEW v1;
# #
......
...@@ -648,9 +648,6 @@ set debug_sync= 'RESET'; ...@@ -648,9 +648,6 @@ set debug_sync= 'RESET';
set @old_general_log = @@global.general_log; set @old_general_log = @@global.general_log;
set @@global.general_log= OFF; set @@global.general_log= OFF;
create table t1 (i int) engine=InnoDB; create table t1 (i int) engine=InnoDB;
# We have to use view in order to make LOCK TABLES avoid
# acquiring SNRW metadata lock on table.
create view v1 as select * from t1;
insert into t1 values (1); insert into t1 values (1);
# Prepare user lock which will be used for resuming execution of # Prepare user lock which will be used for resuming execution of
# the first statement after it acquires TL_WRITE_ALLOW_WRITE lock. # the first statement after it acquires TL_WRITE_ALLOW_WRITE lock.
...@@ -673,7 +670,7 @@ select count(*) > 0 from t1 as a, t1 as b for update;; ...@@ -673,7 +670,7 @@ select count(*) > 0 from t1 as a, t1 as b for update;;
# acquiring lock for the the first instance of 't1'. # acquiring lock for the the first instance of 't1'.
set debug_sync= 'now WAIT_FOR parked'; set debug_sync= 'now WAIT_FOR parked';
# Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1': # Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1':
lock table v1 write;; lock table t1 write concurrent;;
# Switch to connection 'default'. # Switch to connection 'default'.
# Wait until this LOCK TABLES statement starts waiting for table lock. # Wait until this LOCK TABLES statement starts waiting for table lock.
# Allow SELECT ... FOR UPDATE to resume. # Allow SELECT ... FOR UPDATE to resume.
...@@ -703,7 +700,6 @@ unlock tables; ...@@ -703,7 +700,6 @@ unlock tables;
# Do clean-up. # Do clean-up.
set debug_sync= 'RESET'; set debug_sync= 'RESET';
set @@global.general_log= @old_general_log; set @@global.general_log= @old_general_log;
drop view v1;
drop table t1; drop table t1;
# #
# Bug#50821 Deadlock between LOCK TABLES and ALTER TABLE # Bug#50821 Deadlock between LOCK TABLES and ALTER TABLE
......
...@@ -600,3 +600,29 @@ a ...@@ -600,3 +600,29 @@ a
2 2
drop table "a1\""b1"; drop table "a1\""b1";
set sql_mode=default; set sql_mode=default;
create table t1 (a text);
select count(*) from t1;
count(*)
41
truncate table t1;
select count(*) from t1;
count(*)
41
truncate table t1;
select count(*) from t1;
count(*)
0
truncate table t1;
select count(*) from t1;
count(*)
0
truncate table t1;
select count(*) from t1;
count(*)
41
truncate table t1;
select count(*) from t1;
count(*)
0
truncate table t1;
drop table t1;
...@@ -54,9 +54,9 @@ CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMIN ...@@ -54,9 +54,9 @@ CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMIN
BEGIN BEGIN
/*!*/; /*!*/;
# at 781 # at 781
#<date> server id 1 end_log_pos 833 Table_map: `test`.`t1` mapped to number 30 #<date> server id 1 end_log_pos 833 Table_map: `test`.`t1` mapped to number 31
# at 833 # at 833
#<date> server id 1 end_log_pos 898 Write_rows: table id 30 flags: STMT_END_F #<date> server id 1 end_log_pos 898 Write_rows: table id 31 flags: STMT_END_F
### INSERT INTO `test`.`t1` ### INSERT INTO `test`.`t1`
### SET ### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */ ### @1=10 /* INT meta=0 nullable=0 is_null=0 */
...@@ -79,9 +79,9 @@ COMMIT ...@@ -79,9 +79,9 @@ COMMIT
BEGIN BEGIN
/*!*/; /*!*/;
# at 1005 # at 1005
#<date> server id 1 end_log_pos 1057 Table_map: `test`.`t1` mapped to number 30 #<date> server id 1 end_log_pos 1057 Table_map: `test`.`t1` mapped to number 31
# at 1057 # at 1057
#<date> server id 1 end_log_pos 1121 Write_rows: table id 30 flags: STMT_END_F #<date> server id 1 end_log_pos 1121 Write_rows: table id 31 flags: STMT_END_F
### INSERT INTO `test`.`t1` ### INSERT INTO `test`.`t1`
### SET ### SET
### @1=11 /* INT meta=0 nullable=0 is_null=0 */ ### @1=11 /* INT meta=0 nullable=0 is_null=0 */
...@@ -104,9 +104,9 @@ COMMIT ...@@ -104,9 +104,9 @@ COMMIT
BEGIN BEGIN
/*!*/; /*!*/;
# at 1228 # at 1228
#<date> server id 1 end_log_pos 1280 Table_map: `test`.`t1` mapped to number 30 #<date> server id 1 end_log_pos 1280 Table_map: `test`.`t1` mapped to number 31
# at 1280 # at 1280
#<date> server id 1 end_log_pos 1343 Write_rows: table id 30 flags: STMT_END_F #<date> server id 1 end_log_pos 1343 Write_rows: table id 31 flags: STMT_END_F
### INSERT INTO `test`.`t1` ### INSERT INTO `test`.`t1`
### SET ### SET
### @1=12 /* INT meta=0 nullable=0 is_null=0 */ ### @1=12 /* INT meta=0 nullable=0 is_null=0 */
...@@ -129,9 +129,9 @@ COMMIT ...@@ -129,9 +129,9 @@ COMMIT
BEGIN BEGIN
/*!*/; /*!*/;
# at 1450 # at 1450
#<date> server id 1 end_log_pos 1502 Table_map: `test`.`t1` mapped to number 30 #<date> server id 1 end_log_pos 1502 Table_map: `test`.`t1` mapped to number 31
# at 1502 # at 1502
#<date> server id 1 end_log_pos 1568 Write_rows: table id 30 flags: STMT_END_F #<date> server id 1 end_log_pos 1568 Write_rows: table id 31 flags: STMT_END_F
### INSERT INTO `test`.`t1` ### INSERT INTO `test`.`t1`
### SET ### SET
### @1=13 /* INT meta=0 nullable=0 is_null=0 */ ### @1=13 /* INT meta=0 nullable=0 is_null=0 */
...@@ -154,9 +154,9 @@ COMMIT ...@@ -154,9 +154,9 @@ COMMIT
BEGIN BEGIN
/*!*/; /*!*/;
# at 1675 # at 1675
#<date> server id 1 end_log_pos 1727 Table_map: `test`.`t2` mapped to number 31 #<date> server id 1 end_log_pos 1727 Table_map: `test`.`t2` mapped to number 32
# at 1727 # at 1727
#<date> server id 1 end_log_pos 1890 Write_rows: table id 31 flags: STMT_END_F #<date> server id 1 end_log_pos 1890 Write_rows: table id 32 flags: STMT_END_F
### INSERT INTO `test`.`t2` ### INSERT INTO `test`.`t2`
### SET ### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */ ### @1=10 /* INT meta=0 nullable=0 is_null=0 */
...@@ -212,41 +212,38 @@ COMMIT ...@@ -212,41 +212,38 @@ COMMIT
BEGIN BEGIN
/*!*/; /*!*/;
# at 1997 # at 1997
#<date> server id 1 end_log_pos 2049 Table_map: `test`.`t2` mapped to number 31 #<date> server id 1 end_log_pos 2049 Table_map: `test`.`t2` mapped to number 32
# at 2049 # at 2049
#<date> server id 1 end_log_pos 2119 Update_rows: table id 31 flags: STMT_END_F #<date> server id 1 end_log_pos 2111 Update_rows: table id 32 flags: STMT_END_F
### UPDATE `test`.`t2` ### UPDATE `test`.`t2`
### WHERE ### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */ ### @1=10 /* INT meta=0 nullable=0 is_null=0 */
### @5=4 /* INT meta=0 nullable=1 is_null=0 */
### SET ### SET
### @5=5 /* INT meta=0 nullable=1 is_null=0 */ ### @5=5 /* INT meta=0 nullable=1 is_null=0 */
### UPDATE `test`.`t2` ### UPDATE `test`.`t2`
### WHERE ### WHERE
### @1=11 /* INT meta=0 nullable=0 is_null=0 */ ### @1=11 /* INT meta=0 nullable=0 is_null=0 */
### @5=4 /* INT meta=0 nullable=1 is_null=0 */
### SET ### SET
### @5=5 /* INT meta=0 nullable=1 is_null=0 */ ### @5=5 /* INT meta=0 nullable=1 is_null=0 */
### UPDATE `test`.`t2` ### UPDATE `test`.`t2`
### WHERE ### WHERE
### @1=12 /* INT meta=0 nullable=0 is_null=0 */ ### @1=12 /* INT meta=0 nullable=0 is_null=0 */
### @5=NULL /* INT meta=0 nullable=1 is_null=1 */
### SET ### SET
### @5=5 /* INT meta=0 nullable=1 is_null=0 */ ### @5=5 /* INT meta=0 nullable=1 is_null=0 */
# at 2119 # at 2111
#<date> server id 1 end_log_pos 2188 Query thread_id=4 exec_time=x error_code=0 #<date> server id 1 end_log_pos 2180 Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/; SET TIMESTAMP=X/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at 2188 # at 2180
#<date> server id 1 end_log_pos 2226 GTID 0-1-9 #<date> server id 1 end_log_pos 2218 GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/; /*!100001 SET @@session.gtid_seq_no=9*//*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at 2226 # at 2218
#<date> server id 1 end_log_pos 2278 Table_map: `test`.`t1` mapped to number 30 #<date> server id 1 end_log_pos 2270 Table_map: `test`.`t1` mapped to number 31
# at 2278 # at 2270
#<date> server id 1 end_log_pos 2328 Delete_rows: table id 30 flags: STMT_END_F #<date> server id 1 end_log_pos 2320 Delete_rows: table id 31 flags: STMT_END_F
### DELETE FROM `test`.`t1` ### DELETE FROM `test`.`t1`
### WHERE ### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */ ### @1=10 /* INT meta=0 nullable=0 is_null=0 */
...@@ -259,20 +256,20 @@ BEGIN ...@@ -259,20 +256,20 @@ BEGIN
### DELETE FROM `test`.`t1` ### DELETE FROM `test`.`t1`
### WHERE ### WHERE
### @1=13 /* INT meta=0 nullable=0 is_null=0 */ ### @1=13 /* INT meta=0 nullable=0 is_null=0 */
# at 2328 # at 2320
#<date> server id 1 end_log_pos 2397 Query thread_id=4 exec_time=x error_code=0 #<date> server id 1 end_log_pos 2389 Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/; SET TIMESTAMP=X/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at 2397 # at 2389
#<date> server id 1 end_log_pos 2435 GTID 0-1-10 #<date> server id 1 end_log_pos 2427 GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/; /*!100001 SET @@session.gtid_seq_no=10*//*!*/;
BEGIN BEGIN
/*!*/; /*!*/;
# at 2435 # at 2427
#<date> server id 1 end_log_pos 2487 Table_map: `test`.`t2` mapped to number 31 #<date> server id 1 end_log_pos 2479 Table_map: `test`.`t2` mapped to number 32
# at 2487 # at 2479
#<date> server id 1 end_log_pos 2537 Delete_rows: table id 31 flags: STMT_END_F #<date> server id 1 end_log_pos 2529 Delete_rows: table id 32 flags: STMT_END_F
### DELETE FROM `test`.`t2` ### DELETE FROM `test`.`t2`
### WHERE ### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */ ### @1=10 /* INT meta=0 nullable=0 is_null=0 */
...@@ -285,13 +282,76 @@ BEGIN ...@@ -285,13 +282,76 @@ BEGIN
### DELETE FROM `test`.`t2` ### DELETE FROM `test`.`t2`
### WHERE ### WHERE
### @1=13 /* INT meta=0 nullable=0 is_null=0 */ ### @1=13 /* INT meta=0 nullable=0 is_null=0 */
# at 2537 # at 2529
#<date> server id 1 end_log_pos 2606 Query thread_id=4 exec_time=x error_code=0 #<date> server id 1 end_log_pos 2598 Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/; SET TIMESTAMP=X/*!*/;
COMMIT COMMIT
/*!*/; /*!*/;
# at 2606 # at 2598
#<date> server id 1 end_log_pos 2650 Rotate to master-bin.000002 pos: 4 #<date> server id 1 end_log_pos 2642 Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
DROP TABLE t1,t2;
CREATE TABLE `t1` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`is_deleted` BIT(1) DEFAULT b'0',
`last_updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`ref_id` BIGINT(20) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
KEY `last_updated_KEY` (`last_updated`)
);
CREATE TABLE `t2` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`short_desc` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO t2 (id, short_desc) VALUES (1, 'test');
INSERT INTO t1 (id, is_deleted, ref_id) VALUES (1, b'0', 1);
FLUSH BINARY LOGS;
UPDATE t1 t1 INNER JOIN t2 t2 ON t1.ref_id = t2.id
SET t1.is_deleted = TRUE
WHERE t1.id = 1;
FLUSH BINARY LOGS;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 368
#<date> server id 1 end_log_pos 406 GTID 0-1-16
/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;
/*!100001 SET @@session.gtid_domain_id=0*//*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=16*//*!*/;
BEGIN
/*!*/;
# at 406
#<date> server id 1 end_log_pos 453 Table_map: `test`.`t1` mapped to number 34
# at 453
#<date> server id 1 end_log_pos 498 Update_rows: table id 34 flags: STMT_END_F
### UPDATE `test`.`t1`
### WHERE
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### SET
### @2=b'1' /* BIT(1) meta=1 nullable=1 is_null=0 */
### @3=X /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */
# at 498
#<date> server id 1 end_log_pos 576 Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=4/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1342177280/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
COMMIT
/*!*/;
# at 576
#<date> server id 1 end_log_pos 620 Rotate to master-bin.000004 pos: 4
DELIMITER ; DELIMITER ;
# End of log file # End of log file
ROLLBACK /* added by mysqlbinlog */; ROLLBACK /* added by mysqlbinlog */;
......
...@@ -4317,12 +4317,12 @@ second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL E ...@@ -4317,12 +4317,12 @@ second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL E
show create event ee1; show create event ee1;
Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation
ee1 UTC CREATE DEFINER=`root`@`localhost` EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci ee1 UTC CREATE DEFINER=`root`@`localhost` EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci
create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5; create event ee2 on schedule at '2030-12-31 21:01:22' do set @a=5;
create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5; create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5;
show events; show events;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
second ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci second ee2 root@localhost UTC ONE TIME 2030-12-31 21:01:22 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
drop database second; drop database second;
create database third; create database third;
...@@ -4330,7 +4330,7 @@ use third; ...@@ -4330,7 +4330,7 @@ use third;
show events; show events;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
third ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci third ee2 root@localhost UTC ONE TIME 2030-12-31 21:01:22 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
drop database third; drop database third;
set time_zone = 'SYSTEM'; set time_zone = 'SYSTEM';
......
...@@ -2646,6 +2646,106 @@ Note 1517 Duplicate partition name p2 ...@@ -2646,6 +2646,106 @@ Note 1517 Duplicate partition name p2
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-17032: Estimates are higher for partitions of a table with @@use_stat_tables= PREFERABLY
#
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(a int);
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
create table t2 (
part_key int,
a int,
b int
) partition by list(part_key) (
partition p0 values in (0),
partition p1 values in (1),
partition p2 values in (2),
partition p3 values in (3),
partition p4 values in (4)
);
insert into t2
select mod(a,5), a/100, mod(a,5) from t1;
set @save_use_stat_tables= @@use_stat_tables;
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
#
# Tests using stats provided by the storage engine
#
explain extended select * from t2 where part_key=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 200 100.00 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`part_key` = 1)
explain partitions select * from t2 where part_key=1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p1 ALL NULL NULL NULL NULL 200 Using where
explain extended select * from t2 where part_key in (1,2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 400 100.00 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`part_key` in (1,2))
explain partitions select * from t2 where part_key in (1,2);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p1,p2 ALL NULL NULL NULL NULL 400 Using where
explain extended select * from t2 where b=5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 100.00 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = 5)
explain partitions select * from t2 where b=5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1000 Using where
explain extended select * from t2 partition(p0) where b=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 200 100.00 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` PARTITION (`p0`) where (`test`.`t2`.`b` = 1)
set @save_histogram_size=@@histogram_size;
set @@histogram_size=100;
set @@use_stat_tables= PREFERABLY;
set @@optimizer_use_condition_selectivity=4;
analyze table t2;
Table Op Msg_type Msg_text
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
#
# Tests using EITS
#
# filtered should be 100
explain extended select * from t2 where part_key=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 200 100.00 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`part_key` = 1)
explain partitions select * from t2 where part_key=1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p1 ALL NULL NULL NULL NULL 200 Using where
# filtered should be 100
explain extended select * from t2 where part_key in (1,2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 400 100.00 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`part_key` in (1,2))
explain partitions select * from t2 where part_key in (1,2);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p1,p2 ALL NULL NULL NULL NULL 400 Using where
explain extended select * from t2 where b=5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 19.80 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where (`test`.`t2`.`b` = 5)
explain partitions select * from t2 where b=5;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1000 Using where
explain extended select * from t2 partition(p0) where b=1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 200 19.80 Using where
Warnings:
Note 1003 select `test`.`t2`.`part_key` AS `part_key`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` PARTITION (`p0`) where (`test`.`t2`.`b` = 1)
set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set @@histogram_size= @save_histogram_size;
drop table t0,t1,t2;
#
# End of 10.0 tests # End of 10.0 tests
# #
# #
......
...@@ -892,3 +892,29 @@ ERROR HY000: Table definition has changed, please retry transaction ...@@ -892,3 +892,29 @@ ERROR HY000: Table definition has changed, please retry transaction
SELECT b FROM t1 WHERE b = 0; SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction ERROR HY000: Table definition has changed, please retry transaction
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-11167: InnoDB: Warning: using a partial-field key prefix
# in search, results in assertion failure or "Can't find record" error
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE TABLE t2 (b INT, c INT, KEY(b)) ENGINE=InnoDB PARTITION BY HASH(c) PARTITIONS 2;
CREATE ALGORITHM = MERGE VIEW v AS SELECT a, b FROM t1 STRAIGHT_JOIN t2 WHERE b = 'foo' WITH CHECK OPTION;
INSERT INTO t1 VALUES (1),(2);
INSERT IGNORE INTO t2 VALUES (2,2),('three',3),(4,4);
Warnings:
Warning 1366 Incorrect integer value: 'three' for column 'b' at row 2
UPDATE v SET a = NULL;
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'foo'
DROP view v;
DROP TABLE t1, t2;
SET @save_isp=@@innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent= ON;
CREATE TABLE t (f1 INT, f2 INT, KEY(f2)) ENGINE=InnoDB PARTITION BY HASH (f1) PARTITIONS 2;
INSERT IGNORE INTO t VALUES (NULL,0),(NULL,0),(0,21),(4,0),(1,8),(5,66);
CREATE ALGORITHM=MERGE VIEW v AS SELECT t1.* FROM t t1 JOIN t t2 WHERE t1.f1 < t2.f2 WITH LOCAL CHECK OPTION;
UPDATE v SET f2 = NULL;
ERROR HY000: CHECK OPTION failed 'test.v'
SET GLOBAL innodb_stats_persistent= @save_isp;
DROP view v;
DROP TABLE t;
...@@ -37,3 +37,45 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -37,3 +37,45 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 1 SIMPLE t0 ALL NULL NULL NULL NULL 10
1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join)
drop table t0,t1,t2; drop table t0,t1,t2;
CREATE TABLE t1 (
pk INT PRIMARY KEY, f1 INT, f2 CHAR(1), f3 CHAR(1),
KEY(f1), KEY(f2)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(1,4,'v',NULL),(2,6,'v',NULL),(3,7,'c',NULL),(4,1,'e',NULL),(5,0,'x',NULL),
(6,7,'i',NULL),(7,7,'e',NULL),(8,1,'p',NULL),(9,7,'s',NULL),(10,1,'j',NULL),
(11,5,'z',NULL),(12,2,'c',NULL),(13,0,'a',NULL),(14,1,'q',NULL),(15,8,'y',NULL),
(16,1,'m',NULL),(17,1,'r',NULL),(18,9,'v',NULL),(19,1,'n',NULL);
CREATE TABLE t2 (f4 INT, f5 CHAR(1)) ENGINE=InnoDB;
INSERT INTO t2 VALUES (4,'q'),(NULL,'j');
SELECT * FROM t1 AS t1_1, t1 AS t1_2, t2
WHERE f5 = t1_2.f2 AND ( t1_1.f1 = 103 AND t1_1.f2 = 'o' OR t1_1.pk < f4 );
pk f1 f2 f3 pk f1 f2 f3 f4 f5
1 4 v NULL 14 1 q NULL 4 q
2 6 v NULL 14 1 q NULL 4 q
3 7 c NULL 14 1 q NULL 4 q
drop table t1,t2;
#
# MDEV-14440: Server crash in in handler::ha_external_lock or Assertion `inited==RND'
# failed in handler::ha_rnd_end upon SELECT from partitioned table
#
set @optimizer_switch_save= @@optimizer_switch;
set optimizer_switch='index_merge_sort_intersection=off';
create table t0 (a int)engine=innodb;
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (
a int, b int, c int,
key(a),key(b),key(c)
)engine=innodb;
insert into t1
select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a
from t0 A, t0 B, t0 C, t0 D where D.a<5;
set @@global.debug_dbug="+d,ha_index_init_fail";
explain select * from t1 where a=10 and b=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
select * from t1 where a=10 and b=10;
ERROR HY000: Table definition has changed, please retry transaction
DROP TABLE t0,t1;
set @@global.debug_dbug="-d";
set @@optimizer_switch= @optimizer_switch_save;
...@@ -168,11 +168,24 @@ flush privileges; ...@@ -168,11 +168,24 @@ flush privileges;
drop database mysqltest_db1; drop database mysqltest_db1;
set global read_only= @start_read_only; set global read_only= @start_read_only;
# #
# MDEV-16987 - ALTER DATABASE possible in read-only mode
#
CREATE USER user1@localhost;
GRANT ALTER ON test1.* TO user1@localhost;
CREATE DATABASE test1;
SET GLOBAL read_only=1;
ALTER DATABASE test1 CHARACTER SET utf8;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
SET GLOBAL read_only=0;
DROP DATABASE test1;
DROP USER user1@localhost;
USE test;
# End of 5.5 tests
#
# WL#5968 Implement START TRANSACTION READ (WRITE|ONLY); # WL#5968 Implement START TRANSACTION READ (WRITE|ONLY);
# #
# #
# Test interaction with read_only system variable. # Test interaction with read_only system variable.
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT); CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1), (2); INSERT INTO t1 VALUES (1), (2);
CREATE USER user1; CREATE USER user1;
...@@ -204,3 +217,4 @@ COMMIT; ...@@ -204,3 +217,4 @@ COMMIT;
DROP USER user1; DROP USER user1;
SET GLOBAL read_only= 0; SET GLOBAL read_only= 0;
DROP TABLE t1; DROP TABLE t1;
# End of 10.0 tests
...@@ -85,3 +85,19 @@ checksum table t1 extended; ...@@ -85,3 +85,19 @@ checksum table t1 extended;
Table Checksum Table Checksum
test.t1 4108368782 test.t1 4108368782
drop table t1; drop table t1;
#
# MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly
#
CREATE TABLE t1 ( c1 int NOT NULL, c2 int NOT NULL, c4 varchar(20), c5 varchar(20), c6 varchar(20), c7 varchar(20), c8 varchar(20), c9 varchar(20), c10 varchar(20), c11 varchar(20), c12 varchar(20), c13 varchar(20), c14 varchar(20), c15 varchar(20), c16 varchar(20), c19 int NOT NULL, c20 int NOT NULL, c21 varchar(20), c22 VARCHAR(20), c23 varchar(20));
insert into t1 values (5,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,"dog",NULL,NULL);
# Important is that checksum is different from following
CHECKSUM TABLE t1 EXTENDED;
Table Checksum
test.t1 2514025256
UPDATE t1 SET c21='cat' WHERE c1=5;
# Important is that checksum is different from above
CHECKSUM TABLE t1 EXTENDED;
Table Checksum
test.t1 2326430205
drop table t1;
# End of 5.5 tests
...@@ -85,3 +85,19 @@ checksum table t1 extended; ...@@ -85,3 +85,19 @@ checksum table t1 extended;
Table Checksum Table Checksum
test.t1 3885665021 test.t1 3885665021
drop table t1; drop table t1;
#
# MDEV-17085: CHECKSUM TABLE EXTENDED does not work correctly
#
CREATE TABLE t1 ( c1 int NOT NULL, c2 int NOT NULL, c4 varchar(20), c5 varchar(20), c6 varchar(20), c7 varchar(20), c8 varchar(20), c9 varchar(20), c10 varchar(20), c11 varchar(20), c12 varchar(20), c13 varchar(20), c14 varchar(20), c15 varchar(20), c16 varchar(20), c19 int NOT NULL, c20 int NOT NULL, c21 varchar(20), c22 VARCHAR(20), c23 varchar(20));
insert into t1 values (5,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,"dog",NULL,NULL);
# Important is that checksum is different from following
CHECKSUM TABLE t1 EXTENDED;
Table Checksum
test.t1 2514025256
UPDATE t1 SET c21='cat' WHERE c1=5;
# Important is that checksum is different from above
CHECKSUM TABLE t1 EXTENDED;
Table Checksum
test.t1 2326430205
drop table t1;
# End of 5.5 tests
...@@ -591,6 +591,25 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -591,6 +591,25 @@ id select_type table type possible_keys key key_len ref rows Extra
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
# #
# MDEV-17734: AddressSanitizer: use-after-poison in create_key_parts_for_pseudo_indexes
#
set @@use_stat_tables= PREFERABLY;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set @@optimizer_use_condition_selectivity=4;
set @save_use_stat_tables= @@use_stat_tables;
create table t1 (a int, b int);
insert into t1(a,b) values (1,2),(1,3),(1,4),(1,5),(2,6),(2,7),(3,8),(3,9),(3,9),(4,10);
analyze table t1 persistent for columns (a) indexes ();
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
select * from t1 where a=1 and b=3;
a b
1 3
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
drop table t1;
#
# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column # MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
# #
SET use_stat_tables= PREFERABLY; SET use_stat_tables= PREFERABLY;
......
...@@ -618,6 +618,25 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -618,6 +618,25 @@ id select_type table type possible_keys key key_len ref rows Extra
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables; set use_stat_tables=@save_use_stat_tables;
# #
# MDEV-17734: AddressSanitizer: use-after-poison in create_key_parts_for_pseudo_indexes
#
set @@use_stat_tables= PREFERABLY;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set @@optimizer_use_condition_selectivity=4;
set @save_use_stat_tables= @@use_stat_tables;
create table t1 (a int, b int);
insert into t1(a,b) values (1,2),(1,3),(1,4),(1,5),(2,6),(2,7),(3,8),(3,9),(3,9),(4,10);
analyze table t1 persistent for columns (a) indexes ();
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
select * from t1 where a=1 and b=3;
a b
1 3
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
drop table t1;
#
# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column # MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
# #
SET use_stat_tables= PREFERABLY; SET use_stat_tables= PREFERABLY;
......
...@@ -394,3 +394,25 @@ select null in (select a from t1 where a < out3.a union select a from t2 where ...@@ -394,3 +394,25 @@ select null in (select a from t1 where a < out3.a union select a from t2 where
(select a from t3) +1 < out3.a+1) from t3 out3; (select a from t3) +1 < out3.a+1) from t3 out3;
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
drop table t1, t2, t3; drop table t1, t2, t3;
CREATE TABLE t1(
q11 int, q12 int, q13 int, q14 int, q15 int, q16 int, q17 int, q18 int, q19 int,
q21 int, q22 int, q23 int, q24 int, q25 int, q26 int, q27 int, q28 int, q29 int,
f1 int
);
CREATE TABLE t2(f2 int, f21 int, f3 timestamp, f4 int, f5 int, f6 int);
INSERT INTO t1 (f1) VALUES (1),(1),(2),(2);
INSERT INTO t2 VALUES (1,1,"2004-02-29 11:11:11",0,0,0), (2,2,"2004-02-29 11:11:11",0,0,0);
SELECT f1,
(SELECT t.f21 from t2 t where max(
q11+q12+q13+q14+q15+q16+q17+q18+q19+
q21+q22+q23+q24+q25+q26+q27+q28+q29) = t.f2 UNION
SELECT t.f3 FROM t2 AS t WHERE t1.f1=t.f2 AND t.f3=MAX(t1.f1) UNION
SELECT 1 LIMIT 1) AS test
FROM t1 GROUP BY f1;
f1 test
1 1
2 1
Warnings:
Warning 1292 Incorrect datetime value: '1'
Warning 1292 Incorrect datetime value: '2'
DROP TABLE t1,t2;
...@@ -330,7 +330,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -330,7 +330,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 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(((1 is not null) and <in_optimizer>(1,1 in ( <materialize> (select `test`.`t3`.`c` from `test`.`t3` where (`test`.`t3`.`c` is not null) ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) 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(((1 is not null) and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) 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 ( 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 ) ) ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1 1
...@@ -344,7 +344,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -344,7 +344,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where 3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2 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(((1 is not null) and <in_optimizer>(1,1 in ( <materialize> (select `test`.`t3`.`c` from `test`.`t3` where (`test`.`t3`.`c` is not null) ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) 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(((1 is not null) and <in_optimizer>(1,1 in (<primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery3>`.`c`))))))))) 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 ( 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 ) ) ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1 1
......
...@@ -2865,6 +2865,22 @@ SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 ); ...@@ -2865,6 +2865,22 @@ SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 );
f f
DROP TABLE t1, t2; DROP TABLE t1, t2;
# #
# MDEV-18255: Server crashes in Bitmap<64u>::intersect
#
create table t1 (v1 varchar(1)) engine=myisam ;
create table t2 (v1 varchar(1)) engine=myisam ;
explain
select 1 from t1 where exists
(select 1 from t1 where t1.v1 in (select t2.v1 from t2 having t2.v1 < 'j')) ;
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 no matching row in const table
3 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
select 1 from t1 where exists
(select 1 from t1 where t1.v1 in (select t2.v1 from t2 having t2.v1 < 'j')) ;
1
drop table t1,t2;
#
# MDEV-9489: Assertion `0' failed in Protocol::end_statement() on # MDEV-9489: Assertion `0' failed in Protocol::end_statement() on
# UNION ALL # UNION ALL
# #
......
...@@ -2121,6 +2121,44 @@ select @advertAcctId as a from dual union all select 1.0 from dual; ...@@ -2121,6 +2121,44 @@ select @advertAcctId as a from dual union all select 1.0 from dual;
a a
1000003.0 1000003.0
1.0 1.0
#
# MDEV-13784: query causes seg fault
#
CREATE TABLE t1 (`bug_id` int NOT NULL PRIMARY KEY, `product_id` int NOT NULL);
INSERT INTO t1 VALUES (45199,1184);
CREATE TABLE t2 (`product_id` int NOT NULL,`userid` int NOT NULL, PRIMARY KEY (`product_id`,`userid`));
INSERT INTO t2 VALUES (1184,103),(1184,624),(1184,1577),(1184,1582);
CREATE TABLE t3 (`id` int NOT NULL PRIMARY KEY,`name` varchar(64));
CREATE TABLE t4 ( `userid` int NOT NULL PRIMARY KEY, `login_name` varchar(255));
INSERT INTO t4 VALUES (103,'foo'),(624,'foo'),(1577,'foo'),(1582,'foo');
CREATE TABLE t5 (`id` int NOT NULL PRIMARY KEY, `name` varchar(64));
explain select
(
select login_name from t4 where userId = (
select userid from t2 where product_id = t1.product_id
union
select userid from t2 where product_id = (
select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 )
) as x from t1 where (t1.bug_id=45199);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
2 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 func 1 Using where
3 SUBQUERY t2 ref PRIMARY PRIMARY 4 const 3 Using index
4 UNION t2 ref PRIMARY PRIMARY 4 func 1 Using where; Using index
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
6 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
select
(
select login_name from t4 where userId = (
select userid from t2 where product_id = t1.product_id
union
select userid from t2 where product_id = (
select id from t5 where name = (select name from t3 where id = t1.product_id)) limit 1 )
) as x from t1 where (t1.bug_id=45199);
x
foo
drop table t1, t2, t3, t4, t5;
End of 5.5 tests End of 5.5 tests
# #
# WL#1763 Avoid creating temporary table in UNION ALL # WL#1763 Avoid creating temporary table in UNION ALL
......
...@@ -4665,7 +4665,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -4665,7 +4665,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: 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 #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL))))))) Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or 1))) having trigcond(<is_not_null_test>(NULL)))))))
SELECT * FROM t1, t2 SELECT * FROM t1, t2
WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a) WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a)
WHERE t4.a >= t1.a); WHERE t4.a >= t1.a);
...@@ -4681,7 +4681,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -4681,7 +4681,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL))))))) Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or 1))) having trigcond(<is_not_null_test>(NULL)))))))
SELECT * FROM v1, t2 SELECT * FROM v1, t2
WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a) WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a)
WHERE t4.a >= v1.a); WHERE t4.a >= v1.a);
......
...@@ -28,6 +28,25 @@ a ...@@ -28,6 +28,25 @@ a
1 1
1 1
3 3
DELETE FROM t1 WHERE a=3;
BINLOG '
ODdYRw8BAAAAZgAAAGoAAAABAAQANS4xLjIzLXJjLWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAA4N1hHEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
';
SET @binlog_fragment_0='
TFtYRxMBAAAAKQAAAH8BAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE=
TFtYRxcBAAAAIgAAAKEBAAAQABAAAAAAAAEAAf/+AwAAAA==
';
SET @binlog_fragment_1='';
BINLOG @binlog_fragment_0, @binlog_fragment_1;
select * from t1;
a
1
1
3
SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL';
@binlog_fragment_0 NULL NULL
NULL NULL NULL
==== Test --base64-output=never on a binlog with row events ==== ==== Test --base64-output=never on a binlog with row events ====
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment