Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä 2021-04-21 07:58:42 +03:00
commit a0588d54a2
33 changed files with 675 additions and 127 deletions

View File

@ -134,6 +134,7 @@ IF(UNIX)
IF(NOT LIBRT) IF(NOT LIBRT)
MY_SEARCH_LIBS(clock_gettime rt LIBRT) MY_SEARCH_LIBS(clock_gettime rt LIBRT)
ENDIF() ENDIF()
set(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads) FIND_PACKAGE(Threads)
SET(CMAKE_REQUIRED_LIBRARIES SET(CMAKE_REQUIRED_LIBRARIES

View File

@ -93,7 +93,7 @@ static void usage()
{ {
version(); version();
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
puts("Prints all arguments that is give to some program using the default files"); puts("Displays the options from option groups of option files, which is useful to see which options a particular tool will use");
printf("Usage: %s [OPTIONS] [groups]\n", my_progname); printf("Usage: %s [OPTIONS] [groups]\n", my_progname);
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_default_files(config_file); my_print_default_files(config_file);

@ -1 +1 @@
Subproject commit fc431a035a21ac1d4ef25d9d3cd8c4d7e64a8ee7 Subproject commit d19c7c69269fdf4e2af8943dd86c12e4e1664afd

View File

@ -1,6 +1,6 @@
'\" t '\" t
.\" .\"
.TH "\FBMYSQLBINLOG\FR" "1" "28 March 2019" "MariaDB 10\&.4" "MariaDB Database System" .TH "\FBMYSQLBINLOG\FR" "1" "14 April 2021" "MariaDB 10\&.4" "MariaDB Database System"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * set default formatting .\" * set default formatting
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
@ -1091,6 +1091,23 @@ This option is useful for point\-in\-time recovery\&.
.sp -1 .sp -1
.IP \(bu 2.3 .IP \(bu 2.3
.\} .\}
.\" mysqlbinlog: table option
.\" table option: mysqlbinlog
\fB\-\-table\fR,
\fB\-T\fR
.sp
List entries for just this table (local log only)\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysqlbinlog: to-last-log option .\" mysqlbinlog: to-last-log option
.\" to-last-log option: mysqlbinlog .\" to-last-log option: mysqlbinlog
\fB\-\-to\-last\-log\fR, \fB\-\-to\-last\-log\fR,
@ -2107,7 +2124,7 @@ option can be used to prevent this header from being written\&.
.SH "COPYRIGHT" .SH "COPYRIGHT"
.br .br
.PP .PP
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc., 2010-2015 MariaDB Foundation Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc., 2010-2021 MariaDB Foundation
.PP .PP
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
.PP .PP

View File

@ -2529,6 +2529,23 @@ ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `k1` ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `k1`
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-25403 ALTER TABLE wrongly checks for field's default value if AFTER is used
#
create table t1(t int, d date not null);
insert into t1 values (1,'2001-1-1');
set sql_mode = "no_zero_date";
alter table t1 change d d date not null after t, add i int;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` int(11) DEFAULT NULL,
`d` date NOT NULL,
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 add x date not null;
ERROR 22007: Incorrect date value: '0000-00-00' for column `test`.`t1`.`x` at row 1
drop table t1;
#
# End of 10.2 tests # End of 10.2 tests
# #
# #

View File

@ -2050,6 +2050,18 @@ CREATE TABLE t2 (i1 int);
ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1); ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # MDEV-25403 ALTER TABLE wrongly checks for field's default value if AFTER is used
--echo #
create table t1(t int, d date not null);
insert into t1 values (1,'2001-1-1');
set sql_mode = "no_zero_date";
alter table t1 change d d date not null after t, add i int;
show create table t1;
--error ER_TRUNCATED_WRONG_VALUE
alter table t1 add x date not null;
drop table t1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #

View File

@ -2687,6 +2687,77 @@ id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
# end of 10.1 tests # end of 10.1 tests
# #
# MDEV-25362: name resolution for subqueries in ON expressions
#
create table t1 (a int, b int);
create table t2 (c int, d int);
create table t3 (e int, f int);
create table t4 (g int, h int);
explain
select *
from
t1 left join
(t2
join
t3 on
(t3.f=t1.a)
) on (t2.c=t1.a );
ERROR 42S22: Unknown column 't1.a' in 'on clause'
explain
select *
from
t1 left join
(t2
join
t3 on
(t3.f=(select max(g) from t4 where t4.h=t1.a))
) on (t2.c=t1.a );
ERROR 42S22: Unknown column 't1.a' in 'where clause'
drop table t1,t2,t3,t4;
create table t1 (a int);
insert into t1 values (1),(2);
create table t2 (b int);
insert into t2 values (1),(2);
create table t3 (c int);
insert into t3 values (1),(2);
select * from ( select * from t1 left join t2
on b in (select x from t3 as sq1)
) as sq2;
ERROR 42S22: Unknown column 'x' in 'field list'
drop table t1,t2,t3;
# end of 10.2 tests
#
# MDEV-22866: Crash in join optimizer with constant outer join nest
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
INSERT INTO t4 VALUES (5),(6);
CREATE TABLE t5 (e INT) ENGINE=MyISAM;
INSERT INTO t5 VALUES (7),(8);
CREATE TABLE t6 (f INT) ENGINE=MyISAM;
INSERT INTO t6 VALUES (9),(10);
SELECT *
FROM
t1
LEFT JOIN (
t2 LEFT JOIN (
t3 JOIN
t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
) ON t2.b >= t4.d
) ON t1.a <= t2.b
LEFT JOIN t5 ON t2.b = t5.e
LEFT JOIN t6 ON t3.c = t6.f;
a b c d e f
1 3 NULL NULL NULL NULL
1 4 NULL NULL NULL NULL
2 3 NULL NULL NULL NULL
2 4 NULL NULL NULL NULL
drop table t1,t2,t3,t4,t5,t6;
#
# MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins # MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
# #
create table t1(a int); create table t1(a int);
@ -2754,35 +2825,5 @@ WHERE t3.pk IN (2);
1 1
drop view v4; drop view v4;
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
# end of 10.3 tests
SET optimizer_switch=@org_optimizer_switch; SET optimizer_switch=@org_optimizer_switch;
#
# MDEV-22866: Crash in join optimizer with constant outer join nest
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
INSERT INTO t4 VALUES (5),(6);
CREATE TABLE t5 (e INT) ENGINE=MyISAM;
INSERT INTO t5 VALUES (7),(8);
CREATE TABLE t6 (f INT) ENGINE=MyISAM;
INSERT INTO t6 VALUES (9),(10);
SELECT *
FROM
t1
LEFT JOIN (
t2 LEFT JOIN (
t3 JOIN
t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
) ON t2.b >= t4.d
) ON t1.a <= t2.b
LEFT JOIN t5 ON t2.b = t5.e
LEFT JOIN t6 ON t3.c = t6.f;
a b c d e f
1 3 NULL NULL NULL NULL
2 3 NULL NULL NULL NULL
1 4 NULL NULL NULL NULL
2 4 NULL NULL NULL NULL
drop table t1,t2,t3,t4,t5,t6;

View File

@ -2191,6 +2191,91 @@ DROP TABLE t1,t2,t3,t4;
--echo # end of 10.1 tests --echo # end of 10.1 tests
--echo #
--echo # MDEV-25362: name resolution for subqueries in ON expressions
--echo #
create table t1 (a int, b int);
create table t2 (c int, d int);
create table t3 (e int, f int);
create table t4 (g int, h int);
--error ER_BAD_FIELD_ERROR
explain
select *
from
t1 left join
(t2
join
t3 on
(t3.f=t1.a)
) on (t2.c=t1.a );
# This must produce an error:
--error ER_BAD_FIELD_ERROR
explain
select *
from
t1 left join
(t2
join
t3 on
(t3.f=(select max(g) from t4 where t4.h=t1.a))
) on (t2.c=t1.a );
drop table t1,t2,t3,t4;
create table t1 (a int);
insert into t1 values (1),(2);
create table t2 (b int);
insert into t2 values (1),(2);
create table t3 (c int);
insert into t3 values (1),(2);
--error ER_BAD_FIELD_ERROR
select * from ( select * from t1 left join t2
on b in (select x from t3 as sq1)
) as sq2;
drop table t1,t2,t3;
--echo # end of 10.2 tests
--echo #
--echo # MDEV-22866: Crash in join optimizer with constant outer join nest
--echo #
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
INSERT INTO t4 VALUES (5),(6);
CREATE TABLE t5 (e INT) ENGINE=MyISAM;
INSERT INTO t5 VALUES (7),(8);
CREATE TABLE t6 (f INT) ENGINE=MyISAM;
INSERT INTO t6 VALUES (9),(10);
SELECT *
FROM
t1
LEFT JOIN (
t2 LEFT JOIN (
t3 JOIN
t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
) ON t2.b >= t4.d
) ON t1.a <= t2.b
LEFT JOIN t5 ON t2.b = t5.e
LEFT JOIN t6 ON t3.c = t6.f;
drop table t1,t2,t3,t4,t5,t6;
--echo # --echo #
--echo # MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins --echo # MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
--echo # --echo #
@ -2251,39 +2336,6 @@ WHERE t3.pk IN (2);
drop view v4; drop view v4;
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
--echo # end of 10.3 tests
SET optimizer_switch=@org_optimizer_switch; SET optimizer_switch=@org_optimizer_switch;
--echo #
--echo # MDEV-22866: Crash in join optimizer with constant outer join nest
--echo #
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
INSERT INTO t4 VALUES (5),(6);
CREATE TABLE t5 (e INT) ENGINE=MyISAM;
INSERT INTO t5 VALUES (7),(8);
CREATE TABLE t6 (f INT) ENGINE=MyISAM;
INSERT INTO t6 VALUES (9),(10);
SELECT *
FROM
t1
LEFT JOIN (
t2 LEFT JOIN (
t3 JOIN
t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
) ON t2.b >= t4.d
) ON t1.a <= t2.b
LEFT JOIN t5 ON t2.b = t5.e
LEFT JOIN t6 ON t3.c = t6.f;
drop table t1,t2,t3,t4,t5,t6;

View File

@ -2694,6 +2694,77 @@ id timestamp modifiedBy id REV REVTYPE profile_id id REV person_id id REV
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
# end of 10.1 tests # end of 10.1 tests
# #
# MDEV-25362: name resolution for subqueries in ON expressions
#
create table t1 (a int, b int);
create table t2 (c int, d int);
create table t3 (e int, f int);
create table t4 (g int, h int);
explain
select *
from
t1 left join
(t2
join
t3 on
(t3.f=t1.a)
) on (t2.c=t1.a );
ERROR 42S22: Unknown column 't1.a' in 'on clause'
explain
select *
from
t1 left join
(t2
join
t3 on
(t3.f=(select max(g) from t4 where t4.h=t1.a))
) on (t2.c=t1.a );
ERROR 42S22: Unknown column 't1.a' in 'where clause'
drop table t1,t2,t3,t4;
create table t1 (a int);
insert into t1 values (1),(2);
create table t2 (b int);
insert into t2 values (1),(2);
create table t3 (c int);
insert into t3 values (1),(2);
select * from ( select * from t1 left join t2
on b in (select x from t3 as sq1)
) as sq2;
ERROR 42S22: Unknown column 'x' in 'field list'
drop table t1,t2,t3;
# end of 10.2 tests
#
# MDEV-22866: Crash in join optimizer with constant outer join nest
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
INSERT INTO t4 VALUES (5),(6);
CREATE TABLE t5 (e INT) ENGINE=MyISAM;
INSERT INTO t5 VALUES (7),(8);
CREATE TABLE t6 (f INT) ENGINE=MyISAM;
INSERT INTO t6 VALUES (9),(10);
SELECT *
FROM
t1
LEFT JOIN (
t2 LEFT JOIN (
t3 JOIN
t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
) ON t2.b >= t4.d
) ON t1.a <= t2.b
LEFT JOIN t5 ON t2.b = t5.e
LEFT JOIN t6 ON t3.c = t6.f;
a b c d e f
1 3 NULL NULL NULL NULL
2 3 NULL NULL NULL NULL
1 4 NULL NULL NULL NULL
2 4 NULL NULL NULL NULL
drop table t1,t2,t3,t4,t5,t6;
#
# MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins # MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
# #
create table t1(a int); create table t1(a int);
@ -2761,35 +2832,5 @@ WHERE t3.pk IN (2);
1 1
drop view v4; drop view v4;
drop table t1,t2,t3,t4; drop table t1,t2,t3,t4;
# end of 10.3 tests
SET optimizer_switch=@org_optimizer_switch; SET optimizer_switch=@org_optimizer_switch;
#
# MDEV-22866: Crash in join optimizer with constant outer join nest
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c INT, KEY(c)) ENGINE=MyISAM;
CREATE TABLE t4 (d INT, KEY(d)) ENGINE=MyISAM;
INSERT INTO t4 VALUES (5),(6);
CREATE TABLE t5 (e INT) ENGINE=MyISAM;
INSERT INTO t5 VALUES (7),(8);
CREATE TABLE t6 (f INT) ENGINE=MyISAM;
INSERT INTO t6 VALUES (9),(10);
SELECT *
FROM
t1
LEFT JOIN (
t2 LEFT JOIN (
t3 JOIN
t4 ON t3.c = t4.d and t3.c >2 and t3.c<0
) ON t2.b >= t4.d
) ON t1.a <= t2.b
LEFT JOIN t5 ON t2.b = t5.e
LEFT JOIN t6 ON t3.c = t6.f;
a b c d e f
1 3 NULL NULL NULL NULL
2 3 NULL NULL NULL NULL
1 4 NULL NULL NULL NULL
2 4 NULL NULL NULL NULL
drop table t1,t2,t3,t4,t5,t6;

View File

@ -1102,4 +1102,22 @@ U5.`storage_target_id` = V0.`id`
); );
id id
drop table t1,t2,t3; drop table t1,t2,t3;
#
# MDEV-25407: EXISTS subquery with correlation in ON expression crashes
#
create table t10(a int primary key);
insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t11(a int primary key);
insert into t11 select a.a + b.a* 10 + c.a * 100 from t10 a, t10 b, t10 c;
create table t1 (a int, b int);
insert into t1 select a,a from t10;
create table t2 (a int, b int);
insert into t2 select a,a from t11;
create table t3 as select * from t2;
explain select * from t1 where exists (select t2.a from t2 left join t3 on (t3.b=t1.b) where t2.a=t1.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10
1 PRIMARY t2 ALL NULL NULL NULL NULL 1000 Using where; Start temporary; Using join buffer (flat, BNL join)
1 PRIMARY t3 ALL NULL NULL NULL NULL 1000 Using where; End temporary; Using join buffer (incremental, BNL join)
drop table t1, t2, t3, t10, t11;
set optimizer_switch=default; set optimizer_switch=default;

View File

@ -941,5 +941,28 @@ WHERE (
drop table t1,t2,t3; drop table t1,t2,t3;
--echo #
--echo # MDEV-25407: EXISTS subquery with correlation in ON expression crashes
--echo #
create table t10(a int primary key);
insert into t10 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t11(a int primary key);
insert into t11 select a.a + b.a* 10 + c.a * 100 from t10 a, t10 b, t10 c;
create table t1 (a int, b int);
insert into t1 select a,a from t10;
create table t2 (a int, b int);
insert into t2 select a,a from t11;
create table t3 as select * from t2;
explain select * from t1 where exists (select t2.a from t2 left join t3 on (t3.b=t1.b) where t2.a=t1.a);
drop table t1, t2, t3, t10, t11;
#restore defaults #restore defaults
set optimizer_switch=default; set optimizer_switch=default;

View File

@ -50,3 +50,4 @@ a
400 400
401 401
drop table t1; drop table t1;
reset master;

View File

@ -10,3 +10,4 @@ disable_query_log;
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
enable_query_log; enable_query_log;
-- source include/binlog_insert_delayed.test -- source include/binlog_insert_delayed.test
reset master;

View File

@ -678,3 +678,99 @@ SET FOREIGN_KEY_CHECKS = 0;
CREATE TEMPORARY TABLE t1(f1 INT NOT NULL, CREATE TEMPORARY TABLE t1(f1 INT NOT NULL,
FOREIGN KEY(f1) REFERENCES t0(f1))ENGINE=InnoDB; FOREIGN KEY(f1) REFERENCES t0(f1))ENGINE=InnoDB;
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed") ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
CREATE TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t VALUES(0);
CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t2 SELECT * FROM t;
COMMIT;
DROP TABLE t, t2;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t VALUES(0);
ERROR 21S01: Column count doesn't match value count at row 1
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
COMMIT;
DROP TABLE t;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t VALUES(0);
ERROR 21S01: Column count doesn't match value count at row 1
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
ROLLBACK;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t(c INT) ENGINE=InnoDB;
SET SESSION tx_read_only=TRUE;
LOCK TABLE test.t READ;
SELECT * FROM t;
c
INSERT INTO t VALUES(0xADC3);
SET SESSION tx_read_only=FALSE;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1);
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int, c varchar(255)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1, repeat('a', 200));
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2, c=repeat('a', 250);
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
ROLLBACK;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
DELETE FROM t1 WHERE a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE tmp (a INT) ENGINE=InnoDB;
INSERT INTO tmp () VALUES (),();
SET TX_READ_ONLY= 1;
INSERT INTO tmp SELECT * FROM tmp;
SET TX_READ_ONLY= 0;
DROP TABLE tmp;
SET sql_mode='';
SET GLOBAL tx_read_only=TRUE;
CREATE TEMPORARY TABLE t (c INT);
SET SESSION tx_read_only=DEFAULT;
INSERT INTO t VALUES(1);
INSERT INTO t SELECT * FROM t;
SET SESSION tx_read_only=FALSE;
SET GLOBAL tx_read_only=OFF;
DROP TABLE t;
CREATE TEMPORARY TABLE t(a INT);
SET SESSION tx_read_only=ON;
LOCK TABLE t READ;
SELECT COUNT(*)FROM t;
COUNT(*)
0
INSERT INTO t VALUES (0);
SET SESSION tx_read_only=OFF;
DROP TABLE t;
CREATE TEMPORARY TABLE t (a INT) ENGINE=InnoDB;
INSERT INTO t VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t SET a = NULL;
ROLLBACK;

View File

@ -502,3 +502,110 @@ SET FOREIGN_KEY_CHECKS = 0;
--error ER_CANT_CREATE_TABLE --error ER_CANT_CREATE_TABLE
CREATE TEMPORARY TABLE t1(f1 INT NOT NULL, CREATE TEMPORARY TABLE t1(f1 INT NOT NULL,
FOREIGN KEY(f1) REFERENCES t0(f1))ENGINE=InnoDB; FOREIGN KEY(f1) REFERENCES t0(f1))ENGINE=InnoDB;
CREATE TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t VALUES(0);
CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t2 SELECT * FROM t;
COMMIT;
DROP TABLE t, t2;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t VALUES(0);
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
COMMIT;
DROP TABLE t;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t VALUES(0);
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
ROLLBACK;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t(c INT) ENGINE=InnoDB;
SET SESSION tx_read_only=TRUE;
LOCK TABLE test.t READ;
SELECT * FROM t;
INSERT INTO t VALUES(0xADC3);
SET SESSION tx_read_only=FALSE;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1);
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int, c varchar(255)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1, repeat('a', 200));
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2, c=repeat('a', 250);
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
ROLLBACK;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
DELETE FROM t1 WHERE a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE tmp (a INT) ENGINE=InnoDB;
INSERT INTO tmp () VALUES (),();
SET TX_READ_ONLY= 1;
INSERT INTO tmp SELECT * FROM tmp;
SET TX_READ_ONLY= 0;
DROP TABLE tmp;
SET sql_mode='';
SET GLOBAL tx_read_only=TRUE;
CREATE TEMPORARY TABLE t (c INT);
SET SESSION tx_read_only=DEFAULT;
INSERT INTO t VALUES(1);
INSERT INTO t SELECT * FROM t;
SET SESSION tx_read_only=FALSE;
SET GLOBAL tx_read_only=OFF;
DROP TABLE t;
CREATE TEMPORARY TABLE t(a INT);
SET SESSION tx_read_only=ON;
LOCK TABLE t READ;
SELECT COUNT(*)FROM t;
INSERT INTO t VALUES (0);
SET SESSION tx_read_only=OFF;
DROP TABLE t;
CREATE TEMPORARY TABLE t (a INT) ENGINE=InnoDB;
INSERT INTO t VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t SET a = NULL;
ROLLBACK;

View File

@ -745,3 +745,20 @@ create or replace table t1 (x int);
alter table t1 add column y timestamp(6) as row start; alter table t1 add column y timestamp(6) as row start;
ERROR HY000: Table `t1` is not system-versioned ERROR HY000: Table `t1` is not system-versioned
drop table t1; drop table t1;
#
# MDEV-25327 Unexpected ER_DUP_ENTRY upon dropping PK column from system-versioned table
#
create table t1 (pk int, a int, primary key (pk), key (a))
with system versioning;
insert into t1 values (1, 1), (2, 2);
delete from t1;
set system_versioning_alter_history= keep;
alter table t1 drop pk;
drop table t1;
create table t1 (pk int, a int, primary key (pk), key (a))
with system versioning;
insert into t1 values (1, 2), (2, 8), (3, 4), (4, 4), (5, 0);
delete from t1;
set system_versioning_alter_history= keep;
alter ignore table t1 drop pk;
drop table t1;

View File

@ -631,3 +631,25 @@ create or replace table t1 (x int);
alter table t1 add column y timestamp(6) as row start; alter table t1 add column y timestamp(6) as row start;
# cleanup # cleanup
drop table t1; drop table t1;
--echo #
--echo # MDEV-25327 Unexpected ER_DUP_ENTRY upon dropping PK column from system-versioned table
--echo #
create table t1 (pk int, a int, primary key (pk), key (a))
with system versioning;
insert into t1 values (1, 1), (2, 2);
delete from t1;
set system_versioning_alter_history= keep;
alter table t1 drop pk;
# cleanup
drop table t1;
create table t1 (pk int, a int, primary key (pk), key (a))
with system versioning;
insert into t1 values (1, 2), (2, 8), (3, 4), (4, 4), (5, 0);
delete from t1;
set system_versioning_alter_history= keep;
alter ignore table t1 drop pk;
# cleanup
drop table t1;

View File

@ -1612,7 +1612,7 @@ int _my_b_async_read(IO_CACHE *info, uchar *Buffer, size_t Count)
Buffer+=length; Buffer+=length;
Count-=length; Count-=length;
left_length+=length; left_length+=length;
info->read_end=info->rc_pos+read_length; info->read_end=info->read_pos+read_length;
info->read_pos+=length; info->read_pos+=length;
} }
else else

View File

@ -683,6 +683,31 @@ bool Item_subselect::is_expensive()
} }
static
int walk_items_for_table_list(Item_processor processor,
bool walk_subquery, void *argument,
List<TABLE_LIST>& join_list)
{
List_iterator<TABLE_LIST> li(join_list);
int res;
while (TABLE_LIST *table= li++)
{
if (table->on_expr)
{
if ((res= table->on_expr->walk(processor, walk_subquery, argument)))
return res;
}
if (table->nested_join)
{
if ((res= walk_items_for_table_list(processor, walk_subquery, argument,
table->nested_join->join_list)))
return res;
}
}
return 0;
}
bool Item_subselect::walk(Item_processor processor, bool walk_subquery, bool Item_subselect::walk(Item_processor processor, bool walk_subquery,
void *argument) void *argument)
{ {
@ -714,7 +739,10 @@ bool Item_subselect::walk(Item_processor processor, bool walk_subquery,
if (lex->having && (lex->having)->walk(processor, walk_subquery, if (lex->having && (lex->having)->walk(processor, walk_subquery,
argument)) argument))
return 1; return 1;
/* TODO: why does this walk WHERE/HAVING but not ON expressions of outer joins? */
if (walk_items_for_table_list(processor, walk_subquery, argument,
*lex->join_list))
return 1;
while ((item=li++)) while ((item=li++))
{ {

View File

@ -26,7 +26,7 @@
Used instead of FILE when reading or writing whole files. Used instead of FILE when reading or writing whole files.
This will make mf_rec_cache obsolete. This will make mf_rec_cache obsolete.
One can change info->pos_in_file to a higher value to skip bytes in file if One can change info->pos_in_file to a higher value to skip bytes in file if
also info->rc_pos is set to info->rc_end. also info->read_pos is set to info->read_end.
If called through open_cached_file(), then the temporary file will If called through open_cached_file(), then the temporary file will
only be created if a write exeeds the file buffer or if one calls only be created if a write exeeds the file buffer or if one calls
flush_io_cache(). flush_io_cache().

View File

@ -32,7 +32,7 @@
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
@ -57,7 +57,7 @@ extern const char *optimizer_switch_names[];
static inline void output_core_info() static inline void output_core_info()
{ {
/* proc is optional on some BSDs so it can't hurt to look */ /* proc is optional on some BSDs so it can't hurt to look */
#if defined(HAVE_READLINK) && !defined(__APPLE__) #if defined(HAVE_READLINK) && !defined(__APPLE__) && !defined(__FreeBSD__)
char buff[PATH_MAX]; char buff[PATH_MAX];
ssize_t len; ssize_t len;
int fd; int fd;
@ -83,7 +83,7 @@ static inline void output_core_info()
my_close(fd, MYF(0)); my_close(fd, MYF(0));
} }
#endif #endif
#elif defined(__APPLE__) #elif defined(__APPLE__) || defined(__FreeBSD__)
char buff[PATH_MAX]; char buff[PATH_MAX];
size_t len = sizeof(buff); size_t len = sizeof(buff);
if (sysctlbyname("kern.corefile", buff, &len, NULL, 0) == 0) if (sysctlbyname("kern.corefile", buff, &len, NULL, 0) == 0)

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2002, 2011, Oracle and/or its affiliates. Copyright (c) 2002, 2011, Oracle and/or its affiliates.
Copyright (c) 2010, 2020, MariaDB Copyright (c) 2010, 2021, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -596,6 +596,32 @@ bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived)
} }
/**
@brief
Prevent name resolution out of context of ON expressions in derived tables
@param
join_list list of tables used in from list of a derived
@details
The function sets the Name_resolution_context::outer_context to NULL
for all ON expressions contexts in the given join list. It does this
recursively for all nested joins the list contains.
*/
static void nullify_outer_context_for_on_clauses(List<TABLE_LIST>& join_list)
{
List_iterator<TABLE_LIST> li(join_list);
while (TABLE_LIST *table= li++)
{
if (table->on_context)
table->on_context->outer_context= NULL;
if (table->nested_join)
nullify_outer_context_for_on_clauses(table->nested_join->join_list);
}
}
/* /*
Create temporary table structure (but do not fill it) Create temporary table structure (but do not fill it)
@ -760,7 +786,12 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
/* prevent name resolving out of derived table */ /* prevent name resolving out of derived table */
for (SELECT_LEX *sl= first_select; sl; sl= sl->next_select()) for (SELECT_LEX *sl= first_select; sl; sl= sl->next_select())
{ {
// Prevent it for the WHERE clause
sl->context.outer_context= 0; sl->context.outer_context= 0;
// And for ON clauses, if there are any
nullify_outer_context_for_on_clauses(*sl->join_list);
if (!derived->is_with_table_recursive_reference() || if (!derived->is_with_table_recursive_reference() ||
(!derived->with->with_anchor && (!derived->with->with_anchor &&
!derived->with->is_with_prepared_anchor())) !derived->with->is_with_prepared_anchor()))

View File

@ -9392,7 +9392,7 @@ SELECT_LEX *LEX::parsed_subselect(SELECT_LEX_UNIT *unit)
(curr_sel == NULL && current_select == &builtin_select)); (curr_sel == NULL && current_select == &builtin_select));
if (curr_sel) if (curr_sel)
{ {
curr_sel->register_unit(unit, &curr_sel->context); curr_sel->register_unit(unit, context_stack.head());
curr_sel->add_statistics(unit); curr_sel->add_statistics(unit);
} }

View File

@ -7607,6 +7607,7 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
bool new_select= select_lex == NULL; bool new_select= select_lex == NULL;
int old_nest_level= lex->current_select->nest_level; int old_nest_level= lex->current_select->nest_level;
DBUG_ENTER("mysql_new_select"); DBUG_ENTER("mysql_new_select");
Name_resolution_context *curr_context;
if (new_select) if (new_select)
{ {
@ -7614,6 +7615,7 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
DBUG_RETURN(1); DBUG_RETURN(1);
select_lex->select_number= ++thd->lex->stmt_lex->current_select_number; select_lex->select_number= ++thd->lex->stmt_lex->current_select_number;
select_lex->parent_lex= lex; /* Used in init_query. */ select_lex->parent_lex= lex; /* Used in init_query. */
curr_context= lex->context_stack.head();
select_lex->init_query(); select_lex->init_query();
select_lex->init_select(); select_lex->init_select();
} }
@ -7635,7 +7637,8 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
By default we assume that it is usual subselect and we have outer name By default we assume that it is usual subselect and we have outer name
resolution context, if no we will assign it to 0 later resolution context, if no we will assign it to 0 later
*/ */
select_lex->context.outer_context= &select_lex->outer_select()->context;
select_lex->context.outer_context= curr_context;
} }
else else
{ {

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2019, Oracle and/or its affiliates. Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2010, 2020, MariaDB Copyright (c) 2010, 2021, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -8318,7 +8318,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
def->real_field_type() == MYSQL_TYPE_NEWDATE || def->real_field_type() == MYSQL_TYPE_NEWDATE ||
def->real_field_type() == MYSQL_TYPE_DATETIME || def->real_field_type() == MYSQL_TYPE_DATETIME ||
def->real_field_type() == MYSQL_TYPE_DATETIME2) && def->real_field_type() == MYSQL_TYPE_DATETIME2) &&
!alter_ctx->datetime_field && !alter_ctx->datetime_field && !def->field &&
!(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) && !(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) &&
thd->variables.sql_mode & MODE_NO_ZERO_DATE) thd->variables.sql_mode & MODE_NO_ZERO_DATE)
{ {
@ -8527,7 +8527,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_parts.push_back(new (thd->mem_root) Key_part_spec(&cfield->field_name, key_parts.push_back(new (thd->mem_root) Key_part_spec(&cfield->field_name,
key_part_length, true), key_part_length, true),
thd->mem_root); thd->mem_root);
if (cfield->invisible < INVISIBLE_SYSTEM) if (!(cfield->invisible == INVISIBLE_SYSTEM && cfield->vers_sys_field()))
user_keyparts= true; user_keyparts= true;
} }
if (table->s->tmp_table == NO_TMP_TABLE) if (table->s->tmp_table == NO_TMP_TABLE)
@ -8539,6 +8539,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
(void) delete_statistics_for_index(thd, table, key_info, TRUE); (void) delete_statistics_for_index(thd, table, key_info, TRUE);
} }
if (!user_keyparts && key_parts.elements)
{
/*
If we dropped all user key-parts we also drop implicit system fields.
*/
key_parts.empty();
}
if (key_parts.elements) if (key_parts.elements)
{ {
KEY_CREATE_INFO key_create_info; KEY_CREATE_INFO key_create_info;
@ -8574,7 +8582,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_type= Key::PRIMARY; key_type= Key::PRIMARY;
else else
key_type= Key::UNIQUE; key_type= Key::UNIQUE;
if (dropped_key_part && user_keyparts) if (dropped_key_part)
{ {
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), dropped_key_part); my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), dropped_key_part);
if (long_hash_key) if (long_hash_key)

View File

@ -3598,7 +3598,8 @@ fail_err:
ut_ad(thr->graph->trx->id ut_ad(thr->graph->trx->id
== trx_read_trx_id( == trx_read_trx_id(
static_cast<const byte*>( static_cast<const byte*>(
trx_id->data))); trx_id->data))
|| index->table->is_temporary());
} }
} }
#endif #endif
@ -4260,7 +4261,8 @@ btr_cur_update_in_place(
index = cursor->index; index = cursor->index;
ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
|| index->table->is_temporary());
/* The insert buffer tree should never be updated in place. */ /* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG)
@ -4561,7 +4563,8 @@ btr_cur_optimistic_update(
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
index = cursor->index; index = cursor->index;
ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
|| index->table->is_temporary());
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
/* This is intended only for leaf page updates */ /* This is intended only for leaf page updates */
@ -4918,8 +4921,8 @@ btr_cur_pessimistic_update(
ut_ad(!page_zip || !index->table->is_temporary()); ut_ad(!page_zip || !index->table->is_temporary());
/* The insert buffer tree should never be updated in place. */ /* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
ut_ad(trx_id > 0 ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
|| (flags & BTR_KEEP_SYS_FLAG)); || index->table->is_temporary());
ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG)
|| dict_index_is_clust(index)); || dict_index_is_clust(index));
ut_ad(thr_get_trx(thr)->id == trx_id ut_ad(thr_get_trx(thr)->id == trx_id

View File

@ -6195,8 +6195,10 @@ ha_innobase::open(const char* name, int, uint)
innobase_copy_frm_flags_from_table_share(ib_table, table->s); innobase_copy_frm_flags_from_table_share(ib_table, table->s);
/* No point to init any statistics if tablespace is still encrypted. */ /* No point to init any statistics if tablespace is still encrypted
if (ib_table->is_readable()) { or if table is being opened by background thread */
if (THDVAR(thd, background_thread)) {
} else if (ib_table->is_readable()) {
dict_stats_init(ib_table); dict_stats_init(ib_table);
} else { } else {
ib_table->stat_initialized = 1; ib_table->stat_initialized = 1;

View File

@ -89,7 +89,6 @@ void
trx_write_trx_id(byte* db_trx_id, trx_id_t id) trx_write_trx_id(byte* db_trx_id, trx_id_t id)
{ {
compile_time_assert(DATA_TRX_ID_LEN == 6); compile_time_assert(DATA_TRX_ID_LEN == 6);
ut_ad(id);
mach_write_to_6(db_trx_id, id); mach_write_to_6(db_trx_id, id);
} }

View File

@ -1219,6 +1219,7 @@ pars_update_statement(
sel_node->row_lock_mode = LOCK_X; sel_node->row_lock_mode = LOCK_X;
} else { } else {
node->has_clust_rec_x_lock = sel_node->set_x_locks; node->has_clust_rec_x_lock = sel_node->set_x_locks;
ut_ad(node->has_clust_rec_x_lock);
} }
ut_a(sel_node->n_tables == 1); ut_a(sel_node->n_tables == 1);

View File

@ -3332,7 +3332,8 @@ row_ins_index_entry(
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr) /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
{ {
ut_ad(thr_get_trx(thr)->id || index->table->no_rollback()); ut_ad(thr_get_trx(thr)->id || index->table->no_rollback()
|| index->table->is_temporary());
DBUG_EXECUTE_IF("row_ins_index_entry_timeout", { DBUG_EXECUTE_IF("row_ins_index_entry_timeout", {
DBUG_SET("-d,row_ins_index_entry_timeout"); DBUG_SET("-d,row_ins_index_entry_timeout");
@ -3760,13 +3761,17 @@ row_ins_step(
} }
if (UNIV_LIKELY(!node->table->skip_alter_undo)) { if (UNIV_LIKELY(!node->table->skip_alter_undo)) {
trx_write_trx_id(&node->sys_buf[DATA_ROW_ID_LEN], trx->id); trx_write_trx_id(&node->sys_buf[DATA_TRX_ID_LEN], trx->id);
} }
if (node->state == INS_NODE_SET_IX_LOCK) { if (node->state == INS_NODE_SET_IX_LOCK) {
node->state = INS_NODE_ALLOC_ROW_ID; node->state = INS_NODE_ALLOC_ROW_ID;
if (node->table->is_temporary()) {
node->trx_id = trx->id;
}
/* It may be that the current session has not yet started /* It may be that the current session has not yet started
its transaction, or it has been committed: */ its transaction, or it has been committed: */

View File

@ -111,7 +111,8 @@ row_undo_ins_remove_clust_rec(
rec_t* rec = btr_pcur_get_rec(&node->pcur); rec_t* rec = btr_pcur_get_rec(&node->pcur);
ut_ad(rec_get_trx_id(rec, index) == node->trx->id); ut_ad(rec_get_trx_id(rec, index) == node->trx->id
|| node->table->is_temporary());
ut_ad(!rec_get_deleted_flag(rec, index->table->not_redundant()) ut_ad(!rec_get_deleted_flag(rec, index->table->not_redundant())
|| rec_is_alter_metadata(rec, index->table->not_redundant())); || rec_is_alter_metadata(rec, index->table->not_redundant()));
ut_ad(rec_is_metadata(rec, index->table->not_redundant()) ut_ad(rec_is_metadata(rec, index->table->not_redundant())

View File

@ -110,7 +110,8 @@ row_undo_mod_clust_low(
ut_ad(success); ut_ad(success);
ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur), ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur),
btr_cur_get_index(btr_cur)) btr_cur_get_index(btr_cur))
== thr_get_trx(thr)->id); == thr_get_trx(thr)->id
|| btr_cur_get_index(btr_cur)->table->is_temporary());
ut_ad(node->ref != &trx_undo_metadata ut_ad(node->ref != &trx_undo_metadata
|| node->update->info_bits == REC_INFO_METADATA_ADD || node->update->info_bits == REC_INFO_METADATA_ADD
|| node->update->info_bits == REC_INFO_METADATA_ALTER); || node->update->info_bits == REC_INFO_METADATA_ALTER);

View File

@ -196,7 +196,7 @@ row_undo_search_clust_to_pcur(
if (found) { if (found) {
ut_ad(row_get_rec_trx_id(rec, clust_index, offsets) ut_ad(row_get_rec_trx_id(rec, clust_index, offsets)
== node->trx->id); == node->trx->id || node->table->is_temporary());
if (dict_table_has_atomic_blobs(node->table)) { if (dict_table_has_atomic_blobs(node->table)) {
/* There is no prefix of externally stored /* There is no prefix of externally stored