summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 08:28:39 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 08:28:39 +0300
commit3a79e5fd317316c293baa459e8296fdb0744c280 (patch)
tree9ff2059bbd651715daa6a1d7241c0ddd303c0071
parent7948a1dc53eccc23095a83daa5fd6b3bfaedf7f2 (diff)
parent657bcf928eb1c6a80ee2c82f0dcdd59ab02927e4 (diff)
downloadmariadb-git-3a79e5fd317316c293baa459e8296fdb0744c280.tar.gz
Merge 10.3 into 10.4
-rw-r--r--appveyor.yml2
-rw-r--r--include/my_pthread.h12
-rw-r--r--mysql-test/main/create_or_replace.result22
-rw-r--r--mysql-test/main/create_or_replace.test22
-rw-r--r--mysql-test/main/ctype_utf32_uca.result22
-rw-r--r--mysql-test/main/ctype_utf32_uca.test26
-rw-r--r--mysql-test/main/sp.test1
-rw-r--r--mysql-test/suite/gcol/r/innodb_virtual_fk.result200
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_fk.test184
-rw-r--r--mysql-test/suite/mariabackup/partition_partial.test1
-rw-r--r--mysql-test/suite/plugins/r/server_audit.result4
-rw-r--r--mysql-test/suite/plugins/t/server_audit.test2
-rw-r--r--mysql-test/suite/sys_vars/r/insert_id_func.result25
-rw-r--r--mysql-test/suite/sys_vars/t/insert_id_func.test20
-rw-r--r--mysys/safemalloc.c4
-rw-r--r--plugin/server_audit/server_audit.c34
-rw-r--r--sql/item_timefunc.cc1
-rw-r--r--sql/protocol.cc19
-rw-r--r--sql/sql_explain.cc2
-rw-r--r--sql/sql_insert.cc14
-rw-r--r--sql/sql_string.cc6
-rw-r--r--sql/sys_vars.cc18
-rw-r--r--storage/innobase/fsp/fsp0sysspace.cc13
-rw-r--r--storage/innobase/handler/ha_innodb.cc78
-rw-r--r--storage/innobase/include/row0mysql.h10
-rw-r--r--storage/innobase/include/univ.i6
-rw-r--r--storage/innobase/include/ut0byte.ic6
-rw-r--r--storage/innobase/pars/pars0grm.cc4
-rw-r--r--storage/innobase/pars/pars0grm.y4
-rw-r--r--storage/innobase/row/row0ftsort.cc4
-rw-r--r--storage/innobase/row/row0ins.cc15
-rw-r--r--storage/innobase/row/row0merge.cc4
-rw-r--r--storage/innobase/row/row0sel.cc2
-rw-r--r--storage/innobase/row/row0upd.cc5
-rw-r--r--storage/innobase/row/row0vers.cc2
-rw-r--r--storage/maria/ma_loghandler.c5
-rw-r--r--storage/rocksdb/ha_rocksdb.h16
-rw-r--r--storage/test_sql_discovery/mysql-test/sql_discovery/simple.test1
38 files changed, 650 insertions, 166 deletions
diff --git a/appveyor.yml b/appveyor.yml
index f5f1b57735a..b42453a8350 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -25,6 +25,6 @@ test_script:
- set PATH=C:\Strawberry\perl\bin;%PATH%;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64
- cd %APPVEYOR_BUILD_FOLDER%\_build\mysql-test
- set /A parallel=4*%NUMBER_OF_PROCESSORS%
- - perl mysql-test-run.pl --force --max-test-fail=10 --retry=2 -parallel=%parallel% --testcase-timeout=3 --suite=main --skip-test-list=unstable-tests --mysqld=--loose-innodb-flush-log-at-trx-commit=2
+ - perl mysql-test-run.pl --force --max-test-fail=10 --retry=2 -parallel=%parallel% --testcase-timeout=4 --suite=main --skip-test-list=unstable-tests --mysqld=--loose-innodb-flush-log-at-trx-commit=2
image: Visual Studio 2019
diff --git a/include/my_pthread.h b/include/my_pthread.h
index bc47bb8bad0..65498d185c5 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -298,16 +298,18 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif
-#if !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
-/* no pthread_yield() available */
#ifdef HAVE_SCHED_YIELD
#define pthread_yield() sched_yield()
-#elif defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
+#else
+#if !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
+/* no pthread_yield() available */
+#if defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
#define pthread_yield() pthread_yield_np()
#elif defined(HAVE_THR_YIELD)
#define pthread_yield() thr_yield()
-#endif
-#endif
+#endif //defined(HAVE_PTHREAD_YIELD_NP)
+#endif //!defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
+#endif //HAVE_SCHED_YIELD
/*
The defines set_timespec and set_timespec_nsec should be used
diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result
index 485091e5810..3a7cfa53411 100644
--- a/mysql-test/main/create_or_replace.result
+++ b/mysql-test/main/create_or_replace.result
@@ -341,6 +341,27 @@ unlock tables;
drop table t1;
create table test.t1 (i int);
drop database mysqltest2;
+drop table test.t1;
+#
+# MDEV-23391 Server crash in close_thread_table or assertion, upon CREATE OR REPLACE TABLE under lock
+#
+create table t1 (i int);
+lock table t1 write;
+select * from information_schema.metadata_lock_info;
+THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
+# MDL_BACKUP_DDL NULL Backup lock
+# MDL_BACKUP_DML NULL Backup lock
+# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test
+# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
+create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a;
+ERROR 22001: Data too long for column 'a' at row 1
+show tables;
+Tables_in_test
+t2
+select * from information_schema.metadata_lock_info;
+THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
+create table t1 (i int);
+drop table t1;
#
# Testing CREATE .. LIKE
#
@@ -546,3 +567,4 @@ SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
UNLOCK TABLES;
DROP TABLE t3;
+# End of 10.4 tests
diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test
index 1b4994e811f..2b6f2ae4005 100644
--- a/mysql-test/main/create_or_replace.test
+++ b/mysql-test/main/create_or_replace.test
@@ -270,6 +270,26 @@ drop table t1;
create table test.t1 (i int);
drop database mysqltest2;
+drop table test.t1;
+
+
+--echo #
+--echo # MDEV-23391 Server crash in close_thread_table or assertion, upon CREATE OR REPLACE TABLE under lock
+--echo #
+create table t1 (i int);
+lock table t1 write;
+--replace_column 1 #
+--sorted_result
+select * from information_schema.metadata_lock_info;
+--error ER_DATA_TOO_LONG
+create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a;
+show tables;
+--replace_column 1 #
+--sorted_result
+select * from information_schema.metadata_lock_info;
+create table t1 (i int);
+drop table t1;
+
--echo #
--echo # Testing CREATE .. LIKE
@@ -486,3 +506,5 @@ CREATE OR REPLACE TEMPORARY TABLE t2(c INT DEFAULT '');
SELECT * FROM t3;
UNLOCK TABLES;
DROP TABLE t3;
+
+--echo # End of 10.4 tests
diff --git a/mysql-test/main/ctype_utf32_uca.result b/mysql-test/main/ctype_utf32_uca.result
index 3f90bedd1c1..3758b1b5661 100644
--- a/mysql-test/main/ctype_utf32_uca.result
+++ b/mysql-test/main/ctype_utf32_uca.result
@@ -7919,6 +7919,28 @@ a b
DROP TABLE t1;
SET NAMES utf8;
#
+# MDEV-25402 Assertion `!str || str != Ptr' failed in String::copy
+#
+SET @c:="SET SESSION collation_connection=utf32_spanish_ci";
+PREPARE s FROM @c;
+EXECUTE s;
+CREATE PROCEDURE p (IN i INT) EXECUTE s;
+SET SESSION character_set_connection=latin1;
+SET @c:="SET @b=get_format(DATE,'EUR')";
+PREPARE s FROM @c;
+EXECUTE s;
+CALL p (@a);
+DEALLOCATE PREPARE s;
+DROP PROCEDURE p;
+SET NAMES utf8;
+SET @c:="SET @b=get_format(DATE,'EUR')";
+PREPARE s FROM @c;
+EXECUTE s;
+SET collation_connection=utf32_spanish_ci;
+EXECUTE s;
+DEALLOCATE PREPARE s;
+SET NAMES utf8;
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/ctype_utf32_uca.test b/mysql-test/main/ctype_utf32_uca.test
index 42635d1464d..ca1f8850e4a 100644
--- a/mysql-test/main/ctype_utf32_uca.test
+++ b/mysql-test/main/ctype_utf32_uca.test
@@ -266,6 +266,32 @@ SET NAMES utf8;
--echo #
+--echo # MDEV-25402 Assertion `!str || str != Ptr' failed in String::copy
+--echo #
+
+SET @c:="SET SESSION collation_connection=utf32_spanish_ci";
+PREPARE s FROM @c;
+EXECUTE s;
+CREATE PROCEDURE p (IN i INT) EXECUTE s;
+SET SESSION character_set_connection=latin1;
+SET @c:="SET @b=get_format(DATE,'EUR')";
+PREPARE s FROM @c;
+EXECUTE s;
+CALL p (@a);
+DEALLOCATE PREPARE s;
+DROP PROCEDURE p;
+
+SET NAMES utf8;
+SET @c:="SET @b=get_format(DATE,'EUR')";
+PREPARE s FROM @c;
+EXECUTE s;
+SET collation_connection=utf32_spanish_ci;
+EXECUTE s;
+DEALLOCATE PREPARE s;
+SET NAMES utf8;
+
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test
index 7fe49855fe9..18e3e1bd499 100644
--- a/mysql-test/main/sp.test
+++ b/mysql-test/main/sp.test
@@ -1,3 +1,4 @@
+--source include/have_partition.inc
#
# Basic stored PROCEDURE tests
#
diff --git a/mysql-test/suite/gcol/r/innodb_virtual_fk.result b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
index 367ed1223f7..de61c16f739 100644
--- a/mysql-test/suite/gcol/r/innodb_virtual_fk.result
+++ b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
@@ -826,3 +826,203 @@ DROP TABLE email_stats;
DROP TABLE emails_metadata;
DROP TABLE emails;
DROP DATABASE `a-b`;
+USE test;
+#
+# Bug#33053297 VIRTUAL INDEX CORRUPTED DURING CASCADE UPDATE ON CHILD TABLE
+#
+# Test-Case 1
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE=InnoDB;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_date date GENERATED ALWAYS AS
+(concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+'-', lpad(dayofmonth(date_sent), 2, '0'))),
+PRIMARY KEY (id),
+KEY IDX_ES1 (email_id),
+KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = InnoDB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_date
+1 1 2020-10-22 13:32:41 2020-10-22
+DELETE FROM emails;
+DELETE FROM email_stats;
+# Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+# Test-Case 2
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE = InnoDB
+DEFAULT CHARSET = utf8mb4
+COLLATE = utf8mb4_unicode_ci
+ROW_FORMAT = DYNAMIC;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_date date GENERATED ALWAYS AS
+(concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+'-', lpad(dayofmonth(date_sent), 2, '0'))),
+PRIMARY KEY (id),
+KEY IDX_ES1 (email_id),
+KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id)
+ON DELETE SET NULL
+ON UPDATE SET NULL
+) ENGINE = InnoDB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+UPDATE emails SET id = 2 where id = 1;
+SELECT id FROM email_stats WHERE generated_sent_date IS NULL;
+id
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_date
+1 NULL 2020-10-22 13:32:41 2020-10-22
+UPDATE email_stats
+SET email_id=2
+WHERE DATE(generated_sent_date) = '2020-10-22';
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_date
+1 2 2020-10-22 13:32:41 2020-10-22
+# Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+# Test-case 3
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE = INNODB
+DEFAULT CHARSET = utf8mb4
+COLLATE = utf8mb4_unicode_ci
+ROW_FORMAT = DYNAMIC;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_email varchar(20) GENERATED ALWAYS AS
+(CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+PRIMARY KEY (id),
+KEY idx_es1 (email_id),
+KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = INNODB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 1 2020-10-22 13:32:41 2020-1
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+date_sent
+2020-10-22 13:32:41
+DELETE FROM emails;
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 NULL 2020-10-22 13:32:41 2020-$
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+# Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+# Test-case 4
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE = INNODB;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_email varchar(20) GENERATED ALWAYS AS
+(CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+PRIMARY KEY (id),
+KEY idx_es1 (email_id),
+KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id) ON UPDATE SET NULL
+) ENGINE = INNODB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 1 2020-10-22 13:32:41 2020-1
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+date_sent
+2020-10-22 13:32:41
+UPDATE emails SET id = 2 WHERE id = 1;
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 NULL 2020-10-22 13:32:41 2020-$
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+DROP TABLE email_stats;
+DROP TABLE emails;
+CREATE TABLE emails (breaker int unsigned,
+KEY (breaker),
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE=INNODB;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_email varchar(20) GENERATED ALWAYS AS
+(CONCAT(YEAR(date_sent),
+'-',
+COALESCE(email_id, '$'))),
+PRIMARY KEY (id),
+KEY idx_es1 (email_id),
+KEY mautic_generated_sent_date_email (generated_sent_email, email_id),
+FOREIGN KEY fk_ea1 (email_id) REFERENCES emails (breaker)
+ON DELETE SET NULL
+) ENGINE=INNODB;
+show create table email_stats;
+Table Create Table
+email_stats CREATE TABLE `email_stats` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `email_id` int(10) unsigned DEFAULT NULL,
+ `date_sent` datetime NOT NULL,
+ `generated_sent_email` varchar(20) GENERATED ALWAYS AS (concat(year(`date_sent`),'-',coalesce(`email_id`,'$'))) VIRTUAL,
+ PRIMARY KEY (`id`),
+ KEY `idx_es1` (`email_id`),
+ KEY `mautic_generated_sent_date_email` (`generated_sent_email`,`email_id`),
+ CONSTRAINT `fk_ea1` FOREIGN KEY (`email_id`) REFERENCES `emails` (`breaker`) ON DELETE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO emails VALUES (1,1);
+INSERT INTO email_stats(id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 1 2020-10-22 13:32:41 2020-1
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+date_sent
+2020-10-22 13:32:41
+DELETE FROM emails;
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 NULL 2020-10-22 13:32:41 2020-$
+SELECT date_sent
+FROM email_stats force index (mautic_generated_sent_date_email)
+WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+SELECT date_sent
+FROM email_stats force index (idx_es1)
+WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+DROP TABLE email_stats;
+DROP TABLE emails;
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_fk.test b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
index c99259531b3..0f0406b5dd4 100644
--- a/mysql-test/suite/gcol/t/innodb_virtual_fk.test
+++ b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
@@ -693,3 +693,187 @@ DROP TABLE email_stats;
DROP TABLE emails_metadata;
DROP TABLE emails;
DROP DATABASE `a-b`;
+USE test;
+
+--echo #
+--echo # Bug#33053297 VIRTUAL INDEX CORRUPTED DURING CASCADE UPDATE ON CHILD TABLE
+--echo #
+
+--echo # Test-Case 1
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_date date GENERATED ALWAYS AS
+ (concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+ '-', lpad(dayofmonth(date_sent), 2, '0'))),
+ PRIMARY KEY (id),
+ KEY IDX_ES1 (email_id),
+ KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = InnoDB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+
+DELETE FROM emails;
+DELETE FROM email_stats;
+
+--echo # Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+--echo # Test-Case 2
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci
+ ROW_FORMAT = DYNAMIC;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_date date GENERATED ALWAYS AS
+ (concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+ '-', lpad(dayofmonth(date_sent), 2, '0'))),
+ PRIMARY KEY (id),
+ KEY IDX_ES1 (email_id),
+ KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id)
+ ON DELETE SET NULL
+ ON UPDATE SET NULL
+) ENGINE = InnoDB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+
+UPDATE emails SET id = 2 where id = 1;
+
+SELECT id FROM email_stats WHERE generated_sent_date IS NULL;
+SELECT * FROM email_stats;
+UPDATE email_stats
+ SET email_id=2
+ WHERE DATE(generated_sent_date) = '2020-10-22';
+SELECT * FROM email_stats;
+
+--echo # Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+--echo # Test-case 3
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE = INNODB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci
+ ROW_FORMAT = DYNAMIC;
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_email varchar(20) GENERATED ALWAYS AS
+ (CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+ PRIMARY KEY (id),
+ KEY idx_es1 (email_id),
+ KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = INNODB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+
+DELETE FROM emails;
+
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+
+--echo # Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+--echo # Test-case 4
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE = INNODB;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_email varchar(20) GENERATED ALWAYS AS
+ (CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+ PRIMARY KEY (id),
+ KEY idx_es1 (email_id),
+ KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id) ON UPDATE SET NULL
+) ENGINE = INNODB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+
+UPDATE emails SET id = 2 WHERE id = 1;
+
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+
+#clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+CREATE TABLE emails (breaker int unsigned,
+ KEY (breaker),
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE=INNODB;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_email varchar(20) GENERATED ALWAYS AS
+ (CONCAT(YEAR(date_sent),
+ '-',
+ COALESCE(email_id, '$'))),
+ PRIMARY KEY (id),
+ KEY idx_es1 (email_id),
+ KEY mautic_generated_sent_date_email (generated_sent_email, email_id),
+ FOREIGN KEY fk_ea1 (email_id) REFERENCES emails (breaker)
+ ON DELETE SET NULL
+) ENGINE=INNODB;
+
+show create table email_stats;
+INSERT INTO emails VALUES (1,1);
+INSERT INTO email_stats(id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+DELETE FROM emails;
+SELECT * FROM email_stats;
+SELECT date_sent
+ FROM email_stats force index (mautic_generated_sent_date_email)
+ WHERE generated_sent_email = '2020-$';
+SELECT date_sent
+ FROM email_stats force index (idx_es1)
+ WHERE generated_sent_email = '2020-$';
+
+DROP TABLE email_stats;
+DROP TABLE emails;
diff --git a/mysql-test/suite/mariabackup/partition_partial.test b/mysql-test/suite/mariabackup/partition_partial.test
index 8e288ec997f..7ccc42c036c 100644
--- a/mysql-test/suite/mariabackup/partition_partial.test
+++ b/mysql-test/suite/mariabackup/partition_partial.test
@@ -1,4 +1,5 @@
#--source include/innodb_page_size.inc
+--source include/have_partition.inc
# import partitioned table from table from partial backup
diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result
index 40c07805315..9768040aa94 100644
--- a/mysql-test/suite/plugins/r/server_audit.result
+++ b/mysql-test/suite/plugins/r/server_audit.result
@@ -265,6 +265,9 @@ A B C D
A B C D
set global server_audit_query_log_limit= 1024;
drop database sa_db;
+select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
+length('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
+2750
set global server_audit_file_path='.';
show status like 'server_audit_current_log';
Variable_name Value
@@ -501,6 +504,7 @@ TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0
+TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select length(\'012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0
diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test
index 01da49756d0..d8f8b9d0165 100644
--- a/mysql-test/suite/plugins/t/server_audit.test
+++ b/mysql-test/suite/plugins/t/server_audit.test
@@ -216,6 +216,8 @@ select 'A', 'B', 'C', 'D';
set global server_audit_query_log_limit= 1024;
drop database sa_db;
+select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
+
set global server_audit_file_path='.';
--replace_regex /\.[\\\/]/HOME_DIR\//
show status like 'server_audit_current_log';
diff --git a/mysql-test/suite/sys_vars/r/insert_id_func.result b/mysql-test/suite/sys_vars/r/insert_id_func.result
index 6a5746e130d..e4486cd5acf 100644
--- a/mysql-test/suite/sys_vars/r/insert_id_func.result
+++ b/mysql-test/suite/sys_vars/r/insert_id_func.result
@@ -69,3 +69,28 @@ id name
drop table t1;
disconnect test_con1;
disconnect test_con2;
+connection default;
+CREATE TABLE t1(id int primary key auto_increment);
+SET SESSION insert_id=123;
+SET SESSION insert_id=0;
+INSERT INTO t1 VALUES ();
+SET SESSION insert_id=123;
+SET SESSION insert_id=default;
+INSERT INTO t1 VALUES ();
+SET SESSION insert_id=123;
+SET SESSION insert_id=-1;
+Warnings:
+Warning 1292 Truncated incorrect insert_id value: '-1'
+INSERT INTO t1 VALUES ();
+SET SESSION insert_id=123;
+SET SESSION insert_id=-10;
+Warnings:
+Warning 1292 Truncated incorrect insert_id value: '-10'
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+id
+1
+2
+3
+4
+DROP TABLE t1;
diff --git a/mysql-test/suite/sys_vars/t/insert_id_func.test b/mysql-test/suite/sys_vars/t/insert_id_func.test
index a710afbb0cc..feb510c091b 100644
--- a/mysql-test/suite/sys_vars/t/insert_id_func.test
+++ b/mysql-test/suite/sys_vars/t/insert_id_func.test
@@ -103,3 +103,23 @@ drop table t1;
disconnect test_con1;
disconnect test_con2;
+
+# MDEV-22711 Assertion `nr != 0' failed in handler::update_auto_increment.
+#
+connection default;
+CREATE TABLE t1(id int primary key auto_increment);
+SET SESSION insert_id=123;
+SET SESSION insert_id=0;
+INSERT INTO t1 VALUES ();
+SET SESSION insert_id=123;
+SET SESSION insert_id=default;
+INSERT INTO t1 VALUES ();
+SET SESSION insert_id=123;
+SET SESSION insert_id=-1;
+INSERT INTO t1 VALUES ();
+SET SESSION insert_id=123;
+SET SESSION insert_id=-10;
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1;
+DROP TABLE t1;
+
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index d38c3bcfb66..034b6f2536b 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -354,9 +354,9 @@ int sf_sanity()
if (count || irem)
{
warn("Error: Safemalloc link list destroyed");
- return 1;
+ flag= 1;
}
- return 0;
+ return flag;
}
/**
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index 228f261b333..7a170b13b27 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -301,8 +301,6 @@ static char logging;
static volatile int internal_stop_logging= 0;
static char incl_user_buffer[1024];
static char excl_user_buffer[1024];
-static char *big_buffer= NULL;
-static size_t big_buffer_alloced= 0;
static unsigned int query_log_limit= 0;
static char servhost[256];
@@ -561,18 +559,10 @@ static PSI_mutex_info mutex_key_list[]=
{
{ &key_LOCK_operations, "SERVER_AUDIT_plugin::lock_operations",
PSI_FLAG_GLOBAL}
-#ifndef FLOGGER_NO_PSI
- ,
- { &key_LOCK_atomic, "SERVER_AUDIT_plugin::lock_atomic",
- PSI_FLAG_GLOBAL},
- { &key_LOCK_bigbuffer, "SERVER_AUDIT_plugin::lock_bigbuffer",
- PSI_FLAG_GLOBAL}
-#endif /*FLOGGER_NO_PSI*/
};
#endif /*HAVE_PSI_INTERFACE*/
static mysql_prlock_t lock_operations;
static mysql_mutex_t lock_atomic;
-static mysql_mutex_t lock_bigbuffer;
/* The Percona server and partly MySQL don't support */
/* launching client errors in the 'update_variable' methods. */
@@ -1727,7 +1717,7 @@ static int log_statement_ex(const struct connection_info *cn,
int error_code, const char *type, int take_lock)
{
size_t csize;
- char message_loc[1024];
+ char message_loc[2048];
char *message= message_loc;
size_t message_size= sizeof(message_loc);
char *uh_buffer;
@@ -1736,6 +1726,7 @@ static int log_statement_ex(const struct connection_info *cn,
unsigned int db_length;
long long query_id;
int result;
+ char *big_buffer= NULL;
if ((db= cn->db))
db_length= cn->db_length;
@@ -1818,17 +1809,9 @@ do_log_query:
if (query_len > (message_size - csize)/2)
{
- flogger_mutex_lock(&lock_bigbuffer);
- if (big_buffer_alloced < (query_len * 2 + csize))
- {
- big_buffer_alloced= (query_len * 2 + csize + 4095) & ~4095L;
- big_buffer= realloc(big_buffer, big_buffer_alloced);
- if (big_buffer == NULL)
- {
- big_buffer_alloced= 0;
- return 0;
- }
- }
+ size_t big_buffer_alloced= (query_len * 2 + csize + 4095) & ~4095L;
+ if(!(big_buffer= malloc(big_buffer_alloced)))
+ return 0;
memcpy(big_buffer, message, csize);
message= big_buffer;
@@ -1874,8 +1857,8 @@ do_log_query:
"\',%d", error_code);
message[csize]= '\n';
result= write_log(message, csize + 1, take_lock);
- if (message == big_buffer)
- flogger_mutex_unlock(&lock_bigbuffer);
+ if (big_buffer)
+ free(big_buffer);
return result;
}
@@ -2524,7 +2507,6 @@ static int server_audit_init(void *p __attribute__((unused)))
#endif
mysql_prlock_init(key_LOCK_operations, &lock_operations);
flogger_mutex_init(key_LOCK_operations, &lock_atomic, MY_MUTEX_INIT_FAST);
- flogger_mutex_init(key_LOCK_operations, &lock_bigbuffer, MY_MUTEX_INIT_FAST);
coll_init(&incl_user_coll);
coll_init(&excl_user_coll);
@@ -2609,10 +2591,8 @@ static int server_audit_deinit(void *p __attribute__((unused)))
else if (output_type == OUTPUT_SYSLOG)
closelog();
- (void) free(big_buffer);
mysql_prlock_destroy(&lock_operations);
flogger_mutex_destroy(&lock_atomic);
- flogger_mutex_destroy(&lock_bigbuffer);
error_header();
fprintf(stderr, "STOPPED\n");
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 7dbc81e8825..7ef138b7f9a 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2592,7 +2592,6 @@ bool Item_func_timediff::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzy
DBUG_ASSERT(fixed == 1);
int l_sign= 1;
MYSQL_TIME l_time1,l_time2,l_time3;
- ErrConvTime str(&l_time3);
/* the following may be true in, for example, date_add(timediff(...), ... */
if (fuzzydate & TIME_NO_ZERO_IN_DATE)
diff --git a/sql/protocol.cc b/sql/protocol.cc
index eb7f19d2bd0..1eb7a096ca9 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -218,8 +218,6 @@ net_send_ok(THD *thd,
NET *net= &thd->net;
StringBuffer<MYSQL_ERRMSG_SIZE + 10> store;
- bool state_changed= false;
-
bool error= FALSE;
DBUG_ENTER("net_send_ok");
@@ -246,6 +244,11 @@ net_send_ok(THD *thd,
/* last insert id */
store.q_net_store_length(id);
+ /* if client has not session tracking capability, don't send state change flag*/
+ if (!(thd->client_capabilities & CLIENT_SESSION_TRACK)) {
+ server_status &= ~SERVER_SESSION_STATE_CHANGED;
+ }
+
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
DBUG_PRINT("info",
@@ -266,21 +269,17 @@ net_send_ok(THD *thd,
}
thd->get_stmt_da()->set_overwrite_status(true);
- state_changed=
- (thd->client_capabilities & CLIENT_SESSION_TRACK) &&
- (server_status & SERVER_SESSION_STATE_CHANGED);
-
- if (state_changed || (message && message[0]))
+ if ((server_status & SERVER_SESSION_STATE_CHANGED) || (message && message[0]))
{
DBUG_ASSERT(safe_strlen(message) <= MYSQL_ERRMSG_SIZE);
store.q_net_store_data((uchar*) safe_str(message), safe_strlen(message));
}
- if (unlikely(state_changed))
+ if (unlikely(server_status & SERVER_SESSION_STATE_CHANGED))
{
store.set_charset(thd->variables.collation_database);
-
thd->session_tracker.store(thd, &store);
+ thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
}
DBUG_ASSERT(store.length() <= MAX_PACKET_LENGTH);
@@ -289,8 +288,6 @@ net_send_ok(THD *thd,
if (likely(!error) && (!skip_flush || is_eof))
error= net_flush(net);
- thd->server_status&= ~SERVER_SESSION_STATE_CHANGED;
-
thd->get_stmt_da()->set_overwrite_status(false);
DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 645c1618a8a..9114546eb9b 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1921,7 +1921,7 @@ void Explain_table_access::print_explain_json(Explain_query *query,
/*
- Elements in this array match members of enum Extra_tag, defined in
+ Elements in this array match members of enum explain_extra_tag, defined in
sql_explain.h
*/
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 4bf15bfbb9b..0f454e74a48 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4878,12 +4878,6 @@ void select_create::abort_result_set()
/* possible error of writing binary log is ignored deliberately */
(void) thd->binlog_flush_pending_rows_event(TRUE, TRUE);
- if (create_info->table_was_deleted)
- {
- /* Unlock locked table that was dropped by CREATE */
- thd->locked_tables_list.unlock_locked_table(thd,
- create_info->mdl_ticket);
- }
if (table)
{
bool tmp_table= table->s->tmp_table;
@@ -4922,5 +4916,13 @@ void select_create::abort_result_set()
tmp_table);
}
}
+
+ if (create_info->table_was_deleted)
+ {
+ /* Unlock locked table that was dropped by CREATE. */
+ (void) trans_rollback_stmt(thd);
+ thd->locked_tables_list.unlock_locked_table(thd, create_info->mdl_ticket);
+ }
+
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index e3f4497274c..560815eeb6b 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2016, 2020, MariaDB
+ Copyright (c) 2016, 2021, 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
@@ -438,8 +438,8 @@ bool String::copy(const char *str, size_t arg_length,
{
uint32 offset;
- DBUG_ASSERT(!str || str != Ptr);
-
+ DBUG_ASSERT(!str || str != Ptr || !is_alloced());
+
if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
{
*errors= 0;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 53a978794f2..d42c76245cb 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4481,12 +4481,16 @@ static Sys_var_session_special Sys_identity(
*/
static bool update_insert_id(THD *thd, set_var *var)
{
- if (!var->value)
- {
- my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
- return true;
- }
- thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
+ /*
+ If we set the insert_id to the DEFAULT or 0
+ it means we 'reset' it so it's value doesn't
+ affect the INSERT.
+ */
+ if (!var->value ||
+ var->save_result.ulonglong_value == 0)
+ thd->auto_inc_intervals_forced.empty();
+ else
+ thd->force_one_auto_inc_interval(var->save_result.ulonglong_value);
return false;
}
@@ -4494,6 +4498,8 @@ static ulonglong read_insert_id(THD *thd)
{
return thd->auto_inc_intervals_forced.minimum();
}
+
+
static Sys_var_session_special Sys_insert_id(
"insert_id", "The value to be used by the following INSERT "
"or ALTER TABLE statement when inserting an AUTO_INCREMENT value",
diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc
index fd5ac3c368f..98b3ae38097 100644
--- a/storage/innobase/fsp/fsp0sysspace.cc
+++ b/storage/innobase/fsp/fsp0sysspace.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2020, MariaDB Corporation.
+Copyright (c) 2016, 2021, 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 the Free Software
@@ -677,13 +677,18 @@ SysTablespace::file_not_found(
{
file.m_exists = false;
- if (srv_read_only_mode && !m_ignore_read_only) {
+ if (m_ignore_read_only) {
+ } else if (srv_read_only_mode) {
ib::error() << "Can't create file '" << file.filepath()
<< "' when --innodb-read-only is set";
-
return(DB_ERROR);
+ } else if (srv_force_recovery && space_id() == TRX_SYS_SPACE) {
+ ib::error() << "Can't create file '" << file.filepath()
+ << "' when --innodb-force-recovery is set";
+ return DB_ERROR;
+ }
- } else if (&file == &m_files.front()) {
+ if (&file == &m_files.front()) {
/* First data file. */
ut_a(!*create_new_db);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 9c8a1e1f350..972ef1a01b6 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -20725,48 +20725,6 @@ innobase_rename_vc_templ(
table->vc_templ->tb_name = t_tbname;
}
-/** Get the updated parent field value from the update vector for the
-given col_no.
-@param[in] foreign foreign key information
-@param[in] update updated parent vector.
-@param[in] col_no base column position of the child table to check
-@return updated field from the parent update vector, else NULL */
-static
-dfield_t*
-innobase_get_field_from_update_vector(
- dict_foreign_t* foreign,
- upd_t* update,
- ulint col_no)
-{
- dict_table_t* parent_table = foreign->referenced_table;
- dict_index_t* parent_index = foreign->referenced_index;
- ulint parent_field_no;
- ulint parent_col_no;
- ulint prefix_col_no;
-
- for (ulint i = 0; i < foreign->n_fields; i++) {
- if (dict_index_get_nth_col_no(foreign->foreign_index, i)
- != col_no) {
- continue;
- }
-
- parent_col_no = dict_index_get_nth_col_no(parent_index, i);
- parent_field_no = dict_table_get_nth_col_pos(
- parent_table, parent_col_no, &prefix_col_no);
-
- for (ulint j = 0; j < update->n_fields; j++) {
- upd_field_t* parent_ufield
- = &update->fields[j];
-
- if (parent_ufield->field_no == parent_field_no) {
- return(&parent_ufield->new_val);
- }
- }
- }
-
- return (NULL);
-}
-
/**
Allocate a heap and record for calculating virtual fields
@@ -20849,9 +20807,10 @@ void innobase_report_computed_value_failed(dtuple_t *row)
@param[in] ifield index field
@param[in] thd MySQL thread handle
@param[in,out] mysql_table mysql table object
+@param[in,out] mysql_rec MariaDB record buffer
@param[in] old_table during ALTER TABLE, this is the old table
or NULL.
-@param[in] parent_update update vector for the parent row
+@param[in] update update vector for the row, if any
@param[in] foreign foreign key information
@return the field filled with computed value, or NULL if just want
to store the value in passed in "my_rec" */
@@ -20867,8 +20826,7 @@ innobase_get_computed_value(
TABLE* mysql_table,
byte* mysql_rec,
const dict_table_t* old_table,
- upd_t* parent_update,
- dict_foreign_t* foreign)
+ const upd_t* update)
{
byte rec_buf2[REC_VERSION_56_MAX_INDEX_COL_LEN];
byte* buf;
@@ -20881,6 +20839,8 @@ innobase_get_computed_value(
ulint ret = 0;
+ dict_index_t *clust_index= dict_table_get_first_index(index->table);
+
ut_ad(index->table->vc_templ);
ut_ad(thd != NULL);
ut_ad(mysql_table);
@@ -20910,14 +20870,16 @@ innobase_get_computed_value(
= index->table->vc_templ->vtempl[col_no];
const byte* data;
- if (parent_update != NULL) {
- /** Get the updated field from update vector
- of the parent table. */
- row_field = innobase_get_field_from_update_vector(
- foreign, parent_update, col_no);
+ if (update) {
+ ulint clust_no = dict_col_get_clust_pos(base_col,
+ clust_index);
+ if (const upd_field_t *uf = upd_get_field_by_field_no(
+ update, clust_no, false)) {
+ row_field = &uf->new_val;
+ }
}
- if (row_field == NULL) {
+ if (!row_field) {
row_field = dtuple_get_nth_field(row, col_no);
}
@@ -21864,21 +21826,13 @@ void ins_node_t::vers_update_end(row_prebuilt_t *prebuilt, bool history_row)
mem_heap_t *local_heap= NULL;
for (ulint col_no= 0; col_no < dict_table_get_n_v_cols(table); col_no++)
{
-
const dict_v_col_t *v_col= dict_table_get_nth_v_col(table, col_no);
for (ulint i= 0; i < unsigned(v_col->num_base); i++)
- {
- dict_col_t *base_col= v_col->base_col[i];
- if (base_col->ind == table->vers_end)
- {
+ if (v_col->base_col[i]->ind == table->vers_end)
innobase_get_computed_value(row, v_col, clust_index, &local_heap,
table->heap, NULL, thd, mysql_table,
- mysql_table->record[0], NULL, NULL, NULL);
- }
- }
+ mysql_table->record[0], NULL, NULL);
}
- if (local_heap)
- {
+ if (UNIV_LIKELY_NULL(local_heap))
mem_heap_free(local_heap);
- }
}
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index cbb544f60c1..51afbedd649 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -915,11 +915,12 @@ void innobase_report_computed_value_failed(dtuple_t *row);
@param[in,out] local_heap heap memory for processing large data etc.
@param[in,out] heap memory heap that copies the actual index row
@param[in] ifield index field
-@param[in] thd MySQL thread handle
-@param[in,out] mysql_table mysql table object
+@param[in] thd connection handle
+@param[in,out] mysql_table MariaDB table handle
+@param[in,out] mysql_rec MariaDB record buffer
@param[in] old_table during ALTER TABLE, this is the old table
or NULL.
-@param[in] parent_update update vector for the parent row
+@param[in] update update vector for the parent row
@param[in] foreign foreign key information
@return the field filled with computed value */
dfield_t*
@@ -934,8 +935,7 @@ innobase_get_computed_value(
TABLE* mysql_table,
byte* mysql_rec,
const dict_table_t* old_table,
- upd_t* parent_update,
- dict_foreign_t* foreign);
+ const upd_t* update);
/** Get the computed value by supplying the base column values.
@param[in,out] table the table whose virtual column
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index ab9d4d296ad..f1e355ade4d 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -235,6 +235,12 @@ easy way to get it to work. See http://bugs.mysql.com/bug.php?id=52263. */
# define UNIV_INTERN
#endif
+#if defined(__GNUC__) && (__GNUC__ >= 11)
+# define ATTRIBUTE_ACCESS(X) __attribute__((access X))
+#else
+# define ATTRIBUTE_ACCESS(X)
+#endif
+
#ifndef MY_ATTRIBUTE
#if defined(__GNUC__)
# define MY_ATTRIBUTE(A) __attribute__(A)
diff --git a/storage/innobase/include/ut0byte.ic b/storage/innobase/include/ut0byte.ic
index e6e60f07886..6dd48090c3a 100644
--- a/storage/innobase/include/ut0byte.ic
+++ b/storage/innobase/include/ut0byte.ic
@@ -77,7 +77,7 @@ ut_uint64_align_up(
/*********************************************************//**
The following function rounds up a pointer to the nearest aligned address.
@return aligned pointer */
-UNIV_INLINE
+UNIV_INLINE ATTRIBUTE_ACCESS((none,1))
void*
ut_align(
/*=====*/
@@ -97,7 +97,7 @@ ut_align(
The following function rounds down a pointer to the nearest
aligned address.
@return aligned pointer */
-UNIV_INLINE
+UNIV_INLINE ATTRIBUTE_ACCESS((none,1))
void*
ut_align_down(
/*==========*/
@@ -117,7 +117,7 @@ ut_align_down(
The following function computes the offset of a pointer from the nearest
aligned address.
@return distance from aligned pointer */
-UNIV_INLINE
+UNIV_INLINE ATTRIBUTE_ACCESS((none,1))
ulint
ut_align_offset(
/*============*/
diff --git a/storage/innobase/pars/pars0grm.cc b/storage/innobase/pars/pars0grm.cc
index 7e10a783310..10d0d0becd7 100644
--- a/storage/innobase/pars/pars0grm.cc
+++ b/storage/innobase/pars/pars0grm.cc
@@ -79,6 +79,10 @@ que_node_t */
#include "que0que.h"
#include "row0sel.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
+#endif
+
#define YYSTYPE que_node_t*
/* #define __STDC__ */
diff --git a/storage/innobase/pars/pars0grm.y b/storage/innobase/pars/pars0grm.y
index 625ed41bbd4..3fb0865f608 100644
--- a/storage/innobase/pars/pars0grm.y
+++ b/storage/innobase/pars/pars0grm.y
@@ -38,6 +38,10 @@ que_node_t */
#include "que0que.h"
#include "row0sel.h"
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
+#endif
+
#define YYSTYPE que_node_t*
/* #define __STDC__ */
diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc
index f7c07ec1ca9..8d1dbad22cb 100644
--- a/storage/innobase/row/row0ftsort.cc
+++ b/storage/innobase/row/row0ftsort.cc
@@ -1791,8 +1791,6 @@ row_fts_merge_insert(
}
exit:
- dict_table_close(aux_table, FALSE, FALSE);
-
fts_sql_commit(trx);
trx->op_info = "";
@@ -1802,6 +1800,8 @@ exit:
error = ins_ctx.btr_bulk->finish(error);
UT_DELETE(ins_ctx.btr_bulk);
+ dict_table_close(aux_table, FALSE, FALSE);
+
trx->free();
mem_heap_free(heap);
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index c191b972cd0..a63dd90e9c2 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -861,7 +861,6 @@ row_ins_invalidate_query_cache(
innobase_invalidate_query_cache(thr_get_trx(thr), name);
}
-
/** Fill virtual column information in cascade node for the child table.
@param[out] cascade child update node
@param[in] rec clustered rec of child table
@@ -908,6 +907,11 @@ row_ins_foreign_fill_virtual(
if (!record) {
return DB_OUT_OF_MEMORY;
}
+ ut_ad(!node->is_delete
+ || (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL));
+ ut_ad(foreign->type & (DICT_FOREIGN_ON_DELETE_SET_NULL
+ | DICT_FOREIGN_ON_UPDATE_SET_NULL
+ | DICT_FOREIGN_ON_UPDATE_CASCADE));
for (ulint i = 0; i < n_v_fld; i++) {
@@ -923,7 +927,7 @@ row_ins_foreign_fill_virtual(
dfield_t* vfield = innobase_get_computed_value(
update->old_vrow, col, index,
&vc.heap, update->heap, NULL, thd, mysql_table,
- record, NULL, NULL, NULL);
+ record, NULL, NULL);
if (vfield == NULL) {
return DB_COMPUTE_VALUE_FAILED;
@@ -939,16 +943,11 @@ row_ins_foreign_fill_virtual(
upd_field_set_v_field_no(upd_field, i, index);
- bool set_null =
- node->is_delete
- ? (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)
- : (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL);
-
dfield_t* new_vfield = innobase_get_computed_value(
update->old_vrow, col, index,
&vc.heap, update->heap, NULL, thd,
mysql_table, record, NULL,
- set_null ? update : node->update, foreign);
+ update);
if (new_vfield == NULL) {
return DB_COMPUTE_VALUE_FAILED;
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index ac08a5e11e9..a81e47edaf5 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -600,8 +600,8 @@ error:
row_field = innobase_get_computed_value(
row, v_col, clust_index,
v_heap, NULL, ifield, trx->mysql_thd,
- my_table, vcol_storage.innobase_record,
- old_table, NULL, NULL);
+ my_table, vcol_storage.innobase_record,
+ old_table, NULL);
if (row_field == NULL) {
*err = DB_COMPUTE_VALUE_FAILED;
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 2145ca6b06e..a7ceb1f3f85 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -332,7 +332,7 @@ row_sel_sec_rec_is_for_clust_rec(
&heap, NULL, NULL,
thr_get_trx(thr)->mysql_thd,
thr->prebuilt->m_mysql_table,
- record, NULL, NULL, NULL);
+ record, NULL, NULL);
if (vfield == NULL) {
innobase_report_computed_value_failed(row);
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index c8b098be5fa..9f631128b08 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -1079,7 +1079,7 @@ row_upd_build_difference_binary(
dfield_t* vfield = innobase_get_computed_value(
update->old_vrow, col, index,
&vc.heap, heap, NULL, thd, mysql_table, record,
- NULL, NULL, NULL);
+ NULL, NULL);
if (vfield == NULL) {
*error = DB_COMPUTE_VALUE_FAILED;
return(NULL);
@@ -2162,8 +2162,7 @@ row_upd_store_v_row(
node->row, col, index,
&vc.heap, node->heap,
NULL, thd, mysql_table,
- record, NULL, NULL,
- NULL);
+ record, NULL, NULL);
if (vfield == NULL) {
return false;
}
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc
index a5ef82405d4..d1ff7bc540e 100644
--- a/storage/innobase/row/row0vers.cc
+++ b/storage/innobase/row/row0vers.cc
@@ -490,7 +490,7 @@ row_vers_build_clust_v_col(
dfield_t *vfield = innobase_get_computed_value(
row, col, clust_index, &vc.heap,
heap, NULL, thd, maria_table, record, NULL,
- NULL, NULL);
+ NULL);
if (vfield == NULL) {
innobase_report_computed_value_failed(row);
ut_ad(0);
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index 42755a63a03..9de4480062b 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -3399,10 +3399,9 @@ static uint16 translog_get_chunk_header_length(uchar *chunk)
DBUG_PRINT("info", ("TRANSLOG_CHUNK_LNGTH = 3"));
DBUG_RETURN(3);
break;
- default:
- DBUG_ASSERT(0);
- DBUG_RETURN(0); /* Keep compiler happy */
}
+ DBUG_ASSERT(0);
+ DBUG_RETURN(0); /* Keep compiler happy */
}
diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h
index 448900c5a91..270c8c6f319 100644
--- a/storage/rocksdb/ha_rocksdb.h
+++ b/storage/rocksdb/ha_rocksdb.h
@@ -448,15 +448,13 @@ class ha_rocksdb : public my_core::handler {
}
}
- /** @brief
- The name that will be used for display purposes.
- */
- const char *table_type() const /*override*/ {
- DBUG_ENTER_FUNC();
- // MariaDB: this function is not virtual, however ha_innodb
- // declares it (and then never uses!) psergey-merge-todo:.
- DBUG_RETURN(rocksdb_hton_name);
- }
+ /*
+ MariaDB: this function:
+
+ const char *table_type() const
+
+ is non-virtual in class handler, so there's no point to override it.
+ */
/* The following is only used by SHOW KEYS: */
const char *index_type(uint inx) override {
diff --git a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test
index 90eea753a38..a8c7ef9a6bb 100644
--- a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test
+++ b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.test
@@ -29,6 +29,7 @@ show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int primary key) partition by hash(id) partitions 2';
--error ER_SQL_DISCOVER_ERROR
select * from t1;
+--replace_result 1289 1290 "The 'partitioning' feature is disabled; you need MariaDB built with '--with-plugin-partition' to have it working" "The MariaDB server is running with the --skip-partition option so it cannot execute this statement"
show warnings;
set @@test_sql_discovery_statement='t1:create table t1 (a int) union=(t3,t4)';