summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-01-25 11:02:07 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-01-25 11:02:07 +0200
commit3467f6376472ce695e36746ba5b3c13cb5fcbb9f (patch)
tree31432a470ddb2247e0a3e2bcadd89666e273d904
parentce141d0714207afb70911abce21c2a4055b8a9e9 (diff)
parenteaeb8ec4b87882711ecb8e1c7476a6e410d5d2a9 (diff)
downloadmariadb-git-3467f6376472ce695e36746ba5b3c13cb5fcbb9f.tar.gz
Merge 10.3 into 10.4
-rw-r--r--mysql-test/main/derived_cond_pushdown.result70
-rw-r--r--mysql-test/main/derived_cond_pushdown.test13
-rw-r--r--mysql-test/main/empty_string_literal.result29
-rw-r--r--mysql-test/main/empty_string_literal.test19
-rw-r--r--mysql-test/main/information_schema.result9
-rw-r--r--mysql-test/main/information_schema.test10
-rw-r--r--mysql-test/main/parser.result9
-rw-r--r--mysql-test/main/parser.test15
-rw-r--r--mysql-test/main/processlist_notembedded.result16
-rw-r--r--mysql-test/main/processlist_notembedded.test20
-rw-r--r--mysql-test/main/sp-ucs2.result11
-rw-r--r--mysql-test/main/sp-ucs2.test13
-rw-r--r--mysql-test/main/union.result34
-rw-r--r--mysql-test/main/union.test18
-rw-r--r--mysql-test/suite/federated/assisted_discovery.result15
-rw-r--r--mysql-test/suite/federated/assisted_discovery.test21
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_debug.result92
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_debug.test95
-rw-r--r--mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result33
-rw-r--r--mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test43
-rw-r--r--scripts/mysql_system_tables_fix.sql1
-rw-r--r--sql/field.h2
-rw-r--r--sql/sp.cc2
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_show.cc101
-rw-r--r--sql/sql_show.h1
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/table.cc7
-rw-r--r--storage/heap/ha_heap.cc3
-rw-r--r--storage/innobase/btr/btr0pcur.cc9
-rw-r--r--storage/innobase/handler/handler0alter.cc23
-rw-r--r--storage/innobase/include/trx0sys.h6
-rw-r--r--storage/innobase/trx/trx0rseg.cc47
-rw-r--r--storage/maria/ha_maria.cc3
35 files changed, 599 insertions, 201 deletions
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 0f2e6f0e2a2..bce02af83ab 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -17058,6 +17058,76 @@ id
2
3
DROP TABLE t;
+#
+# MDEV-23804: Server crashes in st_select_lex::collect_grouping_fields_for_derived
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (3),(4);
+CREATE VIEW v1 AS SELECT a FROM t1 UNION VALUES (3),(4);
+ANALYZE FORMAT=JSON SELECT * from v1 WHERE a=3;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 2,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 50,
+ "attached_condition": "v1.a = 3",
+ "materialized": {
+ "query_block": {
+ "union_result": {
+ "table_name": "<union2,3>",
+ "access_type": "ALL",
+ "r_loops": 1,
+ "r_rows": 2,
+ "query_specifications": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "r_loops": 1,
+ "rows": 2,
+ "r_rows": 2,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 50,
+ "attached_condition": "t1.a = 3"
+ }
+ }
+ },
+ {
+ "query_block": {
+ "select_id": 3,
+ "operation": "UNION",
+ "table": {
+ "message": "No tables used"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * from v1 WHERE a=3;
+a
+3
+DROP VIEW v1;
+DROP TABLE t1;
# End of 10.3 tests
#
# MDEV-18679: materialized view with SELECT S containing materialized
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 7667cd44ed2..34c09c9e948 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -3466,6 +3466,19 @@ eval set statement optimizer_switch='split_materialized=on' for $q;
DROP TABLE t;
+--echo #
+--echo # MDEV-23804: Server crashes in st_select_lex::collect_grouping_fields_for_derived
+--echo #
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (3),(4);
+CREATE VIEW v1 AS SELECT a FROM t1 UNION VALUES (3),(4);
+--source include/analyze-format.inc
+ANALYZE FORMAT=JSON SELECT * from v1 WHERE a=3;
+SELECT * from v1 WHERE a=3;
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/empty_string_literal.result b/mysql-test/main/empty_string_literal.result
index 2ca491a7dd8..bbcf27cf993 100644
--- a/mysql-test/main/empty_string_literal.result
+++ b/mysql-test/main/empty_string_literal.result
@@ -179,3 +179,32 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select NULL AS `NULL`
+#
+# MDEV-20763 Table corruption or Assertion `btr_validate_index(index, 0, false)' failed in row_upd_sec_index_entry with virtual column and EMPTY_STRING_IS_NULL SQL mode
+#
+create table t1 (a int, b binary(1) generated always as (''), key(a,b));
+insert into t1 (a) values (1);
+set sql_mode= default;
+flush tables;
+update t1 set a = 2;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` binary(1) GENERATED ALWAYS AS (NULL) VIRTUAL,
+ KEY `a` (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a int, b binary(1) generated always as (''), key(a,b));
+insert into t1 (a) values (1);
+set sql_mode= 'empty_string_is_null';
+flush tables;
+update t1 set a = 2;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` binary(1) GENERATED ALWAYS AS ('') VIRTUAL,
+ KEY `a` (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
diff --git a/mysql-test/main/empty_string_literal.test b/mysql-test/main/empty_string_literal.test
index 71e98d872bb..9174a7714a2 100644
--- a/mysql-test/main/empty_string_literal.test
+++ b/mysql-test/main/empty_string_literal.test
@@ -6,3 +6,22 @@ USE test;
set @mode='EMPTY_STRING_IS_NULL';
--source include/empty_string_literal.inc
+
+--echo #
+--echo # MDEV-20763 Table corruption or Assertion `btr_validate_index(index, 0, false)' failed in row_upd_sec_index_entry with virtual column and EMPTY_STRING_IS_NULL SQL mode
+--echo #
+create table t1 (a int, b binary(1) generated always as (''), key(a,b));
+insert into t1 (a) values (1);
+set sql_mode= default;
+flush tables;
+update t1 set a = 2;
+show create table t1;
+drop table t1;
+
+create table t1 (a int, b binary(1) generated always as (''), key(a,b));
+insert into t1 (a) values (1);
+set sql_mode= 'empty_string_is_null';
+flush tables;
+update t1 set a = 2;
+show create table t1;
+drop table t1;
diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result
index c9eb0ef02dc..55c997eee16 100644
--- a/mysql-test/main/information_schema.result
+++ b/mysql-test/main/information_schema.result
@@ -2304,5 +2304,14 @@ create table t2 (n int);
insert into t1 set n = (select table_rows from information_schema.tables where table_name='t2');
drop table t1, t2;
#
+# MDEV-24593 Signal 11 when group by primary key of table joined to information_schema.columns
+#
+create table t1 (f varchar(64) primary key);
+select f from information_schema.columns i
+inner join t1 on f=i.column_name
+group by f;
+f
+drop table t1;
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test
index c3711e62c71..fb9eaa02bff 100644
--- a/mysql-test/main/information_schema.test
+++ b/mysql-test/main/information_schema.test
@@ -2008,6 +2008,16 @@ create table t2 (n int);
insert into t1 set n = (select table_rows from information_schema.tables where table_name='t2');
drop table t1, t2;
+
+--echo #
+--echo # MDEV-24593 Signal 11 when group by primary key of table joined to information_schema.columns
+--echo #
+create table t1 (f varchar(64) primary key);
+select f from information_schema.columns i
+inner join t1 on f=i.column_name
+group by f;
+drop table t1;
+
--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result
index a32f160853b..5ca0e099026 100644
--- a/mysql-test/main/parser.result
+++ b/mysql-test/main/parser.result
@@ -1788,6 +1788,15 @@ EXECUTE IMMEDIATE 'if(`systeminfo /FO LIST';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`systeminfo /FO LIST' at line 1
EXECUTE IMMEDIATE 'if(`systeminfo';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`systeminfo' at line 1
+#
+# MDEV-23666 Assertion failed in Lex_input_stream::body_utf8_append
+#
+SET @@sql_mode='ANSI_QUOTES';
+EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"' at line 1
+EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc';
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"abc' at line 1
+SET @@sql_mode=@save_sql_mode;
# End of 10.3 tests
#
# MDEV-19540: 10.4 allow lock options with SELECT in brackets
diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test
index 0bc470ceb9e..d9a6c2df191 100644
--- a/mysql-test/main/parser.test
+++ b/mysql-test/main/parser.test
@@ -1564,6 +1564,21 @@ EXECUTE IMMEDIATE 'if(`systeminfo /FO LIST';
--error ER_PARSE_ERROR
EXECUTE IMMEDIATE 'if(`systeminfo';
+--echo #
+--echo # MDEV-23666 Assertion failed in Lex_input_stream::body_utf8_append
+--echo #
+SET @@sql_mode='ANSI_QUOTES';
+
+# Without a patch execution of the following statements results in assertion
+# in Lex_input_stream::body_utf8_append on parsing the statement
+--error ER_PARSE_ERROR
+EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"';
+
+--error ER_PARSE_ERROR
+EXECUTE IMMEDIATE 'CREATE PROCEDURE p() UPDATE t SET c=\'\'"abc';
+
+SET @@sql_mode=@save_sql_mode;
+
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/main/processlist_notembedded.result b/mysql-test/main/processlist_notembedded.result
index 3c2671ff5e3..d5c25c0a1d9 100644
--- a/mysql-test/main/processlist_notembedded.result
+++ b/mysql-test/main/processlist_notembedded.result
@@ -1,7 +1,7 @@
#
# MDEV-20466: SHOW PROCESSLIST truncates query text on \0 bytes
#
-connect con1,localhost,root,,;
+connect con1,localhost,root;
connection con1;
SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync WAIT_FOR go';
connection default;
@@ -13,17 +13,21 @@ User
disconnect con1;
connection default;
SET DEBUG_SYNC = 'RESET';
-End of 5.5 tests
+#
+# End of 5.5 tests
+#
#
# MDEV-23752: SHOW EXPLAIN FOR thd waits for sleep
#
-connect con1,localhost,root,,;
-select sleep(100000);;
+connect con1,localhost,root;
+select sleep(100000);
connection default;
-SHOW EXPLAIN FOR con_id;
+SHOW EXPLAIN FOR $con_id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select sleep(100000)
-KILL QUERY con_id;
+KILL QUERY $con_id;
+#
# End of 10.2 tests
+#
diff --git a/mysql-test/main/processlist_notembedded.test b/mysql-test/main/processlist_notembedded.test
index 26021040c39..cc577200368 100644
--- a/mysql-test/main/processlist_notembedded.test
+++ b/mysql-test/main/processlist_notembedded.test
@@ -7,7 +7,7 @@ source include/count_sessions.inc;
--echo # MDEV-20466: SHOW PROCESSLIST truncates query text on \0 bytes
--echo #
-connect (con1,localhost,root,,);
+connect con1,localhost,root;
connection con1;
@@ -39,22 +39,22 @@ SET DEBUG_SYNC = 'RESET';
source include/wait_until_count_sessions.inc;
---echo End of 5.5 tests
+--echo #
+--echo # End of 5.5 tests
+--echo #
--echo #
--echo # MDEV-23752: SHOW EXPLAIN FOR thd waits for sleep
--echo #
---connect (con1,localhost,root,,)
+--connect con1,localhost,root
--let $con_id = `SELECT CONNECTION_ID()`
---send select sleep(100000);
+--send select sleep(100000)
--connection default
+evalp SHOW EXPLAIN FOR $con_id;
+evalp KILL QUERY $con_id;
---replace_result $con_id con_id
-eval SHOW EXPLAIN FOR $con_id;
-
---replace_result $con_id con_id
-eval KILL QUERY $con_id;
-
+--echo #
--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/main/sp-ucs2.result b/mysql-test/main/sp-ucs2.result
index ca448efa535..389fa946ad5 100644
--- a/mysql-test/main/sp-ucs2.result
+++ b/mysql-test/main/sp-ucs2.result
@@ -115,7 +115,6 @@ RETURN 'str';
END|
ERROR 42000: COLLATION 'ucs2_unicode_ci' is not valid for CHARACTER SET 'latin1'
SET NAMES utf8;
-DROP FUNCTION IF EXISTS bug48766;
CREATE FUNCTION bug48766 ()
RETURNS ENUM( 'w' ) CHARACTER SET ucs2
RETURN 0;
@@ -140,3 +139,13 @@ WHERE ROUTINE_NAME='bug48766';
DTD_IDENTIFIER
enum('а','б','в','г')
DROP FUNCTION bug48766;
+call mtr.add_suppression('invalid value in column mysql.proc.');
+set collation_connection=ucs2_general_ci;
+insert into mysql.proc (db, name, type, specific_name, language, sql_data_access, is_deterministic, security_type, param_list, returns, body, definer, created, modified, sql_mode, comment, character_set_client, collation_connection, db_collation, body_utf8 ) values ( 'a', 'a', 'function', 'bug14233_1', 'sql', 'reads_sql_data', 'no', 'definer', '', 'int(10)', 'select * from mysql.user', 'root@localhost', now(), '0000-00-00 00:00:00', '', '', '', '', '', 'select * from mysql.user' );
+select routine_name from information_schema.routines where routine_name='a';
+routine_name
+a
+Warnings:
+Warning 1601 Creation context of stored routine `a`.`a` is invalid
+set collation_connection=default;
+delete from mysql.proc where name='a';
diff --git a/mysql-test/main/sp-ucs2.test b/mysql-test/main/sp-ucs2.test
index a1aec8071b4..3276da3e257 100644
--- a/mysql-test/main/sp-ucs2.test
+++ b/mysql-test/main/sp-ucs2.test
@@ -151,9 +151,6 @@ delimiter ;|
# Bug#48766 SHOW CREATE FUNCTION returns extra data in return clause
#
SET NAMES utf8;
---disable_warnings
-DROP FUNCTION IF EXISTS bug48766;
---enable_warnings
#
# Test that Latin letters are not prepended with extra '\0'.
#
@@ -175,3 +172,13 @@ SELECT DTD_IDENTIFIER FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_NAME='bug48766';
DROP FUNCTION bug48766;
+
+#
+#
+#
+call mtr.add_suppression('invalid value in column mysql.proc.');
+set collation_connection=ucs2_general_ci;
+insert into mysql.proc (db, name, type, specific_name, language, sql_data_access, is_deterministic, security_type, param_list, returns, body, definer, created, modified, sql_mode, comment, character_set_client, collation_connection, db_collation, body_utf8 ) values ( 'a', 'a', 'function', 'bug14233_1', 'sql', 'reads_sql_data', 'no', 'definer', '', 'int(10)', 'select * from mysql.user', 'root@localhost', now(), '0000-00-00 00:00:00', '', '', '', '', '', 'select * from mysql.user' );
+select routine_name from information_schema.routines where routine_name='a';
+set collation_connection=default;
+delete from mysql.proc where name='a';
diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result
index ef3aed397ba..52bc3ccb0dc 100644
--- a/mysql-test/main/union.result
+++ b/mysql-test/main/union.result
@@ -2616,5 +2616,39 @@ Warnings:
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where `test`.`t2`.`a` < 5 except /* select#2 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` where `test`.`t3`.`a` < 5 union all /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` > 4
drop table t1,t2,t3;
#
+# MDEV-24387: Wrong number of decimal digits in certain UNION/Subqery
+# constellation
+#
+SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT * from (SELECT NULL) t;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def CAST(1 AS UNSIGNED) 246 2 1 Y 32896 0 63
+CAST(1 AS UNSIGNED)
+1
+NULL
+SELECT CAST(1 AS SIGNED) UNION ALL SELECT * from (SELECT NULL) t;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def CAST(1 AS SIGNED) 3 2 1 Y 32896 0 63
+CAST(1 AS SIGNED)
+1
+NULL
+SELECT CAST(1 AS SIGNED) UNION ALL SELECT * from (SELECT CAST(1 AS UNSIGNED)) t;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def CAST(1 AS SIGNED) 246 11 1 N 32897 0 63
+CAST(1 AS SIGNED)
+1
+1
+SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT NULL;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def CAST(1 AS UNSIGNED) 246 2 1 Y 32896 0 63
+CAST(1 AS UNSIGNED)
+1
+NULL
+SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT CAST(1 AS SIGNED);
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def CAST(1 AS UNSIGNED) 246 2 1 N 32897 0 63
+CAST(1 AS UNSIGNED)
+1
+1
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test
index 33adbb4603d..2e5a04a27f4 100644
--- a/mysql-test/main/union.test
+++ b/mysql-test/main/union.test
@@ -1866,5 +1866,23 @@ select * from t1 where a > 4;
drop table t1,t2,t3;
--echo #
+--echo # MDEV-24387: Wrong number of decimal digits in certain UNION/Subqery
+--echo # constellation
+--echo #
+
+--disable_ps_protocol
+--enable_metadata
+
+SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT * from (SELECT NULL) t;
+SELECT CAST(1 AS SIGNED) UNION ALL SELECT * from (SELECT NULL) t;
+SELECT CAST(1 AS SIGNED) UNION ALL SELECT * from (SELECT CAST(1 AS UNSIGNED)) t;
+
+SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT NULL;
+SELECT CAST(1 AS UNSIGNED) UNION ALL SELECT CAST(1 AS SIGNED);
+
+--disable_metadata
+--enable_ps_protocol
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/mysql-test/suite/federated/assisted_discovery.result b/mysql-test/suite/federated/assisted_discovery.result
index 4818ff7bb02..e8d6663e9bc 100644
--- a/mysql-test/suite/federated/assisted_discovery.result
+++ b/mysql-test/suite/federated/assisted_discovery.result
@@ -13,8 +13,7 @@ CREATE TABLE t1 (
`name` varchar(32) default 'name')
DEFAULT CHARSET=latin1;
connection master;
-CREATE TABLE t1 ENGINE=FEDERATED
-CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
+CREATE TABLE t1 ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -38,6 +37,9 @@ id group a\\b a\\ name
1 1 2 NULL foo
2 1 2 NULL fee
DROP TABLE t1;
+#
+# MDEV-11311 Create federated table does not work as expected
+#
create table t1 (
a bigint(20) not null auto_increment,
b bigint(20) not null,
@@ -57,8 +59,7 @@ t1 CREATE TABLE `t1` (
KEY `b` (`b`,`c`,`d`(255))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
connection master;
-create table t1 engine=federated
-connection='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
+create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -72,6 +73,12 @@ t1 CREATE TABLE `t1` (
drop table t1;
connection slave;
drop table t1;
+#
+# MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database
+#
+connection master;
+create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
+ERROR HY000: Unable to connect to foreign data source: Table 'test.t1' doesn't exist
connection master;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
diff --git a/mysql-test/suite/federated/assisted_discovery.test b/mysql-test/suite/federated/assisted_discovery.test
index fa83a2a8e19..bd32878f811 100644
--- a/mysql-test/suite/federated/assisted_discovery.test
+++ b/mysql-test/suite/federated/assisted_discovery.test
@@ -13,9 +13,7 @@ CREATE TABLE t1 (
connection master;
---replace_result $SLAVE_MYPORT SLAVE_PORT
-eval CREATE TABLE t1 ENGINE=FEDERATED
- CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
+evalp CREATE TABLE t1 ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
--replace_result $SLAVE_MYPORT SLAVE_PORT
SHOW CREATE TABLE t1;
@@ -30,9 +28,9 @@ connection slave;
SELECT * FROM t1;
DROP TABLE t1;
-#
-#
-#
+--echo #
+--echo # MDEV-11311 Create federated table does not work as expected
+--echo #
create table t1 (
a bigint(20) not null auto_increment,
b bigint(20) not null,
@@ -44,9 +42,7 @@ create table t1 (
show create table t1;
connection master;
---replace_result $SLAVE_MYPORT SLAVE_PORT
-eval create table t1 engine=federated
- connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
+evalp create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
--replace_result $SLAVE_MYPORT SLAVE_PORT
show create table t1;
drop table t1;
@@ -54,5 +50,12 @@ drop table t1;
connection slave;
drop table t1;
+--echo #
+--echo # MDEV-17227 Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database
+--echo #
+connection master;
+--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
+evalp create table t1 engine=federated connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
+
source include/federated_cleanup.inc;
diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result
index 6f45f072fb6..0fd879f8934 100644
--- a/mysql-test/suite/innodb/r/instant_alter_debug.result
+++ b/mysql-test/suite/innodb/r/instant_alter_debug.result
@@ -291,43 +291,6 @@ a b vb
5 NULL NULL
DROP TABLE t1;
#
-# MDEV-17899 Assertion failures on rollback of instant ADD/DROP
-# MDEV-18098 Crash after rollback of instant DROP COLUMN
-#
-SET @save_dbug = @@SESSION.debug_dbug;
-SET debug_dbug='+d,ib_commit_inplace_fail_1';
-CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,2);
-ALTER TABLE t1 DROP COLUMN b;
-ERROR HY000: Internal error: Injected error!
-ALTER TABLE t1 DROP COLUMN b;
-ERROR HY000: Internal error: Injected error!
-ALTER TABLE t1 ADD COLUMN c INT;
-ERROR HY000: Internal error: Injected error!
-SELECT * FROM t1;
-a b
-1 2
-DROP TABLE t1;
-CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
-ALTER TABLE t1 ADD COLUMN c INT;
-ERROR HY000: Internal error: Injected error!
-BEGIN;
-INSERT INTO t1 VALUES(1, 1);
-ROLLBACK;
-ALTER TABLE t1 DROP COLUMN b;
-ERROR HY000: Internal error: Injected error!
-INSERT INTO t1 values (1,1);
-SELECT * FROM t1;
-a b
-1 1
-DROP TABLE t1;
-SET debug_dbug = @save_dbug;
-SELECT variable_value-@old_instant instants
-FROM information_schema.global_status
-WHERE variable_name = 'innodb_instant_alter_column';
-instants
-22
-#
# MDEV-21045 AddressSanitizer: use-after-poison in mem_heap_dup / row_log_table_get_pk_col
#
CREATE TABLE t1 (a TEXT) ENGINE = InnoDB ROW_FORMAT=REDUNDANT;
@@ -370,6 +333,60 @@ SET DEBUG_SYNC='RESET';
disconnect con2;
DROP TABLE t1;
#
+# MDEV-24653 Assertion block->page.id.page_no() == index->page failed
+# in innobase_add_instant_try()
+#
+SET @saved_limit = @@GLOBAL.innodb_limit_optimistic_insert_debug;
+SET GLOBAL innodb_limit_optimistic_insert_debug = 2;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+ALTER TABLE t1 ADD COLUMN b INT;
+DELETE FROM t1;
+InnoDB 0 transactions not purged
+ALTER TABLE t1 ADD COLUMN c INT;
+SELECT * FROM t1;
+a b c
+DROP TABLE t1;
+SET GLOBAL innodb_limit_optimistic_insert_debug = @saved_limit;
+# End of 10.3 tests
+#
+# MDEV-17899 Assertion failures on rollback of instant ADD/DROP
+# MDEV-18098 Crash after rollback of instant DROP COLUMN
+#
+SET @save_dbug = @@SESSION.debug_dbug;
+SET debug_dbug='+d,ib_commit_inplace_fail_1';
+CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,2);
+ALTER TABLE t1 DROP COLUMN b;
+ERROR HY000: Internal error: Injected error!
+ALTER TABLE t1 DROP COLUMN b;
+ERROR HY000: Internal error: Injected error!
+ALTER TABLE t1 ADD COLUMN c INT;
+ERROR HY000: Internal error: Injected error!
+SELECT * FROM t1;
+a b
+1 2
+DROP TABLE t1;
+CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
+ALTER TABLE t1 ADD COLUMN c INT;
+ERROR HY000: Internal error: Injected error!
+BEGIN;
+INSERT INTO t1 VALUES(1, 1);
+ROLLBACK;
+ALTER TABLE t1 DROP COLUMN b;
+ERROR HY000: Internal error: Injected error!
+INSERT INTO t1 values (1,1);
+SELECT * FROM t1;
+a b
+1 1
+DROP TABLE t1;
+SET debug_dbug = @save_dbug;
+SELECT variable_value-@old_instant instants
+FROM information_schema.global_status
+WHERE variable_name = 'innodb_instant_alter_column';
+instants
+28
+#
# MDEV-24512 Assertion failed in rec_is_metadata()
# in btr_discard_only_page_on_level()
#
@@ -383,4 +400,5 @@ SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit;
SELECT * FROM t1;
c2 c
DROP TABLE t1;
+# End of 10.4 tests
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test
index 774de9202b5..37f3fe023c7 100644
--- a/mysql-test/suite/innodb/t/instant_alter_debug.test
+++ b/mysql-test/suite/innodb/t/instant_alter_debug.test
@@ -326,42 +326,6 @@ SELECT * FROM t1;
DROP TABLE t1;
--echo #
---echo # MDEV-17899 Assertion failures on rollback of instant ADD/DROP
---echo # MDEV-18098 Crash after rollback of instant DROP COLUMN
---echo #
-
-SET @save_dbug = @@SESSION.debug_dbug;
-SET debug_dbug='+d,ib_commit_inplace_fail_1';
-CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,2);
---error ER_INTERNAL_ERROR
-ALTER TABLE t1 DROP COLUMN b;
---error ER_INTERNAL_ERROR
-ALTER TABLE t1 DROP COLUMN b;
---error ER_INTERNAL_ERROR
-ALTER TABLE t1 ADD COLUMN c INT;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
---error ER_INTERNAL_ERROR
-ALTER TABLE t1 ADD COLUMN c INT;
-BEGIN;
-INSERT INTO t1 VALUES(1, 1);
-ROLLBACK;
---error ER_INTERNAL_ERROR
-ALTER TABLE t1 DROP COLUMN b;
-INSERT INTO t1 values (1,1);
-SELECT * FROM t1;
-DROP TABLE t1;
-
-SET debug_dbug = @save_dbug;
-
-SELECT variable_value-@old_instant instants
-FROM information_schema.global_status
-WHERE variable_name = 'innodb_instant_alter_column';
-
---echo #
--echo # MDEV-21045 AddressSanitizer: use-after-poison in mem_heap_dup / row_log_table_get_pk_col
--echo #
CREATE TABLE t1 (a TEXT) ENGINE = InnoDB ROW_FORMAT=REDUNDANT;
@@ -414,6 +378,63 @@ SET DEBUG_SYNC='RESET';
DROP TABLE t1;
--echo #
+--echo # MDEV-24653 Assertion block->page.id.page_no() == index->page failed
+--echo # in innobase_add_instant_try()
+--echo #
+
+SET @saved_limit = @@GLOBAL.innodb_limit_optimistic_insert_debug;
+SET GLOBAL innodb_limit_optimistic_insert_debug = 2;
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+ALTER TABLE t1 ADD COLUMN b INT;
+DELETE FROM t1;
+--source include/wait_all_purged.inc
+ALTER TABLE t1 ADD COLUMN c INT;
+
+SELECT * FROM t1;
+DROP TABLE t1;
+SET GLOBAL innodb_limit_optimistic_insert_debug = @saved_limit;
+
+--echo # End of 10.3 tests
+
+--echo #
+--echo # MDEV-17899 Assertion failures on rollback of instant ADD/DROP
+--echo # MDEV-18098 Crash after rollback of instant DROP COLUMN
+--echo #
+
+SET @save_dbug = @@SESSION.debug_dbug;
+SET debug_dbug='+d,ib_commit_inplace_fail_1';
+CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,2);
+--error ER_INTERNAL_ERROR
+ALTER TABLE t1 DROP COLUMN b;
+--error ER_INTERNAL_ERROR
+ALTER TABLE t1 DROP COLUMN b;
+--error ER_INTERNAL_ERROR
+ALTER TABLE t1 ADD COLUMN c INT;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int, b int) ENGINE=InnoDB;
+--error ER_INTERNAL_ERROR
+ALTER TABLE t1 ADD COLUMN c INT;
+BEGIN;
+INSERT INTO t1 VALUES(1, 1);
+ROLLBACK;
+--error ER_INTERNAL_ERROR
+ALTER TABLE t1 DROP COLUMN b;
+INSERT INTO t1 values (1,1);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+SET debug_dbug = @save_dbug;
+
+SELECT variable_value-@old_instant instants
+FROM information_schema.global_status
+WHERE variable_name = 'innodb_instant_alter_column';
+
+--echo #
--echo # MDEV-24512 Assertion failed in rec_is_metadata()
--echo # in btr_discard_only_page_on_level()
--echo #
@@ -429,4 +450,6 @@ SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit;
SELECT * FROM t1;
DROP TABLE t1;
+--echo # End of 10.4 tests
+
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result
index 7d98aba7fc3..b50bf047265 100644
--- a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result
+++ b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result
@@ -232,6 +232,38 @@ CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY,
f1 VARCHAR(200),FULLTEXT fidx(f1))engine=innodb;
ALTER TABLE t1 DROP index fidx, ADD FULLTEXT INDEX(f1);
DROP TABLE t1;
+#
+# MDEV-21478 Inplace alter fails to report error when
+# FTS_DOC_ID is added
+SET NAMES utf8;
+CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
+ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY;
+ALTER TABLE t1 DROP COLUMN FTS_DOC_ıD;
+ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+DROP TABLE t1;
+CREATE TABLE t1 (f1 INT NOT NULL)ENGINE=InnoDB;
+ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+ERROR 42000: Incorrect column name 'FTS_DOC_İD'
+ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY;
+ERROR 42000: Incorrect column name 'FTS_DOC_İD'
+ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=COPY;
+ERROR 42000: Incorrect column name 'fts_doc_id'
+ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=INPLACE;
+ERROR 42000: Incorrect column name 'fts_doc_id'
+ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY;
+ERROR 42000: Incorrect column name 'fts_doc_id'
+ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+ERROR 42000: Incorrect column name 'fts_doc_id'
+ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=COPY;
+ERROR 42000: Incorrect column name 'FTS_DOC_ID'
+ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+ERROR 42000: Incorrect column name 'FTS_DOC_ID'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB;
ALTER TABLE t1 ADD FULLTEXT KEY(a), ADD COLUMN b VARCHAR(3), ADD FULLTEXT KEY(b);
DROP TABLE t1;
@@ -244,3 +276,4 @@ CREATE TABLE t1
ENGINE=InnoDB;
ALTER TABLE t1 ADD c SERIAL;
DROP TABLE t1;
+# End of 10.3 tests
diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test
index cca110f3550..7c56811a2d9 100644
--- a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test
+++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test
@@ -278,6 +278,47 @@ CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY,
ALTER TABLE t1 DROP index fidx, ADD FULLTEXT INDEX(f1);
DROP TABLE t1;
+--echo #
+--echo # MDEV-21478 Inplace alter fails to report error when
+--echo # FTS_DOC_ID is added
+
+SET NAMES utf8;
+
+CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
+ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY;
+ALTER TABLE t1 DROP COLUMN FTS_DOC_ıD;
+ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+DROP TABLE t1;
+
+CREATE TABLE t1 (f1 INT NOT NULL)ENGINE=InnoDB;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=COPY;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=INPLACE;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=COPY;
+
+--error ER_WRONG_COLUMN_NAME
+ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
+
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
# Add more than one FTS index
CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB;
ALTER TABLE t1 ADD FULLTEXT KEY(a), ADD COLUMN b VARCHAR(3), ADD FULLTEXT KEY(b);
@@ -294,3 +335,5 @@ CREATE TABLE t1
ENGINE=InnoDB;
ALTER TABLE t1 ADD c SERIAL;
DROP TABLE t1;
+
+--echo # End of 10.3 tests
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 758229618db..83a4f5b5eda 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -27,6 +27,7 @@
set sql_mode='';
set storage_engine=Aria;
set enforce_storage_engine=NULL;
+set alter_algorithm=DEFAULT;
set @have_innodb= (select count(engine) from information_schema.engines where engine='INNODB' and support != 'NO');
diff --git a/sql/field.h b/sql/field.h
index b3bc2d4dbea..b04e29ac6fb 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1870,7 +1870,7 @@ public:
uchar null_bit_arg, utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
const DTCollation &collation);
- uint decimals() const { return NOT_FIXED_DEC; }
+ uint decimals() const { return is_created_from_null_item ? 0 : NOT_FIXED_DEC; }
int save_in_field(Field *to) { return save_in_field_str(to); }
bool memcpy_field_possible(const Field *from) const
{
diff --git a/sql/sp.cc b/sql/sp.cc
index 0b553ebf7a1..de1a8a04756 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -2949,7 +2949,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
buf->append(STRING_WITH_LEN(" RETURN "));
else
buf->append(STRING_WITH_LEN(" RETURNS "));
- buf->append(&returns);
+ buf->append(returns.str, returns.length); // Not \0 terminated
}
buf->append('\n');
switch (chistics.daccess) {
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index e196765b6bc..cac225e01e7 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -2289,6 +2289,8 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
Return the quote character, to have the parser fail on syntax error.
*/
m_ptr= (char *) m_tok_start + 1;
+ if (m_echo)
+ m_cpp_ptr= (char *) m_cpp_tok_start + 1;
return quote_char;
}
int var_length= my_charlen(cs, get_ptr() - 1, get_end_of_query());
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a6aee4db341..4bbe5ce9141 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1807,7 +1807,7 @@ int JOIN::init_join_caches()
int
JOIN::optimize_inner()
{
- DBUG_ENTER("JOIN::optimize");
+ DBUG_ENTER("JOIN::optimize_inner");
subq_exit_fl= false;
do_send_rows = (unit->select_limit_cnt) ? 1 : 0;
@@ -1880,6 +1880,10 @@ JOIN::optimize_inner()
table_count= select_lex->leaf_tables.elements;
+ if (select_lex->options & OPTION_SCHEMA_TABLE &&
+ optimize_schema_tables_memory_usage(select_lex->leaf_tables))
+ DBUG_RETURN(1);
+
if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
DBUG_RETURN(-1);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 09d8b6b81a1..12da17e7f10 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -5099,7 +5099,8 @@ public:
Sql_condition::enum_warning_level *level,
const char* msg, Sql_condition ** cond_hdl)
{
- if (sql_errno == ER_TRG_NO_DEFINER || sql_errno == ER_TRG_NO_CREATION_CTX)
+ if (sql_errno == ER_TRG_NO_DEFINER || sql_errno == ER_TRG_NO_CREATION_CTX
+ || sql_errno == ER_PARSE_ERROR)
return true;
if (*level != Sql_condition::WARN_LEVEL_ERROR)
@@ -8704,55 +8705,64 @@ end:
}
-static int optimize_schema_tables_memory_usage(TABLE_LIST *table_list)
+bool optimize_schema_tables_memory_usage(List<TABLE_LIST> &tables)
{
- TABLE *table= table_list->table;
- THD *thd=table->in_use;
- if (!table->is_created())
- {
- TMP_TABLE_PARAM *p= table_list->schema_table_param;
- TMP_ENGINE_COLUMNDEF *from_recinfo, *to_recinfo;
- DBUG_ASSERT(table->s->keys == 0);
- DBUG_ASSERT(table->s->uniques == 0);
-
- uchar *cur= table->field[0]->ptr;
- /* first recinfo could be a NULL bitmap, not an actual Field */
- from_recinfo= to_recinfo= p->start_recinfo + (cur != table->record[0]);
- for (uint i=0; i < table->s->fields; i++, from_recinfo++)
- {
- Field *field= table->field[i];
- DBUG_ASSERT(field->vcol_info == 0);
- DBUG_ASSERT(from_recinfo->length);
- DBUG_ASSERT(from_recinfo->length == field->pack_length_in_rec());
- if (bitmap_is_set(table->read_set, i))
+ List_iterator<TABLE_LIST> tli(tables);
+
+ while (TABLE_LIST *table_list= tli++)
+ {
+ TABLE *table= table_list->table;
+ THD *thd=table->in_use;
+
+ if (!table_list->schema_table || !thd->fill_information_schema_tables())
+ continue;
+
+ if (!table->is_created())
+ {
+ TMP_TABLE_PARAM *p= table_list->schema_table_param;
+ TMP_ENGINE_COLUMNDEF *from_recinfo, *to_recinfo;
+ DBUG_ASSERT(table->s->keys == 0);
+ DBUG_ASSERT(table->s->uniques == 0);
+
+ uchar *cur= table->field[0]->ptr;
+ /* first recinfo could be a NULL bitmap, not an actual Field */
+ from_recinfo= to_recinfo= p->start_recinfo + (cur != table->record[0]);
+ for (uint i=0; i < table->s->fields; i++, from_recinfo++)
{
- field->move_field(cur);
- *to_recinfo++= *from_recinfo;
- cur+= from_recinfo->length;
+ Field *field= table->field[i];
+ DBUG_ASSERT(field->vcol_info == 0);
+ DBUG_ASSERT(from_recinfo->length);
+ DBUG_ASSERT(from_recinfo->length == field->pack_length_in_rec());
+ if (bitmap_is_set(table->read_set, i))
+ {
+ field->move_field(cur);
+ *to_recinfo++= *from_recinfo;
+ cur+= from_recinfo->length;
+ }
+ else
+ {
+ field= new (thd->mem_root) Field_string(cur, 0, field->null_ptr,
+ field->null_bit, Field::NONE,
+ &field->field_name, field->dtcollation());
+ field->init(table);
+ field->field_index= i;
+ DBUG_ASSERT(field->pack_length_in_rec() == 0);
+ table->field[i]= field;
+ }
}
- else
+ if ((table->s->reclength= (ulong)(cur - table->record[0])) == 0)
{
- field= new (thd->mem_root) Field_string(cur, 0, field->null_ptr,
- field->null_bit, Field::NONE,
- &field->field_name, field->dtcollation());
- field->init(table);
- field->field_index= i;
- DBUG_ASSERT(field->pack_length_in_rec() == 0);
- table->field[i]= field;
+ /* all fields were optimized away. Force a non-0-length row */
+ table->s->reclength= to_recinfo->length= 1;
+ to_recinfo++;
}
- }
- if ((table->s->reclength= (ulong)(cur - table->record[0])) == 0)
- {
- /* all fields were optimized away. Force a non-0-length row */
- table->s->reclength= to_recinfo->length= 1;
- to_recinfo++;
- }
- p->recinfo= to_recinfo;
+ p->recinfo= to_recinfo;
- // TODO switch from Aria to Memory if all blobs were optimized away?
- if (instantiate_tmp_table(table, p->keyinfo, p->start_recinfo, &p->recinfo,
- table_list->select_lex->options | thd->variables.option_bits))
- return 1;
+ // TODO switch from Aria to Memory if all blobs were optimized away?
+ if (instantiate_tmp_table(table, p->keyinfo, p->start_recinfo, &p->recinfo,
+ table_list->select_lex->options | thd->variables.option_bits))
+ return 1;
+ }
}
return 0;
}
@@ -8778,9 +8788,6 @@ bool optimize_schema_tables_reads(JOIN *join)
TABLE_LIST *table_list= tab->table->pos_in_table_list;
if (table_list->schema_table && thd->fill_information_schema_tables())
{
- if (optimize_schema_tables_memory_usage(table_list))
- DBUG_RETURN(1);
-
/* A value of 0 indicates a dummy implementation */
if (table_list->schema_table->fill_table == 0)
continue;
diff --git a/sql/sql_show.h b/sql/sql_show.h
index 39cbc35230a..c1845d8c1b3 100644
--- a/sql/sql_show.h
+++ b/sql/sql_show.h
@@ -238,6 +238,7 @@ public:
};
bool optimize_schema_tables_reads(JOIN *join);
+bool optimize_schema_tables_memory_usage(List<TABLE_LIST> &tables);
/* Handle the ignored database directories list for SHOW/I_S. */
bool ignore_db_dirs_init();
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index e8a9bd771f7..7230c9c5f60 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -2599,7 +2599,7 @@ error:
if (has_vers_fields && table->versioned(VERS_TIMESTAMP))
{
store_record(table, record[2]);
- if (vers_insert_history_row(table))
+ if (unlikely(error= vers_insert_history_row(table)))
{
restore_record(table, record[2]);
goto error;
diff --git a/sql/table.cc b/sql/table.cc
index 084b441e4c6..4be8f8c91bb 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1127,7 +1127,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
thd->stmt_arena= table->expr_arena;
thd->update_charset(&my_charset_utf8mb4_general_ci, table->s->table_charset);
expr_str.append(&parse_vcol_keyword);
- thd->variables.sql_mode &= ~MODE_NO_BACKSLASH_ESCAPES;
+ thd->variables.sql_mode &= ~(MODE_NO_BACKSLASH_ESCAPES | MODE_EMPTY_STRING_IS_NULL);
while (pos < end)
{
@@ -3210,9 +3210,8 @@ ret:
if (unlikely(thd->is_error() || error))
{
thd->clear_error();
- my_error(ER_SQL_DISCOVER_ERROR, MYF(0),
- plugin_name(db_plugin)->str, db.str, table_name.str,
- sql_copy);
+ my_error(ER_SQL_DISCOVER_ERROR, MYF(0), hton_name(hton)->str,
+ db.str, table_name.str, sql_copy);
DBUG_RETURN(HA_ERR_GENERIC);
}
/* Treat the table as normal table from binary logging point of view */
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index ff5bb4b3ec4..afbb929c372 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -363,9 +363,6 @@ int ha_heap::info(uint flag)
{
HEAPINFO hp_info;
- if (!table)
- return 0;
-
(void) heap_info(file,&hp_info,flag);
errkey= hp_info.errkey;
diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc
index 9c5216dc015..a8db6e22c0a 100644
--- a/storage/innobase/btr/btr0pcur.cc
+++ b/storage/innobase/btr/btr0pcur.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 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
@@ -151,7 +151,8 @@ before_first:
ut_ad(!page_rec_is_infimum(rec));
if (UNIV_UNLIKELY(rec_is_metadata(rec, *index))) {
- ut_ad(index->table->instant);
+ ut_ad(index->table->instant
+ || block->page.id.page_no() != index->page);
ut_ad(page_get_n_recs(block->frame) == 1);
ut_ad(page_is_leaf(block->frame));
ut_ad(!page_has_prev(block->frame));
@@ -169,7 +170,9 @@ before_first:
rec = page_rec_get_next(rec);
if (page_rec_is_supremum(rec)) {
ut_ad(page_has_next(block->frame)
- || rec_is_alter_metadata(p, *index));
+ || rec_is_alter_metadata(p, *index)
+ || block->page.id.page_no()
+ != index->page);
goto before_first;
}
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 2734bd5a77b..97714e9dfa7 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -5907,11 +5907,13 @@ add_all_virtual:
const rec_t* rec = btr_pcur_get_rec(&pcur);
que_thr_t* thr = pars_complete_graph_for_exec(
NULL, trx, ctx->heap, NULL);
+ const bool is_root = block->page.id.page_no() == index->page;
dberr_t err = DB_SUCCESS;
if (rec_is_metadata(rec, *index)) {
ut_ad(page_rec_is_user_rec(rec));
- if (!rec_is_alter_metadata(rec, *index)
+ if (is_root
+ && !rec_is_alter_metadata(rec, *index)
&& !index->table->instant
&& !page_has_next(block->frame)
&& page_rec_is_last(rec, block->frame)) {
@@ -5993,7 +5995,8 @@ add_all_virtual:
}
btr_pcur_close(&pcur);
goto func_exit;
- } else if (page_rec_is_supremum(rec) && !index->table->instant) {
+ } else if (is_root && page_rec_is_supremum(rec)
+ && !index->table->instant) {
empty_table:
/* The table is empty. */
ut_ad(fil_page_index_page_check(block->frame));
@@ -6523,6 +6526,7 @@ new_clustered_failed:
}
if (dict_col_name_is_reserved(field->field_name.str)) {
+wrong_column_name:
dict_mem_table_free(ctx->new_table);
ctx->new_table = ctx->old_table;
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
@@ -6530,6 +6534,21 @@ new_clustered_failed:
goto new_clustered_failed;
}
+ /** Note the FTS_DOC_ID name is case sensitive due
+ to internal query parser.
+ FTS_DOC_ID column must be of BIGINT NOT NULL type
+ and it should be in all capitalized characters */
+ if (!innobase_strcasecmp(field->field_name.str,
+ FTS_DOC_ID_COL_NAME)) {
+ if (col_type != DATA_INT
+ || field->real_maybe_null()
+ || col_len != sizeof(doc_id_t)
+ || strcmp(field->field_name.str,
+ FTS_DOC_ID_COL_NAME)) {
+ goto wrong_column_name;
+ }
+ }
+
if (is_virtual) {
dict_mem_table_add_v_col(
ctx->new_table, ctx->heap,
diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h
index 6ba457cdc40..f20fdc250c5 100644
--- a/storage/innobase/include/trx0sys.h
+++ b/storage/innobase/include/trx0sys.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 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
@@ -847,8 +847,10 @@ public:
#endif
/** Latest recovered binlog offset */
uint64_t recovered_binlog_offset;
- /** Latest recovred binlog file name */
+ /** Latest recovered binlog file name */
char recovered_binlog_filename[TRX_SYS_MYSQL_LOG_NAME_LEN];
+ /** FIL_PAGE_LSN of the page with the latest recovered binlog metadata */
+ lsn_t recovered_binlog_lsn;
/**
diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc
index 3e29ad838c9..ed1499e1392 100644
--- a/storage/innobase/trx/trx0rseg.cc
+++ b/storage/innobase/trx/trx0rseg.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2020, MariaDB Corporation.
+Copyright (c) 2017, 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
@@ -443,8 +443,13 @@ static
void
trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr)
{
- trx_rsegf_t* rseg_header = trx_rsegf_get_new(
- rseg->space->id, rseg->page_no, mtr);
+ /* This is based on trx_rsegf_get_new().
+ We need to access buf_block_t. */
+ buf_block_t *block = buf_page_get(
+ page_id_t(rseg->space->id, rseg->page_no), 0, RW_S_LATCH, mtr);
+ buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
+
+ const trx_rsegf_t* rseg_header = TRX_RSEG + block->frame;
if (mach_read_from_4(rseg_header + TRX_RSEG_FORMAT) == 0) {
trx_id_t id = mach_read_from_8(rseg_header
@@ -455,32 +460,20 @@ trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr)
}
if (rseg_header[TRX_RSEG_BINLOG_NAME]) {
- const char* binlog_name = reinterpret_cast<const char*>
- (rseg_header) + TRX_RSEG_BINLOG_NAME;
+ lsn_t lsn = std::max(block->page.newest_modification,
+ mach_read_from_8(FIL_PAGE_LSN
+ + block->frame));
compile_time_assert(TRX_RSEG_BINLOG_NAME_LEN == sizeof
trx_sys.recovered_binlog_filename);
-
- int cmp = *trx_sys.recovered_binlog_filename
- ? strncmp(binlog_name,
- trx_sys.recovered_binlog_filename,
- TRX_RSEG_BINLOG_NAME_LEN)
- : 1;
-
- if (cmp >= 0) {
- uint64_t binlog_offset = mach_read_from_8(
- rseg_header + TRX_RSEG_BINLOG_OFFSET);
- if (cmp) {
- memcpy(trx_sys.
- recovered_binlog_filename,
- binlog_name,
- TRX_RSEG_BINLOG_NAME_LEN);
- trx_sys.recovered_binlog_offset
- = binlog_offset;
- } else if (binlog_offset >
- trx_sys.recovered_binlog_offset) {
- trx_sys.recovered_binlog_offset
- = binlog_offset;
- }
+ if (lsn > trx_sys.recovered_binlog_lsn) {
+ trx_sys.recovered_binlog_lsn = lsn;
+ trx_sys.recovered_binlog_offset
+ = mach_read_from_8(
+ rseg_header
+ + TRX_RSEG_BINLOG_OFFSET);
+ memcpy(trx_sys.recovered_binlog_filename,
+ rseg_header + TRX_RSEG_BINLOG_NAME,
+ TRX_RSEG_BINLOG_NAME_LEN);
}
#ifdef WITH_WSREP
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 1f734439ffe..aa99bc157c9 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -2523,9 +2523,6 @@ int ha_maria::info(uint flag)
MARIA_INFO maria_info;
char name_buff[FN_REFLEN];
- if (!table)
- return 0;
-
(void) maria_status(file, &maria_info, flag);
if (flag & HA_STATUS_VARIABLE)
{