diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-03-25 17:18:15 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-03-25 17:18:15 +0200 |
commit | 8b480df63ec76963fd96d2e00b911a801b912591 (patch) | |
tree | 4bc43fd486fbbfef4e05977a2080c4e1dbb59da9 | |
parent | c0ba036b774b8e35567dccce421890d2199f30ce (diff) | |
parent | dbc0d576a3f402ae52423fe424ed0a68f49537ef (diff) | |
download | mariadb-git-8b480df63ec76963fd96d2e00b911a801b912591.tar.gz |
Merge 10.3 into 10.4
45 files changed, 337 insertions, 337 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 895fd489a23..de89f6a93b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,8 @@ ENDIF() MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} + ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/Internal/CPack) # Use a default manufacturer if no manufacturer was identified. IF(NOT DEFINED MANUFACTURER) diff --git a/cmake/CPackRPM.cmake b/cmake/Internal/CPack/CPackRPM.cmake index 326013f06b3..2729667e319 100644 --- a/cmake/CPackRPM.cmake +++ b/cmake/Internal/CPack/CPackRPM.cmake @@ -50,7 +50,11 @@ endif() # load the original CPackRPM.cmake set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) unset(CMAKE_MODULE_PATH) -include(CPackRPM) +if (CMAKE_VERSION VERSION_GREATER "3.12.99") + include(Internal/CPack/CPackRPM) +else() + include(CPackRPM) +endif() set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) restore(LICENSE) diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index e082f95177e..e9c9b971d87 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2011, 2018, MariaDB Corporation +# Copyright (c) 2011, 2019, MariaDB Corporation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -87,6 +87,7 @@ IF(FEATURE_SET) ENDIF() SET(WITH_INNODB_SNAPPY OFF CACHE STRING "") +SET(WITH_NUMA 0 CACHE BOOL "") IF(WIN32) SET(INSTALL_MYSQLTESTDIR "" CACHE STRING "") SET(INSTALL_SQLBENCHDIR "" CACHE STRING "") @@ -96,20 +97,17 @@ ELSEIF(RPM) SET(WITH_ZLIB system CACHE STRING "") SET(CHECKMODULE /usr/bin/checkmodule CACHE STRING "") SET(SEMODULE_PACKAGE /usr/bin/semodule_package CACHE STRING "") - SET(WITH_LIBARCHIVE ON CACHE STRING "") SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "") ELSEIF(DEB) SET(WITH_SSL system CACHE STRING "") SET(WITH_ZLIB system CACHE STRING "") SET(WITH_LIBWRAP ON) SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON) - SET(WITH_LIBARCHIVE ON CACHE STRING "") SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "") ELSE() SET(WITH_SSL bundled CACHE STRING "") SET(WITH_ZLIB bundled CACHE STRING "") SET(WITH_JEMALLOC static CACHE STRING "") - SET(WITH_LIBARCHIVE STATIC CACHE STRING "") SET(PLUGIN_AUTH_SOCKET STATIC CACHE STRING "") ENDIF() diff --git a/mysql-test/include/log_slow_debug_common.inc b/mysql-test/include/log_slow_debug_common.inc new file mode 100644 index 00000000000..f8c9075e1e2 --- /dev/null +++ b/mysql-test/include/log_slow_debug_common.inc @@ -0,0 +1,20 @@ +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; + +CREATE SEQUENCE s4; +ALTER SEQUENCE s4 MAXVALUE 100; +PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP SEQUENCE s4; diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result index 3b1912f4a55..73417d0d64e 100644 --- a/mysql-test/main/default.result +++ b/mysql-test/main/default.result @@ -434,7 +434,7 @@ drop table t1; # create table t1 (a int); create or replace table t1 (a int default b, b int default a); -ERROR 01000: Expression for field `a` is refering to uninitialized field `b` +ERROR 01000: Expression for field `a` is referring to uninitialized field `b` show create table t1; ERROR 42S02: Table 'test.t1' doesn't exist # @@ -451,16 +451,16 @@ create or replace table t1 (a varchar(128) default @@version); create or replace table t1 (a int not null, b int as (a)); create or replace table t1 (a int not null, b int default (a+1)); create or replace table t1 (a int default a); -ERROR 01000: Expression for field `a` is refering to uninitialized field `a` +ERROR 01000: Expression for field `a` is referring to uninitialized field `a` create or replace table t1 (a int default b, b int default (1+1)); create or replace table t1 (a int default 1, b int as (c), c int as (a+1)); -ERROR 01000: Expression for field `b` is refering to uninitialized field `c` +ERROR 01000: Expression for field `b` is referring to uninitialized field `c` CREATE TABLE t1 (a INT DEFAULT (DEFAULT(a))); -ERROR 01000: Expression for field `a` is refering to uninitialized field `a` +ERROR 01000: Expression for field `a` is referring to uninitialized field `a` CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)), b INT DEFAULT(DEFAULT(a))); -ERROR 01000: Expression for field `a` is refering to uninitialized field `b` +ERROR 01000: Expression for field `a` is referring to uninitialized field `b` CREATE TABLE t1 (a INT DEFAULT(DEFAULT(b)) NOT NULL, b INT DEFAULT(DEFAULT(a)) NOT NULL); -ERROR 01000: Expression for field `a` is refering to uninitialized field `b` +ERROR 01000: Expression for field `a` is referring to uninitialized field `b` # # Allow defaults to refer to not default fields # @@ -519,7 +519,7 @@ Got one of the listed errors CREATE TABLE t1 (a INT DEFAULT(?)); Got one of the listed errors CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a)); -ERROR 01000: Expression for field `a` is refering to uninitialized field `b` +ERROR 01000: Expression for field `a` is referring to uninitialized field `b` CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy')); ERROR HY000: Function or expression 'name_const()' cannot be used in the DEFAULT clause of `a` CREATE TABLE t1 (a INT DEFAULT COUNT(*)); @@ -3369,7 +3369,7 @@ a b t 4 5 5 the value of the DEFAULT(a), that is b drop table t1; create table t1 (col1 int default(-(default(col1)))); -ERROR 01000: Expression for field `col1` is refering to uninitialized field `col1` +ERROR 01000: Expression for field `col1` is referring to uninitialized field `col1` create table t1 (col int default (yearweek((exp(710))))); ERROR 22003: DOUBLE value is out of range in 'exp(710)' # diff --git a/mysql-test/main/log_slow_debug.result b/mysql-test/main/log_slow_debug.result index 6409aed8535..2da10949315 100644 --- a/mysql-test/main/log_slow_debug.result +++ b/mysql-test/main/log_slow_debug.result @@ -25,7 +25,7 @@ $$ # # Expect all admin statements in the slow log (ON,DEFAULT) # -SET @@GLOBAL.log_slow_admin_statements=ON; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=DEFAULT; TRUNCATE TABLE mysql.slow_log; CREATE TABLE t1 (a INT); @@ -41,7 +41,13 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +CREATE SEQUENCE s4; +ALTER SEQUENCE s4 MAXVALUE 100; +PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP SEQUENCE s4; +CALL show_slow_log(); sql_text [slow] TRUNCATE TABLE mysql.slow_log [slow] CREATE TABLE t1 (a INT) @@ -57,10 +63,16 @@ sql_text [slow] ALTER TABLE t4 MODIFY a INT DEFAULT 1 [slow] DEALLOCATE PREPARE stmt [slow] DROP TABLE t4 +[slow] CREATE SEQUENCE s4 +[slow] ALTER SEQUENCE s4 MAXVALUE 100 +[slow] PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101' +[slow] ALTER SEQUENCE s4 MAXVALUE=101 +[slow] DEALLOCATE PREPARE stmt +[slow] DROP SEQUENCE s4 # # Expect all admin statements in the slow log (ON,admin) # -SET @@GLOBAL.log_slow_admin_statements=ON; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=admin; TRUNCATE TABLE mysql.slow_log; CREATE TABLE t1 (a INT); @@ -76,6 +88,12 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; +CREATE SEQUENCE s4; +ALTER SEQUENCE s4 MAXVALUE 100; +PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP SEQUENCE s4; CALL show_slow_log(); sql_text [slow] CREATE INDEX t1a ON t1 (a) @@ -83,10 +101,12 @@ sql_text [slow] ALTER TABLE t2 RENAME t2 [slow] RENAME TABLE t2 TO t3 [slow] ALTER TABLE t4 MODIFY a INT DEFAULT 1 +[slow] ALTER SEQUENCE s4 MAXVALUE 100 +[slow] ALTER SEQUENCE s4 MAXVALUE=101 # # Expect none of admin DDL statements in the slow log (ON,filesort) # -SET @@GLOBAL.log_slow_admin_statements=ON; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=filesort; TRUNCATE TABLE mysql.slow_log; CREATE TABLE t1 (a INT); @@ -102,12 +122,63 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; +CREATE SEQUENCE s4; +ALTER SEQUENCE s4 MAXVALUE 100; +PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP SEQUENCE s4; CALL show_slow_log(); sql_text # # Expect none of admin statements in the slow log (OFF,DEFAULT) # +SET @@SESSION.log_slow_admin_statements=OFF; +SET log_slow_filter=DEFAULT; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CREATE SEQUENCE s4; +ALTER SEQUENCE s4 MAXVALUE 100; +PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP SEQUENCE s4; +CALL show_slow_log(); +sql_text +[slow] TRUNCATE TABLE mysql.slow_log +[slow] CREATE TABLE t1 (a INT) +[slow] DROP TABLE t1 +[slow] CREATE TABLE t2 (a INT) +[slow] DROP TABLE t3 +[slow] CREATE TABLE t4 (a INT) +[slow] PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1' +[slow] DEALLOCATE PREPARE stmt +[slow] DROP TABLE t4 +[slow] CREATE SEQUENCE s4 +[slow] PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101' +[slow] DEALLOCATE PREPARE stmt +[slow] DROP SEQUENCE s4 +# +# Expect all admin statements in the slow log (GLOBAL OFF,LOCAL ON,DEFAULT) +# In the original implementation, this combination disabled slow log for admin commands. +# However, instead of this exception in GLOBAL vs LOCAL variable behaviour, +# we should make max_system_variables.log_slow_admin_statements=0 +# prevent enabling globally suppressed logging by setting the session variable to ON. +# SET @@GLOBAL.log_slow_admin_statements=OFF; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=DEFAULT; TRUNCATE TABLE mysql.slow_log; CREATE TABLE t1 (a INT); @@ -123,7 +194,13 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +CREATE SEQUENCE s4; +ALTER SEQUENCE s4 MAXVALUE 100; +PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP SEQUENCE s4; +CALL show_slow_log(); sql_text [slow] TRUNCATE TABLE mysql.slow_log [slow] CREATE TABLE t1 (a INT) @@ -139,6 +216,12 @@ sql_text [slow] ALTER TABLE t4 MODIFY a INT DEFAULT 1 [slow] DEALLOCATE PREPARE stmt [slow] DROP TABLE t4 +[slow] CREATE SEQUENCE s4 +[slow] ALTER SEQUENCE s4 MAXVALUE 100 +[slow] PREPARE stmt FROM 'ALTER SEQUENCE s4 MAXVALUE=101' +[slow] ALTER SEQUENCE s4 MAXVALUE=101 +[slow] DEALLOCATE PREPARE stmt +[slow] DROP SEQUENCE s4 # # Clean up # diff --git a/mysql-test/main/log_slow_debug.test b/mysql-test/main/log_slow_debug.test index 7945328fee3..5bacda31d93 100644 --- a/mysql-test/main/log_slow_debug.test +++ b/mysql-test/main/log_slow_debug.test @@ -34,45 +34,21 @@ DELIMITER ;$$ --echo # Expect all admin statements in the slow log (ON,DEFAULT) --echo # -SET @@GLOBAL.log_slow_admin_statements=ON; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=DEFAULT; TRUNCATE TABLE mysql.slow_log; -CREATE TABLE t1 (a INT); -CREATE INDEX t1a ON t1 (a); -DROP INDEX t1a ON t1; -DROP TABLE t1; -CREATE TABLE t2 (a INT); -ALTER TABLE t2 RENAME t2; -RENAME TABLE t2 TO t3; -DROP TABLE t3; -CREATE TABLE t4 (a INT); -PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; -EXECUTE stmt; -DEALLOCATE PREPARE stmt; -DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +--source include/log_slow_debug_common.inc +CALL show_slow_log(); --echo # --echo # Expect all admin statements in the slow log (ON,admin) --echo # -SET @@GLOBAL.log_slow_admin_statements=ON; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=admin; TRUNCATE TABLE mysql.slow_log; -CREATE TABLE t1 (a INT); -CREATE INDEX t1a ON t1 (a); -DROP INDEX t1a ON t1; -DROP TABLE t1; -CREATE TABLE t2 (a INT); -ALTER TABLE t2 RENAME t2; -RENAME TABLE t2 TO t3; -DROP TABLE t3; -CREATE TABLE t4 (a INT); -PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; -EXECUTE stmt; -DEALLOCATE PREPARE stmt; -DROP TABLE t4; +--source include/log_slow_debug_common.inc CALL show_slow_log(); @@ -80,22 +56,10 @@ CALL show_slow_log(); --echo # Expect none of admin DDL statements in the slow log (ON,filesort) --echo # -SET @@GLOBAL.log_slow_admin_statements=ON; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=filesort; TRUNCATE TABLE mysql.slow_log; -CREATE TABLE t1 (a INT); -CREATE INDEX t1a ON t1 (a); -DROP INDEX t1a ON t1; -DROP TABLE t1; -CREATE TABLE t2 (a INT); -ALTER TABLE t2 RENAME t2; -RENAME TABLE t2 TO t3; -DROP TABLE t3; -CREATE TABLE t4 (a INT); -PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; -EXECUTE stmt; -DEALLOCATE PREPARE stmt; -DROP TABLE t4; +--source include/log_slow_debug_common.inc CALL show_slow_log(); @@ -103,23 +67,27 @@ CALL show_slow_log(); --echo # Expect none of admin statements in the slow log (OFF,DEFAULT) --echo # +SET @@SESSION.log_slow_admin_statements=OFF; +SET log_slow_filter=DEFAULT; +TRUNCATE TABLE mysql.slow_log; +--source include/log_slow_debug_common.inc +CALL show_slow_log(); + + +--echo # +--echo # Expect all admin statements in the slow log (GLOBAL OFF,LOCAL ON,DEFAULT) +--echo # In the original implementation, this combination disabled slow log for admin commands. +--echo # However, instead of this exception in GLOBAL vs LOCAL variable behaviour, +--echo # we should make max_system_variables.log_slow_admin_statements=0 +--echo # prevent enabling globally suppressed logging by setting the session variable to ON. +--echo # + SET @@GLOBAL.log_slow_admin_statements=OFF; +SET @@SESSION.log_slow_admin_statements=ON; SET log_slow_filter=DEFAULT; TRUNCATE TABLE mysql.slow_log; -CREATE TABLE t1 (a INT); -CREATE INDEX t1a ON t1 (a); -DROP INDEX t1a ON t1; -DROP TABLE t1; -CREATE TABLE t2 (a INT); -ALTER TABLE t2 RENAME t2; -RENAME TABLE t2 TO t3; -DROP TABLE t3; -CREATE TABLE t4 (a INT); -PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; -EXECUTE stmt; -DEALLOCATE PREPARE stmt; -DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +--source include/log_slow_debug_common.inc +CALL show_slow_log(); --echo # diff --git a/mysql-test/suite/gcol/r/gcol_column_def_options_innodb.result b/mysql-test/suite/gcol/r/gcol_column_def_options_innodb.result index 1f3a1b641ba..6c2cd8a18c8 100644 --- a/mysql-test/suite/gcol/r/gcol_column_def_options_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_column_def_options_innodb.result @@ -255,9 +255,9 @@ a b c 4 -4 -3 drop table t1; create table t1 (a int, b int generated always as(-b) virtual, c int generated always as (b + 1) virtual); -ERROR 01000: Expression for field `b` is refering to uninitialized field `b` +ERROR 01000: Expression for field `b` is referring to uninitialized field `b` create table t1 (a int, b int generated always as(-c) virtual, c int generated always as (b + 1) virtual); -ERROR 01000: Expression for field `b` is refering to uninitialized field `c` +ERROR 01000: Expression for field `b` is referring to uninitialized field `c` create table t1 (pk int auto_increment primary key, col_int_nokey int generated always as (pk + col_int_key) stored, col_int_key int); ERROR HY000: Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `pk` # Bug#20339347: FAIL TO USE CREATE ....SELECT STATEMENT TO CREATE A NEW TABLE @@ -277,7 +277,7 @@ drop table t1,tt; # THD->CHANGE_LIST.IS_EMPTY() # CREATE TABLE t1(a bigint AS (a between 1 and 1)); -ERROR 01000: Expression for field `a` is refering to uninitialized field `a` +ERROR 01000: Expression for field `a` is referring to uninitialized field `a` # Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES # IN FIND_FIELD_IN_TABLE # diff --git a/mysql-test/suite/gcol/r/gcol_column_def_options_myisam.result b/mysql-test/suite/gcol/r/gcol_column_def_options_myisam.result index 40029079943..85370d42af8 100644 --- a/mysql-test/suite/gcol/r/gcol_column_def_options_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_column_def_options_myisam.result @@ -255,9 +255,9 @@ a b c 4 -4 -3 drop table t1; create table t1 (a int, b int generated always as(-b) virtual, c int generated always as (b + 1) virtual); -ERROR 01000: Expression for field `b` is refering to uninitialized field `b` +ERROR 01000: Expression for field `b` is referring to uninitialized field `b` create table t1 (a int, b int generated always as(-c) virtual, c int generated always as (b + 1) virtual); -ERROR 01000: Expression for field `b` is refering to uninitialized field `c` +ERROR 01000: Expression for field `b` is referring to uninitialized field `c` create table t1 (pk int auto_increment primary key, col_int_nokey int generated always as (pk + col_int_key) stored, col_int_key int); ERROR HY000: Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `pk` # Bug#20339347: FAIL TO USE CREATE ....SELECT STATEMENT TO CREATE A NEW TABLE @@ -277,7 +277,7 @@ drop table t1,tt; # THD->CHANGE_LIST.IS_EMPTY() # CREATE TABLE t1(a bigint AS (a between 1 and 1)); -ERROR 01000: Expression for field `a` is refering to uninitialized field `a` +ERROR 01000: Expression for field `a` is referring to uninitialized field `a` # Bug#20757211: GENERATED COLUMNS: ALTER TABLE CRASHES # IN FIND_FIELD_IN_TABLE # diff --git a/mysql-test/suite/innodb/r/innodb_bug14676111.result b/mysql-test/suite/innodb/r/innodb_bug14676111.result index f8f0b3fbccb..738e152b9fa 100644 --- a/mysql-test/suite/innodb/r/innodb_bug14676111.result +++ b/mysql-test/suite/innodb/r/innodb_bug14676111.result @@ -42,7 +42,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; CLUST_INDEX_SIZE -5 +4 set global innodb_limit_optimistic_insert_debug = 10000; connection con2; rollback; @@ -54,7 +54,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; CLUST_INDEX_SIZE -3 +2 begin; insert into t1 values (2); rollback; @@ -64,7 +64,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK select CLUST_INDEX_SIZE from information_schema.INNODB_SYS_TABLESTATS where NAME = 'test/t1'; CLUST_INDEX_SIZE -2 +1 begin; insert into t1 values (2); rollback; diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index 9eb4616949c..f23a1b2367f 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -336,7 +336,7 @@ drop table t1; # MDEV-5611: self-referencing virtual column # create table t1 (a int, b int as (b is null) virtual); -ERROR 01000: Expression for field `b` is refering to uninitialized field `b` +ERROR 01000: Expression for field `b` is referring to uninitialized field `b` create table t1 (a int as (1+1), b int as (a is null) virtual); drop table t1; # end of 5.3 tests diff --git a/sql/filesort.cc b/sql/filesort.cc index c76295e666a..bd14fad8f51 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -36,11 +36,6 @@ #include "sql_select.h" #include "debug_sync.h" -/// How to write record_ref. -#define WRITE_REF(file,from) \ -if (my_b_write((file),(uchar*) (from),param->ref_length)) \ - DBUG_RETURN(1); - /* functions defined in this file */ static uchar *read_buffpek_from_file(IO_CACHE *buffer_file, uint count, diff --git a/sql/handler.h b/sql/handler.h index d008249c81c..4c1a53cc570 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4741,7 +4741,6 @@ public: virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; } virtual int discard_or_import_tablespace(my_bool discard) { return (my_errno=HA_ERR_WRONG_COMMAND); } - virtual void prepare_for_alter() { return; } virtual void drop_table(const char *name); virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0; diff --git a/sql/item.cc b/sql/item.cc index 7559acd7adb..22303128d7e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -837,7 +837,7 @@ bool Item_field::register_field_in_write_map(void *arg) } /** - Check that we are not refering to any not yet initialized fields + Check that we are not referring to any not yet initialized fields Fields are initialized in this order: - All fields that have default value as a constant are initialized first. diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index cc2ac272458..3827f83da5f 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7625,7 +7625,7 @@ ER_ERROR_EVALUATING_EXPRESSION ER_CALCULATING_DEFAULT_VALUE eng "Got an error when calculating default value for %`s" ER_EXPRESSION_REFERS_TO_UNINIT_FIELD 01000 - eng "Expression for field %`-.64s is refering to uninitialized field %`s" + eng "Expression for field %`-.64s is referring to uninitialized field %`s" ER_PARTITION_DEFAULT_ERROR eng "Only one DEFAULT partition allowed" ukr "Припустимо мати тільки один DEFAULT розділ" diff --git a/sql/sql_derived.h b/sql/sql_derived.h index 621a6e9ec24..abfdb007072 100644 --- a/sql/sql_derived.h +++ b/sql/sql_derived.h @@ -24,20 +24,6 @@ bool mysql_handle_derived(LEX *lex, uint phases); bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases); bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived); -/** - Cleans up the SELECT_LEX_UNIT for the derived table (if any). - - @param thd Thread handler - @param lex LEX for this thread - @param derived TABLE_LIST for the derived table - - @retval false Success - @retval true Failure -*/ -bool mysql_derived_cleanup(THD *thd, LEX *lex, TABLE_LIST *derived); - -Item *delete_not_needed_parts(THD *thd, Item *cond); - bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived); #endif /* SQL_DERIVED_INCLUDED */ diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fcde5deb7f6..22b1cfc91a3 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -717,7 +717,6 @@ void LEX::start(THD *thd_arg) describe= 0; analyze_stmt= 0; explain_json= false; - subqueries= FALSE; context_analysis_only= 0; derived_tables= 0; safe_to_cache_query= 1; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 8e983551dbe..63500274afa 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB Corporation + Copyright (c) 2010, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -808,12 +808,6 @@ public: friend bool mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *sel); friend bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, bool open_view_no_parse); - friend bool mysql_derived_prepare(THD *thd, LEX *lex, - TABLE_LIST *orig_table_list); - friend bool mysql_derived_merge(THD *thd, LEX *lex, - TABLE_LIST *orig_table_list); - friend bool TABLE_LIST::init_derived(THD *thd, bool init_view); - friend class st_select_lex; private: void fast_exclude(); @@ -3302,7 +3296,7 @@ public: enum enum_yes_no_unknown tx_chain, tx_release; bool safe_to_cache_query; - bool subqueries, ignore; + bool ignore; bool next_is_main; // use "main" SELECT_LEX for nrxt allocation; bool next_is_down; // use "main" SELECT_LEX for nrxt allocation; st_parsing_options parsing_options; @@ -3326,7 +3320,6 @@ public: sp_name *spname; bool sp_lex_in_use; // Keep track on lex usage in SPs for error handling bool all_privileges; - bool proxy_priv; sp_pcontext *spcont; @@ -4635,18 +4628,6 @@ public: }; /** - Input parameters to the parser. -*/ -struct Parser_input -{ - bool m_compute_digest; - - Parser_input() - : m_compute_digest(false) - {} -}; - -/** Internal state of the parser. The complete state consist of: - state data used during lexical parsing, @@ -4673,7 +4654,6 @@ public: ~Parser_state() {} - Parser_input m_input; Lex_input_stream m_lip; Yacc_state m_yacc; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6b609833ef0..87ac04ea0ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4643,8 +4643,7 @@ end_with_restore_list: select_lex->order_list.elements, select_lex->order_list.first, unit->select_limit_cnt, - lex->duplicates, lex->ignore, - &found, &updated); + lex->ignore, &found, &updated); MYSQL_UPDATE_DONE(res, found, updated); /* mysql_update return 2 if we need to switch to multi-update */ if (up_result != 2) @@ -7790,7 +7789,6 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex) if (select_lex->set_nest_level(old_nest_level + 1)) DBUG_RETURN(1); SELECT_LEX_UNIT *unit; - lex->subqueries= TRUE; /* first select_lex of subselect or derived table */ if (!(unit= lex->alloc_unit())) DBUG_RETURN(1); @@ -10174,8 +10172,7 @@ bool parse_sql(THD *thd, Parser_state *parser_state, /* Start Digest */ parser_state->m_digest_psi= MYSQL_DIGEST_START(thd->m_statement_psi); - if (parser_state->m_input.m_compute_digest || - (parser_state->m_digest_psi != NULL)) + if (parser_state->m_digest_psi != NULL) { /* If either: diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6f964b6901f..7253f33f769 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -7323,11 +7323,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, strlen(part_elem->tablespace_name), cs); else { - char *ts= showing_table->s->tablespace; - if(ts) - table->field[24]->store(ts, strlen(ts), cs); - else - table->field[24]->set_null(); + table->field[24]->set_null(); } } return; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c4f11b1ab81..30578405c21 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -321,7 +321,6 @@ int cut_fields_for_portion_of_time(THD *thd, TABLE *table, order_num number of elemen in ORDER BY clause order ORDER BY clause list limit limit clause - handle_duplicates how to handle duplicates RETURN 0 - OK @@ -336,8 +335,8 @@ int mysql_update(THD *thd, List<Item> &values, COND *conds, uint order_num, ORDER *order, - ha_rows limit, - enum enum_duplicates handle_duplicates, bool ignore, + ha_rows limit, + bool ignore, ha_rows *found_return, ha_rows *updated_return) { bool using_limit= limit != HA_POS_ERROR; diff --git a/sql/sql_update.h b/sql/sql_update.h index 4c6f89d8468..8457fe8f154 100644 --- a/sql/sql_update.h +++ b/sql/sql_update.h @@ -31,8 +31,7 @@ bool check_unique_table(THD *thd, TABLE_LIST *table_list); int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields, List<Item> &values,COND *conds, uint order_num, ORDER *order, ha_rows limit, - enum enum_duplicates handle_duplicates, bool ignore, - ha_rows *found_return, ha_rows *updated_return); + bool ignore, ha_rows *found_return, ha_rows *updated_return); bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List<Item> *fields, List<Item> *values, COND *conds, ulonglong options, diff --git a/sql/sql_view.cc b/sql/sql_view.cc index ec1141668b5..3014065d28b 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1725,7 +1725,6 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, view_select->linkage= DERIVED_TABLE_TYPE; table->updatable= 0; table->effective_with_check= VIEW_CHECK_NONE; - old_lex->subqueries= TRUE; table->derived= &lex->unit; } diff --git a/sql/structs.h b/sql/structs.h index 1eac31d8659..743dee66c57 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -164,9 +164,6 @@ typedef struct st_key { */ Index_statistics *collected_stats; - union { - int bdb_return_if_eq; - } handler; TABLE *table; LEX_CSTRING comment; /** reference to the list of options or NULL */ diff --git a/sql/table.cc b/sql/table.cc index 1feba22ffc0..b86298ef49d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1251,7 +1251,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, if (check_constraint_ptr) *check_constraint_ptr= 0; - /* Check that expressions aren't refering to not yet initialized fields */ + /* Check that expressions aren't referring to not yet initialized fields */ for (field_ptr= table->field; *field_ptr; field_ptr++) { Field *field= *field_ptr; diff --git a/sql/table.h b/sql/table.h index 2d2510c24fd..865824bf36f 100644 --- a/sql/table.h +++ b/sql/table.h @@ -764,9 +764,6 @@ struct TABLE_SHARE /* For sequence tables, the current sequence state */ SEQUENCE *sequence; - /* Name of the tablespace used for this table */ - char *tablespace; - #ifdef WITH_PARTITION_STORAGE_ENGINE /* filled in when reading from frm */ bool auto_partitioned; @@ -884,12 +881,6 @@ struct TABLE_SHARE set_table_cache_key(key_buff, key_length); } - inline bool honor_global_locks() - { - return ((table_category == TABLE_CATEGORY_USER) - || (table_category == TABLE_CATEGORY_SYSTEM)); - } - inline bool require_write_privileges() { return (table_category == TABLE_CATEGORY_LOG); diff --git a/sql/vers_string.h b/sql/vers_string.h index 9d8ca358565..2349cc0cac1 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -103,8 +103,4 @@ public: typedef Lex_cstring_with_compare<Compare_identifiers> Lex_ident; typedef Lex_cstring_with_compare<Compare_table_names> Lex_table_name; -#define XSTRING_WITH_LEN(X) (X).ptr(), (X).length() -#define DB_WITH_LEN(X) (X).db.str, (X).db.length -#define TABLE_NAME_WITH_LEN(X) (X).table_name.str, (X).table_name.length - #endif // VERS_STRING_INCLUDED diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 223814a12be..6723045b9f6 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -377,8 +377,7 @@ btr_root_adjust_on_import( page = buf_block_get_frame(block); page_zip = buf_block_get_page_zip(block); - if (!page_is_root(page)) { - + if (!fil_page_index_page_check(page) || page_has_siblings(page)) { err = DB_CORRUPTION; } else if (dict_index_is_clust(index)) { @@ -1074,18 +1073,13 @@ btr_page_get_father_block( return(btr_page_get_father_node_ptr(offsets, heap, cursor, mtr)); } -/************************************************************//** -Seeks to the upper level node pointer to a page. -It is assumed that mtr holds an x-latch on the tree. */ -static -void -btr_page_get_father( -/*================*/ - dict_index_t* index, /*!< in: b-tree index */ - buf_block_t* block, /*!< in: child page in the index */ - mtr_t* mtr, /*!< in: mtr */ - btr_cur_t* cursor) /*!< out: cursor on node pointer record, - its page x-latched */ +/** Seek to the parent page of a B-tree page. +@param[in,out] index b-tree +@param[in] block child page +@param[in,out] mtr mini-transaction +@param[out] cursor cursor pointing to the x-latched parent page */ +void btr_page_get_father(dict_index_t* index, buf_block_t* block, mtr_t* mtr, + btr_cur_t* cursor) { mem_heap_t* heap; rec_t* rec @@ -1172,11 +1166,11 @@ btr_free_root_check( buf_block_dbg_add_level(block, SYNC_TREE_NODE); if (fil_page_index_page_check(block->frame) - && index_id == btr_page_get_index_id(block->frame)) { + && index_id == btr_page_get_index_id(block->frame)) { /* This should be a root page. It should not be possible to reassign the same index_id for some other index in the tablespace. */ - ut_ad(page_is_root(block->frame)); + ut_ad(!page_has_siblings(block->frame)); } else { block = NULL; } @@ -1326,7 +1320,8 @@ btr_free_but_not_root( ibool finished; mtr_t mtr; - ut_ad(page_is_root(block->frame)); + ut_ad(fil_page_index_page_check(block->frame)); + ut_ad(!page_has_siblings(block->frame)); leaf_loop: mtr_start(&mtr); mtr_set_log_mode(&mtr, log_mode); @@ -1397,7 +1392,6 @@ btr_free_if_exists( return; } - ut_ad(page_is_root(root->frame)); btr_free_but_not_root(root, mtr->get_log_mode()); mtr->set_named_space_id(page_id.space()); btr_free_root(root, mtr); @@ -1415,8 +1409,6 @@ void btr_free(const page_id_t page_id) buf_block_t* block = buf_page_get(page_id, 0, RW_X_LATCH, &mtr); if (block) { - ut_ad(page_is_root(block->frame)); - btr_free_but_not_root(block, MTR_LOG_NO_REDO); btr_free_root(block, &mtr); } @@ -1563,12 +1555,17 @@ btr_page_reorganize_low( ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); btr_assert_not_corrupted(block, index); + ut_ad(fil_page_index_page_check(block->frame)); + ut_ad(index->is_dummy + || block->page.id.space() == index->table->space->id); + ut_ad(index->is_dummy + || block->page.id.page_no() != index->page + || !page_has_siblings(page)); #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ data_size1 = page_get_data_size(page); max_ins_size1 = page_get_max_insert_size_after_reorganize(page, 1); - /* Turn logging off */ mtr_log_t log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); @@ -1626,7 +1623,7 @@ btr_page_reorganize_low( || page_get_max_trx_id(page) == 0 || (dict_index_is_sec_or_ibuf(index) ? page_is_leaf(temp_page) - : page_is_root(temp_page))); + : block->page.id.page_no() == index->page)); /* If innodb_log_compressed_pages is ON, page reorganize should log the compressed page image.*/ @@ -1691,7 +1688,7 @@ btr_page_reorganize_low( #endif /* UNIV_ZIP_DEBUG */ if (!recovery) { - if (page_is_root(temp_page) + if (block->page.id.page_no() == index->page && fil_page_get_type(temp_page) == FIL_PAGE_TYPE_INSTANT) { /* Preserve the PAGE_INSTANT information. */ ut_ad(!page_zip); @@ -1892,6 +1889,8 @@ btr_page_empty( ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(page_zip == buf_block_get_page_zip(block)); + ut_ad(!index->is_dummy); + ut_ad(index->table->space->id == block->page.id.space()); #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ @@ -1904,7 +1903,8 @@ btr_page_empty( /* Preserve PAGE_ROOT_AUTO_INC when creating a clustered index root page. */ const ib_uint64_t autoinc - = dict_index_is_clust(index) && page_is_root(page) + = dict_index_is_clust(index) + && index->page == block->page.id.page_no() ? page_get_autoinc(page) : 0; @@ -1930,7 +1930,10 @@ void btr_set_instant(buf_block_t* root, const dict_index_t& index, mtr_t* mtr) ut_ad(index.n_core_fields > 0); ut_ad(index.n_core_fields < REC_MAX_N_FIELDS); ut_ad(index.is_instant()); - ut_ad(page_is_root(root->frame)); + ut_ad(fil_page_get_type(root->frame) == FIL_PAGE_TYPE_INSTANT + || fil_page_get_type(root->frame) == FIL_PAGE_INDEX); + ut_ad(!page_has_siblings(root->frame)); + ut_ad(root->page.id.page_no() == index.page); rec_t* infimum = page_get_infimum_rec(root->frame); rec_t* supremum = page_get_supremum_rec(root->frame); @@ -3505,33 +3508,6 @@ btr_set_min_rec_mark( } /*************************************************************//** -Deletes on the upper level the node pointer to a page. */ -void -btr_node_ptr_delete( -/*================*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: page whose node pointer is deleted */ - mtr_t* mtr) /*!< in: mtr */ -{ - btr_cur_t cursor; - ibool compressed; - dberr_t err; - - ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); - - /* Delete node pointer on father page */ - btr_page_get_father(index, block, mtr, &cursor); - - compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, - BTR_CREATE_FLAG, false, mtr); - ut_a(err == DB_SUCCESS); - - if (!compressed) { - btr_cur_compress_if_useful(&cursor, FALSE, mtr); - } -} - -/*************************************************************//** If page is the only on its level, this function moves its records to the father page, thus reducing the tree height. @return father block */ @@ -3982,7 +3958,7 @@ retry: lock_rec_free_all_from_discard_page(block); lock_mutex_exit(); } else { - btr_node_ptr_delete(index, block, mtr); + btr_cur_node_ptr_delete(&father_cursor, mtr); if (!dict_table_is_locking_disabled(index->table)) { lock_update_merge_left( merge_block, orig_pred, block); @@ -4255,8 +4231,9 @@ err_exit: /*************************************************************//** Discards a page that is the only page on its level. This will empty the whole B-tree, leaving just an empty root page. This function -should never be reached, because btr_compress(), which is invoked in +should almost never be reached, because btr_compress(), which is invoked in delete operations, calls btr_lift_page_up() to flatten the B-tree. */ +ATTRIBUTE_COLD static void btr_discard_only_page_on_level( @@ -4268,6 +4245,8 @@ btr_discard_only_page_on_level( ulint page_level = 0; trx_id_t max_trx_id; + ut_ad(!index->is_dummy); + /* Save the PAGE_MAX_TRX_ID from the leaf page. */ max_trx_id = page_get_max_trx_id(buf_block_get_frame(block)); @@ -4279,7 +4258,8 @@ btr_discard_only_page_on_level( ut_a(page_get_n_recs(page) == 1); ut_a(page_level == btr_page_get_level(page)); ut_a(!page_has_siblings(page)); - + ut_ad(fil_page_index_page_check(page)); + ut_ad(block->page.id.space() == index->table->space->id); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); btr_search_drop_page_hash_index(block); @@ -4306,7 +4286,7 @@ btr_discard_only_page_on_level( /* block is the root page, which must be empty, except for the node pointer to the (now discarded) block(s). */ - ut_ad(page_is_root(block->frame)); + ut_ad(!page_has_siblings(block->frame)); #ifdef UNIV_BTR_DEBUG if (!dict_index_is_ibuf(index)) { @@ -4385,10 +4365,7 @@ btr_discard_page( buf_block_t* block; page_t* page; rec_t* node_ptr; -#ifdef UNIV_DEBUG btr_cur_t parent_cursor; - bool parent_is_different = false; -#endif block = btr_cur_get_block(cursor); index = btr_cur_get_index(cursor); @@ -4402,13 +4379,11 @@ btr_discard_page( MONITOR_INC(MONITOR_INDEX_DISCARD); -#ifdef UNIV_DEBUG if (dict_index_is_spatial(index)) { rtr_page_get_father(index, block, mtr, cursor, &parent_cursor); } else { btr_page_get_father(index, block, mtr, &parent_cursor); } -#endif /* Decide the page which will inherit the locks */ @@ -4416,7 +4391,7 @@ btr_discard_page( right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr); const ulint zip_size = index->table->space->zip_size(); - + ut_d(bool parent_is_different = false); if (left_page_no != FIL_NULL) { merge_block = btr_block_get( page_id_t(index->table->space_id, left_page_no), @@ -4472,15 +4447,9 @@ btr_discard_page( } if (dict_index_is_spatial(index)) { - btr_cur_t father_cursor; - - /* Since rtr_node_ptr_delete doesn't contain get father - node ptr, so, we need to get father node ptr first and then - delete it. */ - rtr_page_get_father(index, block, mtr, cursor, &father_cursor); - rtr_node_ptr_delete(&father_cursor, mtr); + rtr_node_ptr_delete(&parent_cursor, mtr); } else { - btr_node_ptr_delete(index, block, mtr); + btr_cur_node_ptr_delete(&parent_cursor, mtr); } /* Remove the page from the level list */ @@ -4519,6 +4488,12 @@ btr_discard_page( we cannot use btr_check_node_ptr() */ ut_ad(parent_is_different || btr_check_node_ptr(index, merge_block, mtr)); + + if (btr_cur_get_block(&parent_cursor)->page.id.page_no() == index->page + && !page_has_siblings(btr_cur_get_page(&parent_cursor)) + && page_get_n_recs(btr_cur_get_page(&parent_cursor)) == 1) { + btr_lift_page_up(index, merge_block, mtr); + } } #ifdef UNIV_BTR_PRINT diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 40bcbd33ec9..434f5392cfa 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -626,7 +626,11 @@ index root page. @return whether the page is corrupted */ bool btr_cur_instant_root_init(dict_index_t* index, const page_t* page) { - ut_ad(page_is_root(page)); + ut_ad(!index->is_dummy); + ut_ad(fil_page_index_page_check(page)); + ut_ad(!page_has_siblings(page)); + ut_ad(page_get_space_id(page) == index->table->space_id); + ut_ad(page_get_page_no(page) == index->page); ut_ad(!page_is_comp(page) == !dict_table_is_comp(index->table)); ut_ad(index->is_primary()); ut_ad(!index->is_instant()); @@ -5670,14 +5674,14 @@ btr_cur_optimistic_delete_func( ut_ad(flags == 0 || flags == BTR_CREATE_FLAG); ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor), MTR_MEMO_PAGE_X_FIX)); - ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor), - MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr->is_named_space(cursor->index->table->space)); + ut_ad(!cursor->index->is_dummy); /* This is intended only for leaf page deletions */ block = btr_cur_get_block(cursor); + ut_ad(block->page.id.space() == cursor->index->table->space->id); ut_ad(page_is_leaf(buf_block_get_frame(block))); ut_ad(!dict_index_is_online_ddl(cursor->index) || dict_index_is_clust(cursor->index) @@ -5685,7 +5689,7 @@ btr_cur_optimistic_delete_func( rec = btr_cur_get_rec(cursor); - if (UNIV_UNLIKELY(page_is_root(block->frame) + if (UNIV_UNLIKELY(block->page.id.page_no() == cursor->index->page && page_get_n_recs(block->frame) == 1 + (cursor->index->is_instant() && !rec_is_metadata(rec, *cursor->index)))) { @@ -5863,6 +5867,8 @@ btr_cur_pessimistic_delete( | MTR_MEMO_SX_LOCK)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr->is_named_space(index->table->space)); + ut_ad(!index->is_dummy); + ut_ad(block->page.id.space() == index->table->space->id); if (!has_reserved_extents) { /* First reserve enough free space for the file segments @@ -5916,7 +5922,7 @@ btr_cur_pessimistic_delete( lock_update_delete(block, rec); } - if (!page_is_root(page)) { + if (block->page.id.page_no() != index->page) { if (page_get_n_recs(page) < 2) { goto discard_page; } @@ -6030,10 +6036,11 @@ discard_page: on a page, we have to change the parent node pointer so that it is equal to the new leftmost node pointer on the page */ - - btr_node_ptr_delete(index, block, mtr); + btr_cur_t cursor; + btr_page_get_father(index, block, mtr, &cursor); + btr_cur_node_ptr_delete(&cursor, mtr); const ulint level = btr_page_get_level(page); - + // FIXME: reuse the node_ptr from above dtuple_t* node_ptr = dict_index_build_node_ptr( index, next_rec, block->page.id.page_no(), heap, level); @@ -6099,6 +6106,23 @@ return_after_reservations: return(ret); } +/** Delete the node pointer in a parent page. +@param[in,out] parent cursor pointing to parent record +@param[in,out] mtr mini-transaction */ +void btr_cur_node_ptr_delete(btr_cur_t* parent, mtr_t* mtr) +{ + ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(parent), + MTR_MEMO_PAGE_X_FIX)); + dberr_t err; + ibool compressed = btr_cur_pessimistic_delete(&err, TRUE, parent, + BTR_CREATE_FLAG, false, + mtr); + ut_a(err == DB_SUCCESS); + if (!compressed) { + btr_cur_compress_if_useful(parent, FALSE, mtr); + } +} + /*******************************************************************//** Adds path information to the cursor for the current page, for which the binary search has been performed. */ diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index ffdc448a68e..0775dfe5e5f 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (C) 2013, 2014 Facebook, Inc. All Rights Reserved. -Copyright (C) 2014, 2018, MariaDB Corporation. +Copyright (C) 2014, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -181,7 +181,8 @@ btr_defragment_add_index( return NULL; } - ut_ad(page_is_root(page)); + ut_ad(fil_page_index_page_check(page)); + ut_ad(!page_has_siblings(page)); if (page_is_leaf(page)) { // Index root is a leaf page, no need to defragment. @@ -481,6 +482,7 @@ btr_defragment_merge_pages( ULINT_UNDEFINED); } } + btr_cur_t parent; if (n_recs_to_move == n_recs) { /* The whole page is merged with the previous page, free it. */ @@ -490,7 +492,8 @@ btr_defragment_merge_pages( btr_level_list_remove( index->table->space_id, zip_size, from_page, index, mtr); - btr_node_ptr_delete(index, from_block, mtr); + btr_page_get_father(index, from_block, mtr, &parent); + btr_cur_node_ptr_delete(&parent, mtr); /* btr_blob_dbg_remove(from_page, index, "btr_defragment_n_pages"); */ btr_page_free(index, from_block, mtr); @@ -508,7 +511,9 @@ btr_defragment_merge_pages( lock_update_split_and_merge(to_block, orig_pred, from_block); - btr_node_ptr_delete(index, from_block, mtr); + // FIXME: reuse the node_ptr! + btr_page_get_father(index, from_block, mtr, &parent); + btr_cur_node_ptr_delete(&parent, mtr); rec = page_rec_get_next( page_get_infimum_rec(from_page)); node_ptr = dict_index_build_node_ptr( diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index f0cc6b245d4..e6b658b531e 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -100,7 +100,6 @@ btr_pcur_store_position( buf_block_t* block; rec_t* rec; dict_index_t* index; - page_t* page; ulint offs; ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -112,9 +111,8 @@ btr_pcur_store_position( page_cursor = btr_pcur_get_page_cur(cursor); rec = page_cur_get_rec(page_cursor); - page = page_align(rec); - offs = page_offset(rec); - + offs = rec - block->frame; + ut_ad(block->page.id.page_no() == page_get_page_no(block->frame)); ut_ad(block->page.buf_fix_count); /* For spatial index, when we do positioning on parent buffer if necessary, it might not hold latches, but the @@ -129,14 +127,14 @@ btr_pcur_store_position( cursor->old_stored = true; - if (page_is_empty(page)) { + if (page_is_empty(block->frame)) { /* It must be an empty index tree; NOTE that in this case we do not store the modify_clock, but always do a search if we restore the cursor position */ - ut_a(!page_has_siblings(page)); - ut_ad(page_is_leaf(page)); - ut_ad(page_get_page_no(page) == index->page); + ut_a(!page_has_siblings(block->frame)); + ut_ad(page_is_leaf(block->frame)); + ut_ad(block->page.id.page_no() == index->page); if (page_rec_is_supremum_low(offs)) { cursor->rel_pos = BTR_PCUR_AFTER_LAST_IN_TREE; @@ -155,8 +153,8 @@ before_first: if (UNIV_UNLIKELY(rec_is_metadata(rec, *index))) { ut_ad(index->table->instant); ut_ad(page_get_n_recs(block->frame) == 1); - ut_ad(page_is_leaf(page)); - ut_ad(page_get_page_no(page) == index->page); + ut_ad(page_is_leaf(block->frame)); + ut_ad(page_get_page_no(block->frame) == index->page); cursor->rel_pos = BTR_PCUR_AFTER_LAST_IN_TREE; return; } @@ -166,11 +164,11 @@ before_first: rec = page_rec_get_next(rec); if (rec_is_metadata(rec, *index)) { - ut_ad(!page_has_prev(page)); + ut_ad(!page_has_prev(block->frame)); ut_d(const rec_t* p = rec); rec = page_rec_get_next(rec); if (page_rec_is_supremum(rec)) { - ut_ad(page_has_next(page) + ut_ad(page_has_next(block->frame) || rec_is_alter_metadata(p, *index)); goto before_first; } diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index 2d5f6a9bf05..ca350d02316 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -2,7 +2,7 @@ Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6d6a4696d07..9e6d1a35536 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -145,9 +145,6 @@ void close_thread_tables(THD* thd); #include "dict0priv.h" #include <mysql/service_md5.h> #include "wsrep_sst.h" - -extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; - #endif /* WITH_WSREP */ /** to force correct commit order in binlog */ @@ -238,12 +235,6 @@ void set_my_errno(int err) errno = err; } -static uint omits_virtual_cols(const TABLE_SHARE &share) -{ - return share.frm_version < FRM_VER_EXPRESSSIONS && - share.virtual_fields; -} - /** Checks whether the file name belongs to a partition of a table. @param[in] file_name file name @return pointer to the end of the table name part of the file name, or NULL */ @@ -7329,7 +7320,8 @@ build_template_needs_field( { const Field* field = table->field[i]; - if (!field->stored_in_db() && omits_virtual_cols(*table->s)) { + if (!field->stored_in_db() + && ha_innobase::omits_virtual_cols(*table->s)) { return NULL; } @@ -7486,7 +7478,7 @@ build_template_field( &templ->rec_prefix_field_no); } } else { - ut_ad(!omits_virtual_cols(*table->s)); + DBUG_ASSERT(!ha_innobase::omits_virtual_cols(*table->s)); col = &dict_table_get_nth_v_col(index->table, v_no)->m_col; templ->clust_rec_field_no = v_no; templ->rec_prefix_field_no = ULINT_UNDEFINED; @@ -7876,7 +7868,8 @@ no_icp: continue; } } else { - if (is_v && index->is_primary()) { + if (is_v + && (skip_virtual || index->is_primary())) { num_v++; continue; } @@ -8364,7 +8357,7 @@ calc_row_difference( trx_t* const trx = prebuilt->trx; doc_id_t doc_id = FTS_NULL_DOC_ID; ulint num_v = 0; - const bool skip_virtual = omits_virtual_cols(*table->s); + const bool skip_virtual = ha_innobase::omits_virtual_cols(*table->s); ut_ad(!srv_read_only_mode); @@ -10942,7 +10935,7 @@ create_table_info_t::create_table_def() /* Find out the number of virtual columns. */ ulint num_v = 0; - const bool omit_virtual = omits_virtual_cols(*m_form->s); + const bool omit_virtual = ha_innobase::omits_virtual_cols(*m_form->s); const ulint n_cols = omit_virtual ? m_form->s->stored_fields : m_form->s->fields; diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 4f97eebf3bf..af81b22f879 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -21,6 +21,8 @@ this program; if not, write to the Free Software Foundation, Inc., #include <mysql/service_wsrep.h> #endif /* WITH_WSREP */ +#include "table.h" + /* The InnoDB handler: the interface between MySQL and InnoDB. */ /** "GEN_CLUST_INDEX" is the name reserved for InnoDB default @@ -421,6 +423,14 @@ public: Item* idx_cond_push(uint keyno, Item* idx_cond); /* @} */ + /** Check if InnoDB is not storing virtual column metadata for a table. + @param s table definition (based on .frm file) + @return whether InnoDB will omit virtual column metadata */ + static bool omits_virtual_cols(const TABLE_SHARE& s) + { + return s.frm_version<FRM_VER_EXPRESSSIONS && s.virtual_fields; + } + /** Push a primary key filter. @param[in] pk_filter filter against which primary keys are to be checked @@ -428,7 +438,6 @@ public: bool rowid_filter_push(Rowid_filter *rowid_filter); protected: - /** MySQL calls this method at the end of each statement. This method exists for readability only, called from reset(). The name reset() @@ -445,7 +454,6 @@ protected: @see build_template() */ void reset_template(); -protected: inline void update_thd(THD* thd); void update_thd(); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index e0c1c62a472..ed16cf8752f 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4169,7 +4169,8 @@ innobase_build_col_map( >= altered_table->s->fields + DATA_N_SYS_COLS); DBUG_ASSERT(dict_table_get_n_cols(old_table) + dict_table_get_n_v_cols(old_table) - >= table->s->fields + DATA_N_SYS_COLS); + >= table->s->fields + DATA_N_SYS_COLS + || ha_innobase::omits_virtual_cols(*table->s)); DBUG_ASSERT(!!defaults == !!(ha_alter_info->handler_flags & INNOBASE_DEFAULTS)); DBUG_ASSERT(!defaults || dtuple_get_n_fields(defaults) @@ -5750,7 +5751,9 @@ add_all_virtual: } else if (page_rec_is_supremum(rec)) { empty_table: /* The table is empty. */ - ut_ad(page_is_root(block->frame)); + ut_ad(fil_page_index_page_check(block->frame)); + ut_ad(!page_has_siblings(block->frame)); + ut_ad(block->page.id.page_no() == index->page); /* MDEV-17383: free metadata BLOBs! */ btr_page_empty(block, NULL, index, 0, &mtr); index->clear_instant_alter(); diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 5d8dd93d655..2585780cfd6 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -551,14 +551,13 @@ btr_set_min_rec_mark( rec_t* rec, /*!< in/out: record */ mtr_t* mtr) /*!< in: mtr */ MY_ATTRIBUTE((nonnull)); -/*************************************************************//** -Deletes on the upper level the node pointer to a page. */ -void -btr_node_ptr_delete( -/*================*/ - dict_index_t* index, /*!< in: index tree */ - buf_block_t* block, /*!< in: page whose node pointer is deleted */ - mtr_t* mtr) /*!< in: mtr */ +/** Seek to the parent page of a B-tree page. +@param[in,out] index b-tree +@param[in] block child page +@param[in,out] mtr mini-transaction +@param[out] cursor cursor pointing to the x-latched parent page */ +void btr_page_get_father(dict_index_t* index, buf_block_t* block, mtr_t* mtr, + btr_cur_t* cursor) MY_ATTRIBUTE((nonnull)); #ifdef UNIV_DEBUG /************************************************************//** diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 44b679bd07b..9acde0e3f94 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -558,6 +558,11 @@ btr_cur_pessimistic_delete( bool rollback,/*!< in: performing rollback? */ mtr_t* mtr) /*!< in: mtr */ MY_ATTRIBUTE((nonnull)); +/** Delete the node pointer in a parent page. +@param[in,out] parent cursor pointing to parent record +@param[in,out] mtr mini-transaction */ +void btr_cur_node_ptr_delete(btr_cur_t* parent, mtr_t* mtr) + MY_ATTRIBUTE((nonnull)); /***********************************************************//** Parses a redo log record of updating a record in-place. @return end of log record or NULL */ diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 563466f911c..62c58d6616d 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -544,20 +544,6 @@ normalize_table_name_c_low( const char* name, /*!< in: table name string */ ibool set_lower_case); /*!< in: TRUE if we want to set name to lower case */ -/******************************************************************//** -Gets information on the durability property requested by thread. -Used when writing either a prepare or commit record to the log -buffer. -@return the durability property. */ - -#include <dur_prop.h> - -enum durability_properties -thd_requested_durability( -/*=====================*/ - const THD* thd) /*!< in: thread handle */ - MY_ATTRIBUTE((warn_unused_result)); - /** Update the system variable with the given value of the InnoDB buffer pool size. @param[in] buf_pool_size given value of buffer pool size.*/ diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index bc6ab0cb848..dae60fba327 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,6 +1,6 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -727,9 +727,7 @@ page_rec_get_heap_no( /** Determine whether a page has any siblings. @param[in] page page frame @return true if the page has any siblings */ -inline -bool -page_has_siblings(const page_t* page) +inline bool page_has_siblings(const page_t* page) { compile_time_assert(!(FIL_PAGE_PREV % 8)); compile_time_assert(FIL_PAGE_NEXT == FIL_PAGE_PREV + 4); @@ -738,22 +736,10 @@ page_has_siblings(const page_t* page) != ~uint64_t(0); } -/** Determine whether a page is an index root page. -@param[in] page page frame -@return true if the page is a root page of an index */ -inline -bool -page_is_root(const page_t* page) -{ - return fil_page_index_page_check(page) && !page_has_siblings(page); -} - /** Determine whether a page has a predecessor. @param[in] page page frame @return true if the page has a predecessor */ -inline -bool -page_has_prev(const page_t* page) +inline bool page_has_prev(const page_t* page) { return *reinterpret_cast<const uint32_t*>(page + FIL_PAGE_PREV) != FIL_NULL; @@ -762,9 +748,7 @@ page_has_prev(const page_t* page) /** Determine whether a page has a successor. @param[in] page page frame @return true if the page has a successor */ -inline -bool -page_has_next(const page_t* page) +inline bool page_has_next(const page_t* page) { return *reinterpret_cast<const uint32_t*>(page + FIL_PAGE_NEXT) != FIL_NULL; diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index ad0ea913af9..641323e7d41 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -83,7 +83,8 @@ UNIV_INLINE ib_uint64_t page_get_autoinc(const page_t* page) { - ut_ad(page_is_root(page)); + ut_ad(fil_page_index_page_check(page)); + ut_ad(!page_has_siblings(page)); return(mach_read_from_8(PAGE_HEADER + PAGE_ROOT_AUTO_INC + page)); } @@ -164,6 +165,7 @@ page_header_set_field( { ut_ad(page); ut_ad(field <= PAGE_N_RECS); + ut_ad(field != PAGE_N_RECS || val); ut_ad(field == PAGE_N_HEAP || val < srv_page_size); ut_ad(field != PAGE_N_HEAP || (val & 0x7fff) < srv_page_size); diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 25b2d202168..9d1e37405b7 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2018, MariaDB Corporation. +Copyright (c) 2018, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1982,12 +1982,14 @@ page_parse_copy_rec_list_to_created_page( return(rec_end); } + ut_ad(fil_page_index_page_check(block->frame)); /* This function is never invoked on the clustered index root page, except in the redo log apply of page_copy_rec_list_end_to_created_page() which was logged by. page_copy_rec_list_to_created_page_write_log(). For other pages, this field must be zero-initialized. */ - ut_ad(!page_get_instant(block->frame) || page_is_root(block->frame)); + ut_ad(!page_get_instant(block->frame) + || !page_has_siblings(block->frame)); while (ptr < rec_end) { ptr = page_cur_parse_insert_rec(TRUE, ptr, end_ptr, @@ -2043,9 +2045,10 @@ page_copy_rec_list_end_to_created_page( ut_ad(page_dir_get_n_heap(new_page) == PAGE_HEAP_NO_USER_LOW); ut_ad(page_align(rec) != new_page); ut_ad(page_rec_is_comp(rec) == page_is_comp(new_page)); + ut_ad(fil_page_index_page_check(new_page)); /* This function is never invoked on the clustered index root page, except in btr_lift_page_up(). */ - ut_ad(!page_get_instant(new_page) || page_is_root(new_page)); + ut_ad(!page_get_instant(new_page) || !page_has_siblings(new_page)); if (page_rec_is_infimum(rec)) { @@ -2138,6 +2141,8 @@ page_copy_rec_list_end_to_created_page( rec = page_rec_get_next(rec); } while (!page_rec_is_supremum(rec)); + ut_ad(n_recs); + if ((slot_index > 0) && (count + 1 + (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2 <= PAGE_DIR_SLOT_MAX_N_OWNED)) { diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index b93773197c9..9109787f191 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -507,6 +507,8 @@ page_create_empty( page_zip_des_t* page_zip= buf_block_get_page_zip(block); ut_ad(fil_page_index_page_check(page)); + ut_ad(!index->is_dummy); + ut_ad(block->page.id.space() == index->table->space->id); /* Multiple transactions cannot simultaneously operate on the same temp-table in parallel. @@ -517,7 +519,7 @@ page_create_empty( && page_is_leaf(page)) { max_trx_id = page_get_max_trx_id(page); ut_ad(max_trx_id); - } else if (page_is_root(page)) { + } else if (block->page.id.page_no() == index->page) { /* Preserve PAGE_ROOT_AUTO_INC. */ max_trx_id = page_get_max_trx_id(page); } else { @@ -1210,6 +1212,7 @@ delete_all: page_header_set_field(page, NULL, PAGE_GARBAGE, size + page_header_get_field(page, PAGE_GARBAGE)); + ut_ad(page_get_n_recs(page) > n_recs); page_header_set_field(page, NULL, PAGE_N_RECS, (ulint)(page_get_n_recs(page) - n_recs)); } diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 8c5007c434b..ae70c29913f 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4470,10 +4470,12 @@ page_zip_dir_delete( slot_rec = page_zip_dir_find(page_zip, page_offset(rec)); ut_a(slot_rec); - + uint16_t n_recs = page_get_n_recs(page); + ut_ad(n_recs); + ut_ad(n_recs > 1 || page_get_page_no(page) == index->page); /* This could not be done before page_zip_dir_find(). */ page_header_set_field(page, page_zip, PAGE_N_RECS, - (ulint)(page_get_n_recs(page) - 1)); + n_recs - 1); if (UNIV_UNLIKELY(!free)) { /* Make the last slot the start of the free list. */ @@ -4747,7 +4749,7 @@ page_zip_reorganize( clustered index root pages. */ ut_ad(page_get_max_trx_id(page) == 0 || (dict_index_is_clust(index) - ? page_is_root(temp_page) + ? !page_has_siblings(temp_page) : page_is_leaf(temp_page))); /* Restore logging. */ diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 108b024f986..fdd352390da 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -670,7 +670,7 @@ dberr_t FetchIndexRootPages::operator()(buf_block_t* block) UNIV_NOTHROW return set_current_xdes(block->page.id.page_no(), page); } else if (fil_page_index_page_check(page) && !is_free(block->page.id.page_no()) - && page_is_root(page)) { + && !page_has_siblings(page)) { index_id_t id = btr_page_get_index_id(page); @@ -1829,9 +1829,9 @@ PageConverter::update_index_page( page, m_page_zip_ptr, m_index->m_srv_index->id, 0); if (dict_index_is_clust(m_index->m_srv_index)) { - if (page_is_root(page)) { - dict_index_t* index = const_cast<dict_index_t*>( - m_index->m_srv_index); + dict_index_t* index = const_cast<dict_index_t*>( + m_index->m_srv_index); + if (block->page.id.page_no() == index->page) { /* Preserve the PAGE_ROOT_AUTO_INC. */ if (index->table->supports_instant()) { if (btr_cur_instant_root_init(index, page)) { @@ -1882,7 +1882,7 @@ PageConverter::update_index_page( if (page_is_empty(page)) { /* Only a root page can be empty. */ - if (!page_is_root(page)) { + if (page_has_siblings(page)) { // TODO: We should relax this and skip secondary // indexes. Mark them as corrupt because they can // always be rebuilt. diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 5701a4af233..55a3865b783 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -963,7 +963,8 @@ row_log_table_low( break; case FIL_PAGE_TYPE_INSTANT: ut_ad(index->is_instant()); - ut_ad(page_is_root(page_align(rec))); + ut_ad(!page_has_siblings(page_align(rec))); + ut_ad(page_get_page_no(page_align(rec)) == index->page); break; default: ut_ad(!"wrong page type"); |