mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Merge 10.3 into 10.4, except for MDEV-20265
The MDEV-20265 commit e746f451d5
introduces DBUG_ASSERT(right_op == r_tbl) in
st_select_lex::add_cross_joined_table(), and that assertion would
fail in several tests that exercise joins. That commit was skipped
in this merge, and a separate fix of MDEV-20265 will be necessary in 10.4.
This commit is contained in:
commit
efb8485d85
66 changed files with 689 additions and 317 deletions
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2006, 2017, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2008, 2018, MariaDB Corporation
|
||||
# Copyright (c) 2008, 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
|
||||
|
@ -231,6 +231,11 @@ IF (WITH_UBSAN)
|
|||
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO)
|
||||
ENDIF()
|
||||
|
||||
OPTION(WITH_MSAN "Enable memory sanitizer" OFF)
|
||||
IF (WITH_MSAN)
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT WITH_TSAN)
|
||||
# enable security hardening features, like most distributions do
|
||||
# in our benchmarks that costs about ~1% of performance, depending on the load
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2017, MariaDB
|
||||
Copyright (c) 2009, 2019, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -1687,6 +1687,7 @@ void abort_not_supported_test(const char *fmt, ...)
|
|||
cur_file->file_name, cur_file->lineno);
|
||||
|
||||
char buff[DIE_BUFF_SIZE];
|
||||
buff[0] = '\0';
|
||||
print_file_stack(buff, buff + sizeof(buff));
|
||||
fprintf(stderr, "%s", buff);
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ IF(RPM)
|
|||
SET(BUILD_DEPS ${BUILD_DEPS} ${${V}_DEP})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
LIST(REMOVE_DUPLICATES BUILD_DEPS)
|
||||
STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}")
|
||||
IF (BUILD_DEPS)
|
||||
LIST(REMOVE_DUPLICATES BUILD_DEPS)
|
||||
STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}")
|
||||
ENDIF()
|
||||
ENDIF(RPM)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (c) 2009, 2018, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2011, 2019, 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
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
||||
|
||||
|
||||
INCLUDE(CMakeParseArguments)
|
||||
|
@ -209,7 +209,7 @@ MACRO(MYSQL_ADD_PLUGIN)
|
|||
ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
TARGET_LINK_LIBRARIES (${target} mysqld)
|
||||
ENDIF()
|
||||
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN)
|
||||
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN AND NOT WITH_MSAN)
|
||||
TARGET_LINK_LIBRARIES (${target} "-Wl,--no-undefined")
|
||||
ENDIF()
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ed3a91c139175746c5d6903d67ca902d91228f65
|
||||
Subproject commit dc271e5a1b9d4074e2086b776a668b6b5614f2bc
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (c) 2008, 2012, Oracle and/or its affiliates
|
||||
Copyright (c) 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
|
||||
|
@ -219,6 +220,7 @@ int main(int argc, char* const argv[] )
|
|||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
sa_abort.sa_handler= handle_abort;
|
||||
sa_abort.sa_flags= 0;
|
||||
sigemptyset(&sa_abort.sa_mask);
|
||||
/* Install signal handlers */
|
||||
sigaction(SIGTERM, &sa,NULL);
|
||||
|
|
|
@ -385,3 +385,15 @@ SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
|
|||
CREATE TABLE t2 LIKE t1;
|
||||
SET debug_dbug= DEFAULT;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# MDEV-20210
|
||||
# If you have an INVISIBLE VIRTUAL column, SHOW CREATE TABLE doesn't list it as INVISIBLE
|
||||
#
|
||||
CREATE TABLE t1 (i INT, v int GENERATED ALWAYS AS (1) VIRTUAL INVISIBLE);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL,
|
||||
`v` int(11) GENERATED ALWAYS AS (1) VIRTUAL INVISIBLE
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -281,3 +281,12 @@ SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
|
|||
CREATE TABLE t2 LIKE t1;
|
||||
SET debug_dbug= DEFAULT;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20210
|
||||
--echo # If you have an INVISIBLE VIRTUAL column, SHOW CREATE TABLE doesn't list it as INVISIBLE
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (i INT, v int GENERATED ALWAYS AS (1) VIRTUAL INVISIBLE);
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -2179,7 +2179,7 @@ count(*)
|
|||
6
|
||||
explain extended select count(*) from t1 where a in (22,83,11) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref b,a b 5 const 59 55.93 Using where
|
||||
1 SIMPLE t1 ref b,a b 5 const 59 3.30 Using where
|
||||
Warnings:
|
||||
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (22,83,11)
|
||||
select * from t1 where a in (22,83,11) and b=2;
|
||||
|
@ -2196,7 +2196,7 @@ count(*)
|
|||
6
|
||||
explain extended select count(*) from t1 where a in (22,83,11) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 55.93 Using where; Using rowid filter
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 3.30 Using where; Using rowid filter
|
||||
Warnings:
|
||||
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (22,83,11)
|
||||
select * from t1 where a in (22,83,11) and b=2;
|
||||
|
|
|
@ -1637,3 +1637,37 @@ set @@use_stat_tables= @save_use_stat_tables;
|
|||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
#
|
||||
# MDEV-19834 Selectivity of an equality condition discounted twice
|
||||
#
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables='preferably';
|
||||
create table t1 (a int, b int, key (b), key (a));
|
||||
insert into t1
|
||||
select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
|
||||
analyze table t1 ;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status Table is already up to date
|
||||
# Check what info the optimizer has about selectivities
|
||||
explain extended select * from t1 use index () where a in (17,51,5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5)
|
||||
explain extended select * from t1 use index () where b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2
|
||||
# Now, the equality is used for ref access, while the range condition
|
||||
# gives selectivity data
|
||||
explain extended select * from t1 where a in (17,51,5) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 58 (3%) 2.90 Using where; Using rowid filter
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5)
|
||||
drop table t1;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
# End of 10.1 tests
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
--source include/have_stat_tables.inc
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t0,t1,t2,t3;
|
||||
|
@ -1104,3 +1105,26 @@ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectiv
|
|||
drop table t1;
|
||||
drop function f1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19834 Selectivity of an equality condition discounted twice
|
||||
--echo #
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables='preferably';
|
||||
create table t1 (a int, b int, key (b), key (a));
|
||||
insert into t1
|
||||
select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
|
||||
analyze table t1 ;
|
||||
|
||||
--echo # Check what info the optimizer has about selectivities
|
||||
explain extended select * from t1 use index () where a in (17,51,5);
|
||||
explain extended select * from t1 use index () where b=2;
|
||||
|
||||
--echo # Now, the equality is used for ref access, while the range condition
|
||||
--echo # gives selectivity data
|
||||
explain extended select * from t1 where a in (17,51,5) and b=2;
|
||||
drop table t1;
|
||||
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
--echo # End of 10.1 tests
|
||||
|
||||
|
|
|
@ -1647,6 +1647,40 @@ set @@use_stat_tables= @save_use_stat_tables;
|
|||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
#
|
||||
# MDEV-19834 Selectivity of an equality condition discounted twice
|
||||
#
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables='preferably';
|
||||
create table t1 (a int, b int, key (b), key (a));
|
||||
insert into t1
|
||||
select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
|
||||
analyze table t1 ;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
# Check what info the optimizer has about selectivities
|
||||
explain extended select * from t1 use index () where a in (17,51,5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5)
|
||||
explain extended select * from t1 use index () where b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2
|
||||
# Now, the equality is used for ref access, while the range condition
|
||||
# gives selectivity data
|
||||
explain extended select * from t1 where a in (17,51,5) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 2.90 Using where; Using rowid filter
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5)
|
||||
drop table t1;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
# End of 10.1 tests
|
||||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
|
||||
set @tmp_ust= @@use_stat_tables;
|
||||
set @tmp_oucs= @@optimizer_use_condition_selectivity;
|
||||
|
|
|
@ -1156,6 +1156,17 @@ ExtractValue('foo','bar') i MIN(d)
|
|||
3 1976-12-14 13:21:07
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
|
||||
#
|
||||
SET SQL_MODE=DEFAULT;
|
||||
CREATE OR REPLACE TABLE t1 (a CHAR(11));
|
||||
CREATE OR REPLACE TABLE t2 (b DATETIME);
|
||||
INSERT INTO t1 VALUES ('2010-02-19') ;
|
||||
SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
DROP TABLE t1, t2;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
#
|
||||
# End of 10.1 tests
|
||||
#
|
||||
#
|
||||
|
|
|
@ -710,6 +710,20 @@ INSERT INTO t1 VALUES (3,NULL),(3,'1976-12-14 13:21:07'),(NULL,'1981-09-24 01:04
|
|||
SELECT ExtractValue('foo','bar'), i, MIN(d) FROM t1 GROUP BY i;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
|
||||
--echo #
|
||||
|
||||
SET SQL_MODE=DEFAULT;
|
||||
CREATE OR REPLACE TABLE t1 (a CHAR(11));
|
||||
CREATE OR REPLACE TABLE t2 (b DATETIME);
|
||||
INSERT INTO t1 VALUES ('2010-02-19') ;
|
||||
SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
DROP TABLE t1, t2;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.1 tests
|
||||
--echo #
|
||||
|
|
|
@ -1,4 +1,28 @@
|
|||
#
|
||||
# Start of 5.5 tests
|
||||
#
|
||||
#
|
||||
# MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
@a := 1
|
||||
1
|
||||
SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
COALESCE(1)
|
||||
1
|
||||
SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
COALESCE(@a:=1)
|
||||
1
|
||||
SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
COALESCE(@a)
|
||||
1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 5.5 tests
|
||||
#
|
||||
#
|
||||
# Start of 10.1 tests
|
||||
#
|
||||
#
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
--echo #
|
||||
--echo # Start of 5.5 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.5 tests
|
||||
--echo #
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.1 tests
|
||||
--echo #
|
||||
|
|
26
mysql-test/suite/encryption/r/file_creation.result
Normal file
26
mysql-test/suite/encryption/r/file_creation.result
Normal file
|
@ -0,0 +1,26 @@
|
|||
SET GLOBAL innodb_encrypt_tables = ON;
|
||||
SET GLOBAL innodb_encryption_threads = 1;
|
||||
SET GLOBAL innodb_max_dirty_pages_pct = 99;
|
||||
SHOW VARIABLES LIKE 'innodb_encrypt%';
|
||||
Variable_name Value
|
||||
innodb_encrypt_log OFF
|
||||
innodb_encrypt_tables ON
|
||||
innodb_encrypt_temporary_tables OFF
|
||||
innodb_encryption_rotate_key_age 1
|
||||
innodb_encryption_rotation_iops 100
|
||||
innodb_encryption_threads 1
|
||||
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(255), f3 CHAR(255),
|
||||
f4 CHAR(255), f5 CHAR(255))ENGINE=INNODB;
|
||||
INSERT INTO t1 VALUES(1, "mysql", "mariadb", "batman", "superman");
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
# Wait max 10 min for key encryption threads to encrypt all spaces
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t1 optimize status OK
|
||||
ALTER TABLE t1 FORCE;
|
||||
# Kill the server
|
||||
DROP TABLE t1;
|
1
mysql-test/suite/encryption/t/file_creation.opt
Normal file
1
mysql-test/suite/encryption/t/file_creation.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--innodb-tablespaces-encryption
|
41
mysql-test/suite/encryption/t/file_creation.test
Normal file
41
mysql-test/suite/encryption/t/file_creation.test
Normal file
|
@ -0,0 +1,41 @@
|
|||
--source include/have_innodb.inc
|
||||
--source include/have_example_key_management_plugin.inc
|
||||
let $restart_noprint=2;
|
||||
# embedded does not support restart
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
#
|
||||
# MDEV-19348 MariaBackup prepare fails with InnoDB: Database page corruption
|
||||
# on disk or a failed file read
|
||||
#
|
||||
|
||||
SET GLOBAL innodb_encrypt_tables = ON;
|
||||
SET GLOBAL innodb_encryption_threads = 1;
|
||||
SET GLOBAL innodb_max_dirty_pages_pct = 99;
|
||||
SHOW VARIABLES LIKE 'innodb_encrypt%';
|
||||
|
||||
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(255), f3 CHAR(255),
|
||||
f4 CHAR(255), f5 CHAR(255))ENGINE=INNODB;
|
||||
|
||||
INSERT INTO t1 VALUES(1, "mysql", "mariadb", "batman", "superman");
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
|
||||
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
|
||||
|
||||
--echo # Wait max 10 min for key encryption threads to encrypt all spaces
|
||||
--let $wait_timeout= 600
|
||||
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
|
||||
--source include/wait_condition.inc
|
||||
|
||||
OPTIMIZE TABLE t1;
|
||||
|
||||
--source ../../suite/innodb/include/no_checkpoint_start.inc
|
||||
ALTER TABLE t1 FORCE;
|
||||
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1;
|
||||
--source ../../suite/innodb/include/no_checkpoint_end.inc
|
||||
|
||||
--source include/start_mysqld.inc
|
||||
DROP TABLE t1;
|
|
@ -1,6 +1,5 @@
|
|||
--source include/galera_cluster.inc
|
||||
|
||||
|
||||
--connection node_1
|
||||
|
||||
create database cardtest02;
|
||||
|
@ -45,16 +44,30 @@ let $table_rows1 = `SELECT table_rows from information_schema.tables WHERE TABLE
|
|||
let $avg_row_length1 = `SELECT avg_row_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $data_length1 = `SELECT data_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
|
||||
--let $wait_timeout=600
|
||||
--let $wait_condition = SELECT table_rows = 301 from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
select count(*) from cardtest_tbl;
|
||||
|
||||
let $cardinality1 = `SELECT cardinality from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $table_rows1 = `SELECT table_rows from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $avg_row_length1 = `SELECT avg_row_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $data_length1 = `SELECT data_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
|
||||
--connection node_2
|
||||
set session wsrep_sync_wait=15;
|
||||
use cardtest02;
|
||||
|
||||
--let $wait_timeout=600
|
||||
--let $wait_condition = SELECT table_rows = 301 from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
select count(*) from cardtest_tbl;
|
||||
|
||||
if (`SELECT cardinality <> $cardinality1 from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl'`)
|
||||
{
|
||||
SELECT cardinality from from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
SELECT cardinality from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
}
|
||||
if (`SELECT table_rows <> $table_rows1 from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`)
|
||||
{
|
||||
|
|
|
@ -161,3 +161,62 @@ c d
|
|||
6 30
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
#
|
||||
# MDEV-17187 table doesn't exist in engine after ALTER other tables
|
||||
# with CONSTRAINTs
|
||||
#
|
||||
set foreign_key_checks=on;
|
||||
create table t1 (id int not null primary key) engine=innodb;
|
||||
create table t2 (id int not null primary key, fid int not null,
|
||||
CONSTRAINT fk_fid FOREIGN KEY (fid) REFERENCES t1 (id))engine=innodb;
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 1), (2, 1), (3, 2);
|
||||
set foreign_key_checks=off;
|
||||
alter table t2 drop index fk_fid;
|
||||
set foreign_key_checks=on;
|
||||
delete from t1 where id=2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`))
|
||||
insert into t2 values(4, 99);
|
||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`))
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
id fid
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
set foreign_key_checks=off;
|
||||
delete from t1 where id=2;
|
||||
insert into t2 values(4, 99);
|
||||
set foreign_key_checks=on;
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
3
|
||||
select * from t2;
|
||||
id fid
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 99
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`id` int(11) NOT NULL,
|
||||
`fid` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1,t2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
||||
drop table t1,t2;
|
||||
ERROR 42S02: Unknown table 'test.t2'
|
||||
|
|
|
@ -25,7 +25,7 @@ create table t2(a int, constraint a foreign key a (a) references t1(a)) engine=i
|
|||
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Create table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key a (a) references t1(a)) engine=innodb'.
|
||||
Warning 150 Create table `test`.`t2` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key a (a) references t1(a)) engine=innodb'.
|
||||
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `t2`
|
||||
drop table t1;
|
||||
|
@ -42,7 +42,7 @@ alter table t2 add constraint b foreign key (b) references t2(b);
|
|||
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Alter table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key (b) references t2(b)'.
|
||||
Warning 150 Alter table `test`.`t2` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key (b) references t2(b)'.
|
||||
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `t2`
|
||||
drop table t2, t1;
|
||||
|
|
|
@ -18,9 +18,7 @@ Tables_in_test
|
|||
main
|
||||
ref_table1
|
||||
ref_table2
|
||||
# restart and see if we can still access the main table
|
||||
# restart
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
|
||||
SHOW CREATE TABLE `main`;
|
||||
Table Create Table
|
||||
|
|
|
@ -4,13 +4,17 @@
|
|||
#
|
||||
# Set up the test with a procedure and a function.
|
||||
#
|
||||
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= 1;
|
||||
CREATE PROCEDURE insert_n(start int, end int)
|
||||
BEGIN
|
||||
DECLARE i INT DEFAULT start;
|
||||
START TRANSACTION;
|
||||
WHILE i <= end do
|
||||
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = i;
|
||||
SET i = i + 1;
|
||||
END WHILE;
|
||||
COMMIT;
|
||||
END~~
|
||||
CREATE FUNCTION num_pages_get()
|
||||
RETURNS INT
|
||||
|
@ -47,13 +51,14 @@ connection default;
|
|||
# Connect to default and record how many pages were accessed
|
||||
# when selecting the record using the secondary key.
|
||||
#
|
||||
InnoDB 4 transactions not purged
|
||||
SET @num_pages_1 = num_pages_get();
|
||||
SELECT * FROM t1 force index (b);
|
||||
a b c
|
||||
SET @num_pages_2= num_pages_get();
|
||||
SELECT @num_pages_2 - @num_pages_1 < 500;
|
||||
@num_pages_2 - @num_pages_1 < 500
|
||||
1
|
||||
SELECT IF(@num_pages_2 - @num_pages_1 < 5000, 'OK', @num_pages_2 - @num_pages_1) num_pages_diff;
|
||||
num_pages_diff
|
||||
OK
|
||||
#
|
||||
# Commit and show the final record.
|
||||
#
|
||||
|
@ -76,6 +81,7 @@ test.t1 check status OK
|
|||
#
|
||||
disconnect con2;
|
||||
disconnect con3;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE insert_n;
|
||||
DROP FUNCTION num_pages_get;
|
||||
|
|
|
@ -203,3 +203,49 @@ connection default;
|
|||
select * from t2;
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17187 table doesn't exist in engine after ALTER other tables
|
||||
--echo # with CONSTRAINTs
|
||||
--echo #
|
||||
|
||||
set foreign_key_checks=on;
|
||||
create table t1 (id int not null primary key) engine=innodb;
|
||||
create table t2 (id int not null primary key, fid int not null,
|
||||
CONSTRAINT fk_fid FOREIGN KEY (fid) REFERENCES t1 (id))engine=innodb;
|
||||
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 1), (2, 1), (3, 2);
|
||||
|
||||
set foreign_key_checks=off;
|
||||
alter table t2 drop index fk_fid;
|
||||
set foreign_key_checks=on;
|
||||
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
delete from t1 where id=2;
|
||||
--error ER_NO_REFERENCED_ROW_2
|
||||
insert into t2 values(4, 99);
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
set foreign_key_checks=off;
|
||||
delete from t1 where id=2;
|
||||
insert into t2 values(4, 99);
|
||||
set foreign_key_checks=on;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
show create table t1;
|
||||
show create table t2;
|
||||
|
||||
# Optional: test DROP TABLE without any prior ha_innobase::open().
|
||||
# This was tested manually, but it would cause --embedded to skip the test,
|
||||
# and the restart would significantly increase the running time.
|
||||
# --source include/restart_mysqld.inc
|
||||
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
drop table t1,t2;
|
||||
--error ER_BAD_TABLE_ERROR
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -28,11 +28,8 @@ SET FOREIGN_KEY_CHECKS=0;
|
|||
DROP INDEX `idx_1` ON `main`;
|
||||
SHOW TABLES;
|
||||
|
||||
--echo # restart and see if we can still access the main table
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
# This is required to access the table
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
|
||||
SHOW CREATE TABLE `main`;
|
||||
|
||||
|
|
|
@ -6,15 +6,19 @@
|
|||
--echo #
|
||||
|
||||
--source include/have_innodb.inc
|
||||
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= 1;
|
||||
|
||||
DELIMITER ~~;
|
||||
CREATE PROCEDURE insert_n(start int, end int)
|
||||
BEGIN
|
||||
DECLARE i INT DEFAULT start;
|
||||
START TRANSACTION;
|
||||
WHILE i <= end do
|
||||
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = i;
|
||||
SET i = i + 1;
|
||||
END WHILE;
|
||||
COMMIT;
|
||||
END~~
|
||||
|
||||
CREATE FUNCTION num_pages_get()
|
||||
|
@ -60,11 +64,13 @@ connection default;
|
|||
--echo # Connect to default and record how many pages were accessed
|
||||
--echo # when selecting the record using the secondary key.
|
||||
--echo #
|
||||
--let $wait_all_purged=4
|
||||
--source include/wait_all_purged.inc
|
||||
SET @num_pages_1 = num_pages_get();
|
||||
SELECT * FROM t1 force index (b);
|
||||
SET @num_pages_2= num_pages_get();
|
||||
|
||||
SELECT @num_pages_2 - @num_pages_1 < 500;
|
||||
SELECT IF(@num_pages_2 - @num_pages_1 < 5000, 'OK', @num_pages_2 - @num_pages_1) num_pages_diff;
|
||||
|
||||
--echo #
|
||||
--echo # Commit and show the final record.
|
||||
|
@ -81,6 +87,7 @@ CHECK TABLE t1;
|
|||
--echo #
|
||||
disconnect con2;
|
||||
disconnect con3;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE insert_n;
|
||||
DROP FUNCTION num_pages_get;
|
||||
|
|
|
@ -1524,7 +1524,7 @@ ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
|
|||
ERROR HY000: Can't create table `test`.`child` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Alter table '`test`.`child`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
|
||||
Warning 150 Alter table `test`.`child` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
|
||||
Error 1005 Can't create table `test`.`child` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `child`
|
||||
ALTER TABLE parent DROP INDEX idx1;
|
||||
|
@ -1532,7 +1532,7 @@ ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
|
|||
Got one of the listed errors
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Alter table '`test`.`child`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
|
||||
Warning 150 Alter table `test`.`child` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
|
||||
Error 1005 Can't create table `test`.`child` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `child`
|
||||
ALTER TABLE child DROP INDEX idx2;
|
||||
|
@ -1540,7 +1540,7 @@ ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
|
|||
Got one of the listed errors
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Alter table '`test`.`child`' with foreign key constraint failed. There is only prefix index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
|
||||
Warning 150 Alter table `test`.`child` with foreign key constraint failed. There is only prefix index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
|
||||
Error 1005 Can't create table `test`.`child` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `child`
|
||||
DROP TABLE child, parent;
|
||||
|
|
4
mysql-test/suite/maria/partition.result
Normal file
4
mysql-test/suite/maria/partition.result
Normal file
|
@ -0,0 +1,4 @@
|
|||
CREATE TABLE t (a INT, KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2;
|
||||
SELECT * FROM t PARTITION (p1);
|
||||
a
|
||||
DROP TABLE t;
|
11
mysql-test/suite/maria/partition.test
Normal file
11
mysql-test/suite/maria/partition.test
Normal file
|
@ -0,0 +1,11 @@
|
|||
--source include/have_partition.inc
|
||||
|
||||
#
|
||||
# MDEV-19254
|
||||
# Server crashes in maria_status / ha_maria::info upon SELECT with partition
|
||||
# pruning
|
||||
#
|
||||
|
||||
CREATE TABLE t (a INT, KEY(a)) ENGINE=Aria PARTITION BY KEY(a) PARTITIONS 2;
|
||||
SELECT * FROM t PARTITION (p1);
|
||||
DROP TABLE t;
|
|
@ -555,17 +555,6 @@ t1 CREATE TABLE `t1` (
|
|||
create or replace table t1 (f int) with system versioning partition by hash(f);
|
||||
insert delayed into t1 values (1);
|
||||
#
|
||||
# MDEV-17613 MIN/MAX Optimization (Select tables optimized away) does not work
|
||||
#
|
||||
create or replace table t1 (pk int primary key) with system versioning
|
||||
partition by system_time (
|
||||
partition p1 history,
|
||||
partition pn current);
|
||||
insert into t1 values (1), (2);
|
||||
explain select max(pk) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
#
|
||||
# MDEV-20068 History partition rotation is not done under LOCK TABLES
|
||||
#
|
||||
create or replace table t1 (x int) with system versioning partition by system_time limit 1
|
||||
|
|
|
@ -44,7 +44,7 @@ i
|
|||
6
|
||||
explain partitions select * from t1;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL 2
|
||||
1 SIMPLE t1 pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL 2 Using where
|
||||
explain partitions select * from t1 for system_time as of '2001-02-04 10:20:30';
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 p1_p1sp0,p1_p1sp1,p0_p0sp0,p0_p0sp1,p2_p2sp0,p2_p2sp1,pn_pnsp0,pn_pnsp1 ALL NULL NULL NULL NULL # Using where
|
||||
|
|
|
@ -488,27 +488,6 @@ create or replace table t1 (f int) with system versioning partition by hash(f);
|
|||
--error 0,ER_DELAYED_NOT_SUPPORTED
|
||||
insert delayed into t1 values (1);
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17613 MIN/MAX Optimization (Select tables optimized away) does not work
|
||||
--echo #
|
||||
--disable_query_log
|
||||
set @saved_storage_engine= @@default_storage_engine;
|
||||
if ($MTR_COMBINATION_HEAP)
|
||||
{
|
||||
# This case does not work with HEAP
|
||||
set default_storage_engine= myisam;
|
||||
}
|
||||
--enable_query_log
|
||||
create or replace table t1 (pk int primary key) with system versioning
|
||||
partition by system_time (
|
||||
partition p1 history,
|
||||
partition pn current);
|
||||
insert into t1 values (1), (2);
|
||||
explain select max(pk) from t1;
|
||||
--disable_query_log
|
||||
set default_storage_engine= @saved_storage_engine;
|
||||
--enable_query_log
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20068 History partition rotation is not done under LOCK TABLES
|
||||
--echo #
|
||||
|
|
|
@ -201,7 +201,7 @@ static int get_date_time_separator(uint *number_of_fields,
|
|||
do
|
||||
{
|
||||
s++;
|
||||
} while (my_isspace(&my_charset_latin1, *s));
|
||||
} while (s < end && my_isspace(&my_charset_latin1, *s));
|
||||
*str= s;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8304,6 +8304,7 @@ int ha_partition::info(uint flag)
|
|||
ulonglong max_records= 0;
|
||||
uint32 i= 0;
|
||||
uint32 handler_instance= 0;
|
||||
bool handler_instance_set= 0;
|
||||
|
||||
file_array= m_file;
|
||||
do
|
||||
|
@ -8316,8 +8317,9 @@ int ha_partition::info(uint flag)
|
|||
!bitmap_is_set(&(m_part_info->read_partitions),
|
||||
(uint) (file_array - m_file)))
|
||||
file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag);
|
||||
if (file->stats.records > max_records)
|
||||
if (file->stats.records > max_records || !handler_instance_set)
|
||||
{
|
||||
handler_instance_set= 1;
|
||||
max_records= file->stats.records;
|
||||
handler_instance= i;
|
||||
}
|
||||
|
|
|
@ -96,15 +96,14 @@ public:
|
|||
Loose_scan_opt():
|
||||
try_loosescan(FALSE),
|
||||
bound_sj_equalities(0),
|
||||
quick_uses_applicable_index(FALSE)
|
||||
quick_uses_applicable_index(0),
|
||||
quick_max_loose_keypart(0),
|
||||
best_loose_scan_key(0),
|
||||
best_loose_scan_cost(0),
|
||||
best_loose_scan_records(0),
|
||||
best_loose_scan_start_key(NULL),
|
||||
best_max_loose_keypart(0)
|
||||
{
|
||||
/* Protected by quick_uses_applicable_index */
|
||||
LINT_INIT(quick_max_loose_keypart);
|
||||
/* The following are protected by best_loose_scan_cost!= DBL_MAX */
|
||||
LINT_INIT(best_loose_scan_key);
|
||||
LINT_INIT(best_loose_scan_records);
|
||||
LINT_INIT(best_max_loose_keypart);
|
||||
LINT_INIT(best_loose_scan_start_key);
|
||||
}
|
||||
|
||||
void init(JOIN *join, JOIN_TAB *s, table_map remaining_tables)
|
||||
|
|
|
@ -2663,9 +2663,16 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen)
|
|||
{
|
||||
if (!table_list->table || !table_list->table->needs_reopen())
|
||||
continue;
|
||||
/* no need to remove the table from the TDC here, thus (TABLE*)1 */
|
||||
close_all_tables_for_name(thd, table_list->table->s,
|
||||
HA_EXTRA_NOT_USED, (TABLE*)1);
|
||||
for (TABLE **prev= &thd->open_tables; *prev; prev= &(*prev)->next)
|
||||
{
|
||||
if (*prev == table_list->table)
|
||||
{
|
||||
thd->locked_tables_list.unlink_from_list(thd, table_list, false);
|
||||
mysql_lock_remove(thd, thd->lock, *prev);
|
||||
close_thread_table(thd, prev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DBUG_ASSERT(table_list->table == NULL);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -460,6 +460,8 @@ uint Explain_union::make_union_table_name(char *buf)
|
|||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
type.str= NULL;
|
||||
type.length= 0;
|
||||
}
|
||||
memcpy(buf, type.str, (len= (uint)type.length));
|
||||
|
||||
|
|
|
@ -916,19 +916,6 @@ Item* SELECT_LEX::period_setup_conds(THD *thd, TABLE_LIST *tables, Item *where)
|
|||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
/**
|
||||
Setup System Versioning conditions
|
||||
|
||||
Add WHERE condition according to FOR SYSTEM_TIME clause.
|
||||
|
||||
If the table is partitioned by SYSTEM_TIME and there is no FOR SYSTEM_TIME
|
||||
clause, then select now-partition instead of modifying WHERE condition.
|
||||
|
||||
@retval
|
||||
-1 on error
|
||||
@retval
|
||||
0 on success
|
||||
*/
|
||||
int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
DBUG_ENTER("SELECT_LEX::vers_setup_conds");
|
||||
|
@ -986,13 +973,12 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
|||
vers_select_conds_t &vers_conditions= table->vers_conditions;
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
Vers_part_info *vers_info;
|
||||
if (table->table->part_info && (vers_info= table->table->part_info->vers_info))
|
||||
{
|
||||
if (table->partition_names)
|
||||
/*
|
||||
if the history is stored in partitions, then partitions
|
||||
themselves are not versioned
|
||||
*/
|
||||
if (table->partition_names && table->table->part_info->vers_info)
|
||||
{
|
||||
/* If the history is stored in partitions, then partitions
|
||||
themselves are not versioned. */
|
||||
if (vers_conditions.is_set())
|
||||
{
|
||||
my_error(ER_VERS_QUERY_IN_PARTITION, MYF(0), table->alias.str);
|
||||
|
@ -1001,19 +987,6 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
|||
else
|
||||
vers_conditions.init(SYSTEM_TIME_ALL);
|
||||
}
|
||||
else if (!vers_conditions.is_set() &&
|
||||
/* We cannot optimize REPLACE .. SELECT because it may need
|
||||
to call vers_set_hist_part() to update history. */
|
||||
thd->lex->sql_command != SQLCOM_REPLACE_SELECT)
|
||||
{
|
||||
table->partition_names= newx List<String>;
|
||||
String *s= newx String(vers_info->now_part->partition_name,
|
||||
system_charset_info);
|
||||
table->partition_names->push_back(s);
|
||||
table->table->file->change_partitions_to_open(table->partition_names);
|
||||
vers_conditions.init(SYSTEM_TIME_ALL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outer_table && !vers_conditions.is_set())
|
||||
|
@ -1068,7 +1041,6 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
|||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#undef newx
|
||||
|
||||
/*****************************************************************************
|
||||
Check fields, find best join, do the select and output fields.
|
||||
|
@ -9056,6 +9028,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
|
|||
KEYUSE *keyuse= pos->key;
|
||||
KEYUSE *prev_ref_keyuse= keyuse;
|
||||
uint key= keyuse->key;
|
||||
bool used_range_selectivity= false;
|
||||
|
||||
/*
|
||||
Check if we have a prefix of key=const that matches a quick select.
|
||||
|
@ -9081,6 +9054,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
|
|||
keyparts++;
|
||||
}
|
||||
sel /= (double)table->quick_rows[key] / (double) table->stat_records();
|
||||
used_range_selectivity= true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9116,13 +9090,14 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
|
|||
if (keyparts > keyuse->keypart)
|
||||
{
|
||||
/* Ok this is the keyuse that will be used for ref access */
|
||||
uint fldno;
|
||||
if (is_hash_join_key_no(key))
|
||||
fldno= keyuse->keypart;
|
||||
else
|
||||
fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1;
|
||||
if (keyuse->val->const_item())
|
||||
if (!used_range_selectivity && keyuse->val->const_item())
|
||||
{
|
||||
uint fldno;
|
||||
if (is_hash_join_key_no(key))
|
||||
fldno= keyuse->keypart;
|
||||
else
|
||||
fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1;
|
||||
|
||||
if (table->field[fldno]->cond_selectivity > 0)
|
||||
{
|
||||
sel /= table->field[fldno]->cond_selectivity;
|
||||
|
|
|
@ -882,7 +882,7 @@ public:
|
|||
void set_empty()
|
||||
{
|
||||
sjm_scan_need_tables= 0;
|
||||
LINT_INIT_STRUCT(sjm_scan_last_inner);
|
||||
sjm_scan_last_inner= 0;
|
||||
is_used= FALSE;
|
||||
}
|
||||
void set_from_prev(struct st_position *prev);
|
||||
|
|
|
@ -2269,6 +2269,10 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
packet->append(STRING_WITH_LEN(" STORED"));
|
||||
else
|
||||
packet->append(STRING_WITH_LEN(" VIRTUAL"));
|
||||
if (field->invisible == INVISIBLE_USER)
|
||||
{
|
||||
packet->append(STRING_WITH_LEN(" INVISIBLE"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1820,16 +1820,13 @@ public:
|
|||
bool is_partial_fields_present;
|
||||
|
||||
Index_prefix_calc(THD *thd, TABLE *table, KEY *key_info)
|
||||
: index_table(table), index_info(key_info)
|
||||
: index_table(table), index_info(key_info), prefixes(0), empty(true),
|
||||
calc_state(NULL), is_single_comp_pk(false), is_partial_fields_present(false)
|
||||
{
|
||||
uint i;
|
||||
Prefix_calc_state *state;
|
||||
uint key_parts= table->actual_n_key_parts(key_info);
|
||||
empty= TRUE;
|
||||
prefixes= 0;
|
||||
LINT_INIT_STRUCT(calc_state);
|
||||
|
||||
is_partial_fields_present= is_single_comp_pk= FALSE;
|
||||
uint pk= table->s->primary_key;
|
||||
if ((uint) (table->key_info - key_info) == pk &&
|
||||
table->key_info[pk].user_defined_key_parts == 1)
|
||||
|
@ -2129,7 +2126,12 @@ int alloc_statistics_for_table(THD* thd, TABLE *table)
|
|||
Histogram_type hist_type= (Histogram_type) (thd->variables.histogram_type);
|
||||
uchar *histogram= NULL;
|
||||
if (hist_size > 0)
|
||||
histogram= (uchar *) alloc_root(&table->mem_root, hist_size * columns);
|
||||
{
|
||||
if ((histogram= (uchar *) alloc_root(&table->mem_root,
|
||||
hist_size * columns)))
|
||||
bzero(histogram, hist_size * columns);
|
||||
|
||||
}
|
||||
|
||||
if (!table_stats || !column_stats || !index_stats || !idx_avg_frequency ||
|
||||
(hist_size && !histogram))
|
||||
|
|
|
@ -7941,7 +7941,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||
Create_field *def;
|
||||
Field **f_ptr,*field;
|
||||
MY_BITMAP *dropped_fields= NULL; // if it's NULL - no dropped fields
|
||||
bool save_reopen= table->m_needs_reopen;
|
||||
bool drop_period= false;
|
||||
DBUG_ENTER("mysql_prepare_alter_table");
|
||||
|
||||
|
@ -8693,9 +8692,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||
alter_info->create_list.swap(new_create_list);
|
||||
alter_info->key_list.swap(new_key_list);
|
||||
alter_info->check_constraint_list.swap(new_constraint_list);
|
||||
DBUG_RETURN(rc);
|
||||
err:
|
||||
table->m_needs_reopen= save_reopen;
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
|
@ -11104,10 +11101,9 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
|
|||
{
|
||||
DBUG_ENTER("Sql_cmd_create_table::execute");
|
||||
LEX *lex= thd->lex;
|
||||
TABLE_LIST *all_tables= lex->query_tables;
|
||||
SELECT_LEX *select_lex= lex->first_select_lex();
|
||||
TABLE_LIST *first_table= select_lex->table_list.first;
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
DBUG_ASSERT(first_table == lex->query_tables && first_table != 0);
|
||||
bool link_to_local;
|
||||
TABLE_LIST *create_table= first_table;
|
||||
TABLE_LIST *select_tables= lex->create_last_non_select_table->next_global;
|
||||
|
|
|
@ -640,7 +640,7 @@ static ssize_t sst_prepare_other (const char* method,
|
|||
const char** addr_out)
|
||||
{
|
||||
bool extra_args;
|
||||
ssize_t const cmd_len= estimate_cmd_len(&extra_args);
|
||||
size_t const cmd_len= estimate_cmd_len(&extra_args);
|
||||
wsp::string cmd_str(cmd_len);
|
||||
|
||||
if (!cmd_str())
|
||||
|
@ -690,7 +690,7 @@ static ssize_t sst_prepare_other (const char* method,
|
|||
my_free(binlog_opt_val);
|
||||
my_free(binlog_index_opt_val);
|
||||
|
||||
if (ret < 0 || ret >= cmd_len)
|
||||
if (ret < 0 || size_t(ret) >= cmd_len)
|
||||
{
|
||||
WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret);
|
||||
return (ret < 0 ? ret : -EMSGSIZE);
|
||||
|
@ -953,7 +953,7 @@ static int sst_donate_mysqldump (const char* addr,
|
|||
memcpy(host, address.get_address(), address.get_address_len());
|
||||
int port= address.get_port();
|
||||
bool extra_args;
|
||||
ssize_t const cmd_len= estimate_cmd_len(&extra_args);
|
||||
size_t const cmd_len= estimate_cmd_len(&extra_args);
|
||||
wsp::string cmd_str(cmd_len);
|
||||
|
||||
if (!cmd_str())
|
||||
|
@ -990,7 +990,7 @@ static int sst_donate_mysqldump (const char* addr,
|
|||
wsrep_gtid_domain_id,
|
||||
bypass ? " " WSREP_SST_OPT_BYPASS : "");
|
||||
|
||||
if (ret < 0 || ret >= cmd_len)
|
||||
if (ret < 0 || size_t(ret) >= cmd_len)
|
||||
{
|
||||
WSREP_ERROR("sst_donate_mysqldump(): snprintf() failed: %d", ret);
|
||||
return (ret < 0 ? ret : -EMSGSIZE);
|
||||
|
@ -1350,7 +1350,7 @@ static int sst_donate_other (const char* method,
|
|||
char** env) // carries auth info
|
||||
{
|
||||
bool extra_args;
|
||||
ssize_t const cmd_len= estimate_cmd_len(&extra_args);
|
||||
size_t const cmd_len= estimate_cmd_len(&extra_args);
|
||||
wsp::string cmd_str(cmd_len);
|
||||
|
||||
if (!cmd_str())
|
||||
|
@ -1406,7 +1406,7 @@ static int sst_donate_other (const char* method,
|
|||
my_free(binlog_opt_val);
|
||||
my_free(binlog_index_opt_val);
|
||||
|
||||
if (ret < 0 || ret >= cmd_len)
|
||||
if (ret < 0 || size_t(ret) >= cmd_len)
|
||||
{
|
||||
WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret);
|
||||
return (ret < 0 ? ret : -EMSGSIZE);
|
||||
|
|
|
@ -100,6 +100,7 @@ static bool create_wsrep_THD(Wsrep_thd_args* args)
|
|||
break;
|
||||
default:
|
||||
assert(0);
|
||||
key= 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -50,7 +50,9 @@ int heap_scan(register HP_INFO *info, uchar *record)
|
|||
}
|
||||
else
|
||||
{
|
||||
info->next_block+=share->block.records_in_block;
|
||||
/* increase next_block to the next records_in_block boundary */
|
||||
ulong rem= info->next_block % share->block.records_in_block;
|
||||
info->next_block+=share->block.records_in_block - rem;
|
||||
if (info->next_block >= share->records+share->deleted)
|
||||
{
|
||||
info->next_block= share->records+share->deleted;
|
||||
|
|
|
@ -626,13 +626,8 @@ btr_scrub_get_table_and_index(
|
|||
scrub_data->current_table = NULL;
|
||||
}
|
||||
|
||||
/* argument to dict_table_open_on_index_id */
|
||||
bool dict_locked = true;
|
||||
|
||||
/* open table based on index_id */
|
||||
dict_table_t* table = dict_table_open_on_index_id(
|
||||
index_id,
|
||||
dict_locked);
|
||||
dict_table_t* table = dict_table_open_on_index_id(index_id);
|
||||
|
||||
if (table != NULL) {
|
||||
/* mark table as being scrubbed */
|
||||
|
|
|
@ -266,7 +266,7 @@ dict_table_try_drop_aborted(
|
|||
|
||||
if (table == NULL) {
|
||||
table = dict_table_open_on_id_low(
|
||||
table_id, DICT_ERR_IGNORE_NONE, FALSE);
|
||||
table_id, DICT_ERR_IGNORE_FK_NOKEY, FALSE);
|
||||
} else {
|
||||
ut_ad(table->id == table_id);
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ dict_table_open_on_id(
|
|||
table_id,
|
||||
table_op == DICT_TABLE_OP_LOAD_TABLESPACE
|
||||
? DICT_ERR_IGNORE_RECOVER_LOCK
|
||||
: DICT_ERR_IGNORE_NONE,
|
||||
: DICT_ERR_IGNORE_FK_NOKEY,
|
||||
table_op == DICT_TABLE_OP_OPEN_ONLY_IF_CACHED);
|
||||
|
||||
if (table != NULL) {
|
||||
|
@ -896,7 +896,7 @@ dict_table_open_on_name(
|
|||
if (table != NULL) {
|
||||
|
||||
/* If table is encrypted or corrupted */
|
||||
if (ignore_err == DICT_ERR_IGNORE_NONE
|
||||
if (!(ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY)
|
||||
&& !table->is_readable()) {
|
||||
/* Make life easy for drop table. */
|
||||
dict_sys.prevent_eviction(table);
|
||||
|
@ -2764,11 +2764,6 @@ dict_index_build_internal_fts(
|
|||
}
|
||||
/*====================== FOREIGN KEY PROCESSING ========================*/
|
||||
|
||||
#define DB_FOREIGN_KEY_IS_PREFIX_INDEX 200
|
||||
#define DB_FOREIGN_KEY_COL_NOT_NULL 201
|
||||
#define DB_FOREIGN_KEY_COLS_NOT_EQUAL 202
|
||||
#define DB_FOREIGN_KEY_INDEX_NOT_FOUND 203
|
||||
|
||||
/** Check whether the dict_table_t is a partition.
|
||||
A partitioned table on the SQL level is composed of InnoDB tables,
|
||||
where each InnoDB table is a [sub]partition including its secondary indexes
|
||||
|
@ -2875,7 +2870,7 @@ dict_foreign_find_index(
|
|||
/*!< in: nonzero if none of
|
||||
the columns must be declared
|
||||
NOT NULL */
|
||||
ulint* error, /*!< out: error code */
|
||||
fkerr_t* error, /*!< out: error code */
|
||||
ulint* err_col_no,
|
||||
/*!< out: column number where
|
||||
error happened */
|
||||
|
@ -2883,17 +2878,15 @@ dict_foreign_find_index(
|
|||
/*!< out: index where error
|
||||
happened */
|
||||
{
|
||||
dict_index_t* index;
|
||||
|
||||
ut_ad(mutex_own(&dict_sys.mutex));
|
||||
|
||||
if (error) {
|
||||
*error = DB_FOREIGN_KEY_INDEX_NOT_FOUND;
|
||||
*error = FK_INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
index = dict_table_get_first_index(table);
|
||||
|
||||
while (index != NULL) {
|
||||
for (dict_index_t* index = dict_table_get_first_index(table);
|
||||
index;
|
||||
index = dict_table_get_next_index(index)) {
|
||||
if (types_idx != index
|
||||
&& !index->to_be_dropped
|
||||
&& !dict_index_is_online_ddl(index)
|
||||
|
@ -2901,42 +2894,17 @@ dict_foreign_find_index(
|
|||
table, col_names, columns, n_cols,
|
||||
index, types_idx,
|
||||
check_charsets, check_null,
|
||||
error, err_col_no,err_index)) {
|
||||
error, err_col_no, err_index)) {
|
||||
if (error) {
|
||||
*error = DB_SUCCESS;
|
||||
*error = FK_SUCCESS;
|
||||
}
|
||||
|
||||
return(index);
|
||||
}
|
||||
|
||||
index = dict_table_get_next_index(index);
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
#ifdef WITH_WSREP
|
||||
dict_index_t*
|
||||
wsrep_dict_foreign_find_index(
|
||||
/*====================*/
|
||||
dict_table_t* table, /*!< in: table */
|
||||
const char** col_names, /*!< in: column names, or NULL
|
||||
to use table->col_names */
|
||||
const char** columns,/*!< in: array of column names */
|
||||
ulint n_cols, /*!< in: number of columns */
|
||||
dict_index_t* types_idx, /*!< in: NULL or an index to whose types the
|
||||
column types must match */
|
||||
ibool check_charsets,
|
||||
/*!< in: whether to check charsets.
|
||||
only has an effect if types_idx != NULL */
|
||||
ulint check_null)
|
||||
/*!< in: nonzero if none of the columns must
|
||||
be declared NOT NULL */
|
||||
{
|
||||
return dict_foreign_find_index(
|
||||
table, col_names, columns, n_cols, types_idx, check_charsets,
|
||||
check_null, NULL, NULL, NULL);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
/**********************************************************************//**
|
||||
Report an error in a foreign key definition. */
|
||||
static
|
||||
|
@ -3033,15 +3001,11 @@ dict_foreign_add_to_cache(
|
|||
}
|
||||
|
||||
if (ref_table && !for_in_cache->referenced_table) {
|
||||
ulint index_error;
|
||||
ulint err_col;
|
||||
dict_index_t *err_index=NULL;
|
||||
|
||||
index = dict_foreign_find_index(
|
||||
ref_table, NULL,
|
||||
for_in_cache->referenced_col_names,
|
||||
for_in_cache->n_fields, for_in_cache->foreign_index,
|
||||
check_charsets, false, &index_error, &err_col, &err_index);
|
||||
check_charsets, false);
|
||||
|
||||
if (index == NULL
|
||||
&& !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) {
|
||||
|
@ -3073,10 +3037,6 @@ dict_foreign_add_to_cache(
|
|||
}
|
||||
|
||||
if (for_table && !for_in_cache->foreign_table) {
|
||||
ulint index_error;
|
||||
ulint err_col;
|
||||
dict_index_t *err_index=NULL;
|
||||
|
||||
index = dict_foreign_find_index(
|
||||
for_table, col_names,
|
||||
for_in_cache->foreign_col_names,
|
||||
|
@ -3084,8 +3044,7 @@ dict_foreign_add_to_cache(
|
|||
for_in_cache->referenced_index, check_charsets,
|
||||
for_in_cache->type
|
||||
& (DICT_FOREIGN_ON_DELETE_SET_NULL
|
||||
| DICT_FOREIGN_ON_UPDATE_SET_NULL),
|
||||
&index_error, &err_col, &err_index);
|
||||
| DICT_FOREIGN_ON_UPDATE_SET_NULL));
|
||||
|
||||
if (index == NULL
|
||||
&& !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) {
|
||||
|
@ -3797,7 +3756,7 @@ dict_foreign_push_index_error(
|
|||
const char* latest_foreign, /*!< in: start of latest foreign key
|
||||
constraint name */
|
||||
const char** columns, /*!< in: foreign key columns */
|
||||
ulint index_error, /*!< in: error code */
|
||||
fkerr_t index_error, /*!< in: error code */
|
||||
ulint err_col, /*!< in: column where error happened
|
||||
*/
|
||||
dict_index_t* err_index, /*!< in: index where error happened
|
||||
|
@ -3806,37 +3765,37 @@ dict_foreign_push_index_error(
|
|||
FILE* ef) /*!< in: output stream */
|
||||
{
|
||||
switch (index_error) {
|
||||
case DB_FOREIGN_KEY_INDEX_NOT_FOUND: {
|
||||
case FK_SUCCESS:
|
||||
break;
|
||||
case FK_INDEX_NOT_FOUND:
|
||||
fprintf(ef,
|
||||
"%s table '%s' with foreign key constraint"
|
||||
"%s table %s with foreign key constraint"
|
||||
" failed. There is no index in the referenced"
|
||||
" table where the referenced columns appear"
|
||||
" as the first columns near '%s'.\n",
|
||||
operation, create_name, latest_foreign);
|
||||
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
|
||||
"%s table '%s' with foreign key constraint"
|
||||
"%s table %s with foreign key constraint"
|
||||
" failed. There is no index in the referenced"
|
||||
" table where the referenced columns appear"
|
||||
" as the first columns near '%s'.",
|
||||
operation, create_name, latest_foreign);
|
||||
break;
|
||||
}
|
||||
case DB_FOREIGN_KEY_IS_PREFIX_INDEX: {
|
||||
return;
|
||||
case FK_IS_PREFIX_INDEX:
|
||||
fprintf(ef,
|
||||
"%s table '%s' with foreign key constraint"
|
||||
"%s table %s with foreign key constraint"
|
||||
" failed. There is only prefix index in the referenced"
|
||||
" table where the referenced columns appear"
|
||||
" as the first columns near '%s'.\n",
|
||||
operation, create_name, latest_foreign);
|
||||
ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
|
||||
"%s table '%s' with foreign key constraint"
|
||||
"%s table %s with foreign key constraint"
|
||||
" failed. There is only prefix index in the referenced"
|
||||
" table where the referenced columns appear"
|
||||
" as the first columns near '%s'.",
|
||||
operation, create_name, latest_foreign);
|
||||
break;
|
||||
}
|
||||
case DB_FOREIGN_KEY_COL_NOT_NULL: {
|
||||
return;
|
||||
case FK_COL_NOT_NULL:
|
||||
fprintf(ef,
|
||||
"%s table %s with foreign key constraint"
|
||||
" failed. You have defined a SET NULL condition but "
|
||||
|
@ -3847,9 +3806,8 @@ dict_foreign_push_index_error(
|
|||
" failed. You have defined a SET NULL condition but "
|
||||
"column '%s' on index is defined as NOT NULL near '%s'.",
|
||||
operation, create_name, columns[err_col], latest_foreign);
|
||||
break;
|
||||
}
|
||||
case DB_FOREIGN_KEY_COLS_NOT_EQUAL: {
|
||||
return;
|
||||
case FK_COLS_NOT_EQUAL:
|
||||
dict_field_t* field;
|
||||
const char* col_name;
|
||||
field = dict_index_get_nth_field(err_index, err_col);
|
||||
|
@ -3868,11 +3826,9 @@ dict_foreign_push_index_error(
|
|||
" failed. Field type or character set for column '%s' "
|
||||
"does not mach referenced column '%s' near '%s'.",
|
||||
operation, create_name, columns[err_col], col_name, latest_foreign);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ut_error;
|
||||
return;
|
||||
}
|
||||
DBUG_ASSERT(!"unknown error");
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
|
@ -3904,7 +3860,7 @@ dict_create_foreign_constraints_low(
|
|||
const char* start_of_latest_foreign = sql_string;
|
||||
const char* start_of_latest_set = NULL;
|
||||
FILE* ef = dict_foreign_err_file;
|
||||
ulint index_error = DB_SUCCESS;
|
||||
fkerr_t index_error = FK_SUCCESS;
|
||||
dict_index_t* err_index = NULL;
|
||||
ulint err_col;
|
||||
const char* constraint_name;
|
||||
|
@ -6247,7 +6203,7 @@ dict_foreign_qualify_index(
|
|||
/*!< in: nonzero if none of
|
||||
the columns must be declared
|
||||
NOT NULL */
|
||||
ulint* error, /*!< out: error code */
|
||||
fkerr_t* error, /*!< out: error code */
|
||||
ulint* err_col_no,
|
||||
/*!< out: column number where
|
||||
error happened */
|
||||
|
@ -6275,7 +6231,7 @@ dict_foreign_qualify_index(
|
|||
/* We do not accept column prefix
|
||||
indexes here */
|
||||
if (error && err_col_no && err_index) {
|
||||
*error = DB_FOREIGN_KEY_IS_PREFIX_INDEX;
|
||||
*error = FK_IS_PREFIX_INDEX;
|
||||
*err_col_no = i;
|
||||
*err_index = (dict_index_t*)index;
|
||||
}
|
||||
|
@ -6285,7 +6241,7 @@ dict_foreign_qualify_index(
|
|||
if (check_null
|
||||
&& (field->col->prtype & DATA_NOT_NULL)) {
|
||||
if (error && err_col_no && err_index) {
|
||||
*error = DB_FOREIGN_KEY_COL_NOT_NULL;
|
||||
*error = FK_COL_NOT_NULL;
|
||||
*err_col_no = i;
|
||||
*err_index = (dict_index_t*)index;
|
||||
}
|
||||
|
@ -6315,7 +6271,7 @@ dict_foreign_qualify_index(
|
|||
dict_index_get_nth_col(types_idx, i),
|
||||
check_charsets)) {
|
||||
if (error && err_col_no && err_index) {
|
||||
*error = DB_FOREIGN_KEY_COLS_NOT_EQUAL;
|
||||
*error = FK_COLS_NOT_EQUAL;
|
||||
*err_col_no = i;
|
||||
*err_index = (dict_index_t*)index;
|
||||
}
|
||||
|
|
|
@ -3082,7 +3082,7 @@ func_exit:
|
|||
mem_heap_free(heap);
|
||||
|
||||
ut_ad(!table
|
||||
|| ignore_err != DICT_ERR_IGNORE_NONE
|
||||
|| (ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY)
|
||||
|| !table->is_readable()
|
||||
|| !table->corrupted);
|
||||
|
||||
|
@ -3771,29 +3771,14 @@ dict_load_table_id_on_index_id(
|
|||
return(found);
|
||||
}
|
||||
|
||||
UNIV_INTERN
|
||||
dict_table_t*
|
||||
dict_table_open_on_index_id(
|
||||
/*========================*/
|
||||
index_id_t index_id, /*!< in: index id */
|
||||
bool dict_locked) /*!< in: dict locked */
|
||||
dict_table_t* dict_table_open_on_index_id(index_id_t index_id)
|
||||
{
|
||||
if (!dict_locked) {
|
||||
mutex_enter(&dict_sys.mutex);
|
||||
}
|
||||
|
||||
ut_ad(mutex_own(&dict_sys.mutex));
|
||||
table_id_t table_id;
|
||||
dict_table_t * table = NULL;
|
||||
if (dict_load_table_id_on_index_id(index_id, &table_id)) {
|
||||
bool local_dict_locked = true;
|
||||
table = dict_table_open_on_id(table_id,
|
||||
local_dict_locked,
|
||||
table = dict_table_open_on_id(table_id, true,
|
||||
DICT_TABLE_OP_LOAD_TABLESPACE);
|
||||
}
|
||||
|
||||
if (!dict_locked) {
|
||||
mutex_exit(&dict_sys.mutex);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
|
|
@ -354,6 +354,34 @@ fil_space_destroy_crypt_data(
|
|||
}
|
||||
}
|
||||
|
||||
/** Fill crypt data information to the give page.
|
||||
It should be called during ibd file creation.
|
||||
@param[in] flags tablespace flags
|
||||
@param[in,out] page first page of the tablespace */
|
||||
void
|
||||
fil_space_crypt_t::fill_page0(
|
||||
ulint flags,
|
||||
byte* page)
|
||||
{
|
||||
const uint len = sizeof(iv);
|
||||
const ulint offset = FSP_HEADER_OFFSET
|
||||
+ fsp_header_get_encryption_offset(
|
||||
fil_space_t::zip_size(flags));
|
||||
page0_offset = offset;
|
||||
|
||||
memcpy(page + offset, CRYPT_MAGIC, MAGIC_SZ);
|
||||
mach_write_to_1(page + offset + MAGIC_SZ, type);
|
||||
mach_write_to_1(page + offset + MAGIC_SZ + 1, len);
|
||||
memcpy(page + offset + MAGIC_SZ + 2, &iv, len);
|
||||
|
||||
mach_write_to_4(page + offset + MAGIC_SZ + 2 + len,
|
||||
min_key_version);
|
||||
mach_write_to_4(page + offset + MAGIC_SZ + 2 + len + 4,
|
||||
key_id);
|
||||
mach_write_to_1(page + offset + MAGIC_SZ + 2 + len + 8,
|
||||
encryption);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
Write crypt data to a page (0)
|
||||
@param[in] space tablespace
|
||||
|
@ -2488,9 +2516,11 @@ static void fil_crypt_rotation_list_fill()
|
|||
/* Protect the tablespace while we may
|
||||
release fil_system.mutex. */
|
||||
space->n_pending_ops++;
|
||||
#ifndef DBUG_OFF
|
||||
fil_space_t* s= fil_system.read_page0(
|
||||
space->id);
|
||||
ut_ad(!s || s == space);
|
||||
#endif
|
||||
space->n_pending_ops--;
|
||||
if (!space->size) {
|
||||
/* Page 0 was not loaded.
|
||||
|
|
|
@ -2927,8 +2927,6 @@ fil_ibd_create(
|
|||
byte* page;
|
||||
bool success;
|
||||
bool has_data_dir = FSP_FLAGS_HAS_DATA_DIR(flags) != 0;
|
||||
fil_space_t* space = NULL;
|
||||
fil_space_crypt_t *crypt_data = NULL;
|
||||
|
||||
ut_ad(!is_system_tablespace(space_id));
|
||||
ut_ad(!srv_read_only_mode);
|
||||
|
@ -3019,6 +3017,19 @@ err_exit:
|
|||
fsp_header_init_fields(page, space_id, flags);
|
||||
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
|
||||
|
||||
/* Create crypt data if the tablespace is either encrypted or user has
|
||||
requested it to remain unencrypted. */
|
||||
fil_space_crypt_t *crypt_data = (mode != FIL_ENCRYPTION_DEFAULT
|
||||
|| srv_encrypt_tables)
|
||||
? fil_space_create_crypt_data(mode, key_id)
|
||||
: NULL;
|
||||
|
||||
if (crypt_data) {
|
||||
/* Write crypt data information in page0 while creating
|
||||
ibd file. */
|
||||
crypt_data->fill_page0(flags, page);
|
||||
}
|
||||
|
||||
if (ulint zip_size = fil_space_t::zip_size(flags)) {
|
||||
page_zip_des_t page_zip;
|
||||
page_zip_set_size(&page_zip, zip_size);
|
||||
|
@ -3066,15 +3077,9 @@ err_exit:
|
|||
}
|
||||
}
|
||||
|
||||
/* Create crypt data if the tablespace is either encrypted or user has
|
||||
requested it to remain unencrypted. */
|
||||
if (mode == FIL_ENCRYPTION_ON || mode == FIL_ENCRYPTION_OFF ||
|
||||
srv_encrypt_tables) {
|
||||
crypt_data = fil_space_create_crypt_data(mode, key_id);
|
||||
}
|
||||
|
||||
space = fil_space_create(name, space_id, flags, FIL_TYPE_TABLESPACE,
|
||||
crypt_data, mode);
|
||||
fil_space_t* space = fil_space_create(name, space_id, flags,
|
||||
FIL_TYPE_TABLESPACE,
|
||||
crypt_data, mode);
|
||||
if (!space) {
|
||||
free(crypt_data);
|
||||
*err = DB_ERROR;
|
||||
|
|
|
@ -3096,7 +3096,7 @@ static bool innobase_query_caching_table_check(
|
|||
const char* norm_name)
|
||||
{
|
||||
dict_table_t* table = dict_table_open_on_name(
|
||||
norm_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE);
|
||||
norm_name, FALSE, FALSE, DICT_ERR_IGNORE_FK_NOKEY);
|
||||
|
||||
if (table == NULL) {
|
||||
return false;
|
||||
|
@ -6084,9 +6084,7 @@ ha_innobase::open(const char* name, int, uint)
|
|||
the rollback invoking dict_index_t::clear_instant_alter() while
|
||||
open table handles exist in client connections. */
|
||||
|
||||
dict_table_t* ib_table;
|
||||
char norm_name[FN_REFLEN];
|
||||
dict_err_ignore_t ignore_err = DICT_ERR_IGNORE_NONE;
|
||||
|
||||
DBUG_ENTER("ha_innobase::open");
|
||||
|
||||
|
@ -6100,15 +6098,8 @@ ha_innobase::open(const char* name, int, uint)
|
|||
|
||||
char* is_part = is_partition(norm_name);
|
||||
THD* thd = ha_thd();
|
||||
|
||||
/* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table
|
||||
can be opened even if some FK indexes are missing. If not, the table
|
||||
can't be opened in the same situation */
|
||||
if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
|
||||
ignore_err = DICT_ERR_IGNORE_FK_NOKEY;
|
||||
}
|
||||
|
||||
ib_table = open_dict_table(name, norm_name, is_part, ignore_err);
|
||||
dict_table_t* ib_table = open_dict_table(name, norm_name, is_part,
|
||||
DICT_ERR_IGNORE_FK_NOKEY);
|
||||
|
||||
DEBUG_SYNC(thd, "ib_open_after_dict_open");
|
||||
|
||||
|
@ -10162,17 +10153,6 @@ next_record:
|
|||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
extern dict_index_t*
|
||||
wsrep_dict_foreign_find_index(
|
||||
/*==========================*/
|
||||
dict_table_t* table,
|
||||
const char** col_names,
|
||||
const char** columns,
|
||||
ulint n_cols,
|
||||
dict_index_t* types_idx,
|
||||
ibool check_charsets,
|
||||
ulint check_null);
|
||||
|
||||
inline
|
||||
const char*
|
||||
wsrep_key_type_to_str(Wsrep_service_key_type type)
|
||||
|
@ -10236,7 +10216,7 @@ wsrep_append_foreign_key(
|
|||
foreign->referenced_table_name_lookup);
|
||||
if (foreign->referenced_table) {
|
||||
foreign->referenced_index =
|
||||
wsrep_dict_foreign_find_index(
|
||||
dict_foreign_find_index(
|
||||
foreign->referenced_table, NULL,
|
||||
foreign->referenced_col_names,
|
||||
foreign->n_fields,
|
||||
|
@ -10250,7 +10230,7 @@ wsrep_append_foreign_key(
|
|||
|
||||
if (foreign->foreign_table) {
|
||||
foreign->foreign_index =
|
||||
wsrep_dict_foreign_find_index(
|
||||
dict_foreign_find_index(
|
||||
foreign->foreign_table, NULL,
|
||||
foreign->foreign_col_names,
|
||||
foreign->n_fields,
|
||||
|
@ -13189,8 +13169,8 @@ innobase_rename_table(
|
|||
row_mysql_lock_data_dictionary(trx);
|
||||
}
|
||||
|
||||
dict_table_t* table = dict_table_open_on_name(norm_from, TRUE, FALSE,
|
||||
DICT_ERR_IGNORE_NONE);
|
||||
dict_table_t* table = dict_table_open_on_name(
|
||||
norm_from, TRUE, FALSE, DICT_ERR_IGNORE_FK_NOKEY);
|
||||
|
||||
/* Since DICT_BG_YIELD has sleep for 250 milliseconds,
|
||||
Convert lock_wait_timeout unit from second to 250 milliseconds */
|
||||
|
@ -14310,7 +14290,7 @@ ha_innobase::defragment_table(
|
|||
normalize_table_name(norm_name, name);
|
||||
|
||||
table = dict_table_open_on_name(norm_name, FALSE,
|
||||
FALSE, DICT_ERR_IGNORE_NONE);
|
||||
FALSE, DICT_ERR_IGNORE_FK_NOKEY);
|
||||
|
||||
for (index = dict_table_get_first_index(table); index;
|
||||
index = dict_table_get_next_index(index)) {
|
||||
|
|
|
@ -116,12 +116,7 @@ dict_table_open_on_id(
|
|||
/**********************************************************************//**
|
||||
Returns a table object based on table id.
|
||||
@return table, NULL if does not exist */
|
||||
UNIV_INTERN
|
||||
dict_table_t*
|
||||
dict_table_open_on_index_id(
|
||||
/*==================*/
|
||||
table_id_t table_id, /*!< in: table id */
|
||||
bool dict_locked) /*!< in: TRUE=data dictionary locked */
|
||||
dict_table_t* dict_table_open_on_index_id(index_id_t index_id)
|
||||
__attribute__((warn_unused_result));
|
||||
/********************************************************************//**
|
||||
Decrements the count of open handles to a table. */
|
||||
|
@ -489,6 +484,21 @@ dict_table_open_on_name(
|
|||
dict_err_ignore_t ignore_err)
|
||||
MY_ATTRIBUTE((warn_unused_result));
|
||||
|
||||
/** Outcome of dict_foreign_find_index() or dict_foreign_qualify_index() */
|
||||
enum fkerr_t
|
||||
{
|
||||
/** A backing index was found for a FOREIGN KEY constraint */
|
||||
FK_SUCCESS = 0,
|
||||
/** There is no index that covers the columns in the constraint. */
|
||||
FK_INDEX_NOT_FOUND,
|
||||
/** The index is for a prefix index, not a full column. */
|
||||
FK_IS_PREFIX_INDEX,
|
||||
/** A condition of SET NULL conflicts with a NOT NULL column. */
|
||||
FK_COL_NOT_NULL,
|
||||
/** The column types do not match */
|
||||
FK_COLS_NOT_EQUAL
|
||||
};
|
||||
|
||||
/*********************************************************************//**
|
||||
Tries to find an index whose first fields are the columns in the array,
|
||||
in the same order and is not marked for deletion and is not the same
|
||||
|
@ -515,11 +525,11 @@ dict_foreign_find_index(
|
|||
/*!< in: nonzero if none of
|
||||
the columns must be declared
|
||||
NOT NULL */
|
||||
ulint* error, /*!< out: error code */
|
||||
ulint* err_col_no,
|
||||
fkerr_t* error = NULL, /*!< out: error code */
|
||||
ulint* err_col_no = NULL,
|
||||
/*!< out: column number where
|
||||
error happened */
|
||||
dict_index_t** err_index)
|
||||
dict_index_t** err_index = NULL)
|
||||
/*!< out: index where error
|
||||
happened */
|
||||
|
||||
|
@ -595,7 +605,7 @@ dict_foreign_qualify_index(
|
|||
/*!< in: nonzero if none of
|
||||
the columns must be declared
|
||||
NOT NULL */
|
||||
ulint* error, /*!< out: error code */
|
||||
fkerr_t* error, /*!< out: error code */
|
||||
ulint* err_col_no,
|
||||
/*!< out: column number where
|
||||
error happened */
|
||||
|
|
|
@ -66,11 +66,11 @@ Note: please define the IGNORE_ERR_* as bits, so their value can
|
|||
be or-ed together */
|
||||
enum dict_err_ignore_t {
|
||||
DICT_ERR_IGNORE_NONE = 0, /*!< no error to ignore */
|
||||
DICT_ERR_IGNORE_INDEX_ROOT = 1, /*!< ignore error if index root
|
||||
page is FIL_NULL or incorrect value */
|
||||
DICT_ERR_IGNORE_CORRUPT = 2, /*!< skip corrupted indexes */
|
||||
DICT_ERR_IGNORE_FK_NOKEY = 4, /*!< ignore error if any foreign
|
||||
DICT_ERR_IGNORE_FK_NOKEY = 1, /*!< ignore error if any foreign
|
||||
key is missing */
|
||||
DICT_ERR_IGNORE_INDEX_ROOT = 2, /*!< ignore error if index root
|
||||
page is FIL_NULL or incorrect value */
|
||||
DICT_ERR_IGNORE_CORRUPT = 4, /*!< skip corrupted indexes */
|
||||
DICT_ERR_IGNORE_RECOVER_LOCK = 8,
|
||||
/*!< Used when recovering table locks
|
||||
for resurrected transactions.
|
||||
|
|
|
@ -178,6 +178,12 @@ struct fil_space_crypt_t : st_encryption_scheme
|
|||
return (encryption == FIL_ENCRYPTION_OFF);
|
||||
}
|
||||
|
||||
/** Fill crypt data information to the give page.
|
||||
It should be called during ibd file creation.
|
||||
@param[in] flags tablespace flags
|
||||
@param[in,out] page first page of the tablespace */
|
||||
void fill_page0(ulint flags, byte* page);
|
||||
|
||||
/** Write crypt data to a page (0)
|
||||
@param[in] space tablespace
|
||||
@param[in,out] page0 first page of the tablespace
|
||||
|
|
|
@ -871,8 +871,12 @@ row_ins_foreign_report_add_err(
|
|||
fk_str = dict_print_info_on_foreign_key_in_create_format(trx, foreign,
|
||||
TRUE);
|
||||
fputs(fk_str.c_str(), ef);
|
||||
fprintf(ef, " in parent table, in index %s",
|
||||
foreign->foreign_index->name());
|
||||
if (foreign->foreign_index) {
|
||||
fprintf(ef, " in parent table, in index %s",
|
||||
foreign->foreign_index->name());
|
||||
} else {
|
||||
fputs(" in parent table", ef);
|
||||
}
|
||||
if (entry) {
|
||||
fputs(" tuple:\n", ef);
|
||||
/* TODO: DB_TRX_ID and DB_ROLL_PTR may be uninitialized.
|
||||
|
@ -1656,34 +1660,51 @@ row_ins_check_foreign_constraint(
|
|||
|| !check_table->is_readable()
|
||||
|| check_index == NULL) {
|
||||
|
||||
if (!srv_read_only_mode && check_ref) {
|
||||
FILE* ef = dict_foreign_err_file;
|
||||
std::string fk_str;
|
||||
FILE* ef = dict_foreign_err_file;
|
||||
std::string fk_str;
|
||||
|
||||
row_ins_set_detailed(trx, foreign);
|
||||
row_ins_set_detailed(trx, foreign);
|
||||
row_ins_foreign_trx_print(trx);
|
||||
|
||||
row_ins_foreign_trx_print(trx);
|
||||
|
||||
fputs("Foreign key constraint fails for table ", ef);
|
||||
ut_print_name(ef, trx,
|
||||
foreign->foreign_table_name);
|
||||
fputs(":\n", ef);
|
||||
fk_str = dict_print_info_on_foreign_key_in_create_format(
|
||||
trx, foreign, TRUE);
|
||||
fputs(fk_str.c_str(), ef);
|
||||
fprintf(ef, "\nTrying to add to index %s tuple:\n",
|
||||
foreign->foreign_index->name());
|
||||
fputs("Foreign key constraint fails for table ", ef);
|
||||
ut_print_name(ef, trx, check_ref
|
||||
? foreign->foreign_table_name
|
||||
: foreign->referenced_table_name);
|
||||
fputs(":\n", ef);
|
||||
fk_str = dict_print_info_on_foreign_key_in_create_format(
|
||||
trx, foreign, TRUE);
|
||||
fputs(fk_str.c_str(), ef);
|
||||
if (check_ref) {
|
||||
if (foreign->foreign_index) {
|
||||
fprintf(ef, "\nTrying to add to index %s"
|
||||
" tuple:\n",
|
||||
foreign->foreign_index->name());
|
||||
} else {
|
||||
fputs("\nTrying to add tuple:\n", ef);
|
||||
}
|
||||
dtuple_print(ef, entry);
|
||||
fputs("\nBut the parent table ", ef);
|
||||
ut_print_name(ef, trx,
|
||||
foreign->referenced_table_name);
|
||||
fputs("\nor its .ibd file does"
|
||||
ut_print_name(ef, trx, foreign->referenced_table_name);
|
||||
fputs("\nor its .ibd file or the required index does"
|
||||
" not currently exist!\n", ef);
|
||||
mutex_exit(&dict_foreign_err_mutex);
|
||||
|
||||
err = DB_NO_REFERENCED_ROW;
|
||||
} else {
|
||||
if (foreign->referenced_index) {
|
||||
fprintf(ef, "\nTrying to modify index %s"
|
||||
" tuple:\n",
|
||||
foreign->referenced_index->name());
|
||||
} else {
|
||||
fputs("\nTrying to modify tuple:\n", ef);
|
||||
}
|
||||
dtuple_print(ef, entry);
|
||||
fputs("\nBut the referencing table ", ef);
|
||||
ut_print_name(ef, trx, foreign->foreign_table_name);
|
||||
fputs("\nor its .ibd file or the required index does"
|
||||
" not currently exist!\n", ef);
|
||||
err = DB_ROW_IS_REFERENCED;
|
||||
}
|
||||
|
||||
mutex_exit(&dict_foreign_err_mutex);
|
||||
goto exit_func;
|
||||
}
|
||||
|
||||
|
@ -1949,6 +1970,7 @@ row_ins_check_foreign_constraints(
|
|||
/*==============================*/
|
||||
dict_table_t* table, /*!< in: table */
|
||||
dict_index_t* index, /*!< in: index */
|
||||
bool pk, /*!< in: index->is_primary() */
|
||||
dtuple_t* entry, /*!< in: index entry for index */
|
||||
que_thr_t* thr) /*!< in: query thread */
|
||||
{
|
||||
|
@ -1957,6 +1979,8 @@ row_ins_check_foreign_constraints(
|
|||
trx_t* trx;
|
||||
ibool got_s_lock = FALSE;
|
||||
|
||||
DBUG_ASSERT(index->is_primary() == pk);
|
||||
|
||||
trx = thr_get_trx(thr);
|
||||
|
||||
DEBUG_SYNC_C_IF_THD(thr_get_trx(thr)->mysql_thd,
|
||||
|
@ -1968,7 +1992,8 @@ row_ins_check_foreign_constraints(
|
|||
|
||||
foreign = *it;
|
||||
|
||||
if (foreign->foreign_index == index) {
|
||||
if (foreign->foreign_index == index
|
||||
|| (pk && !foreign->foreign_index)) {
|
||||
dict_table_t* ref_table = NULL;
|
||||
dict_table_t* referenced_table
|
||||
= foreign->referenced_table;
|
||||
|
@ -3177,7 +3202,7 @@ row_ins_clust_index_entry(
|
|||
|
||||
if (!index->table->foreign_set.empty()) {
|
||||
err = row_ins_check_foreign_constraints(
|
||||
index->table, index, entry, thr);
|
||||
index->table, index, true, entry, thr);
|
||||
if (err != DB_SUCCESS) {
|
||||
|
||||
DBUG_RETURN(err);
|
||||
|
@ -3276,7 +3301,7 @@ row_ins_sec_index_entry(
|
|||
|
||||
if (!index->table->foreign_set.empty()) {
|
||||
err = row_ins_check_foreign_constraints(index->table, index,
|
||||
entry, thr);
|
||||
false, entry, thr);
|
||||
if (err != DB_SUCCESS) {
|
||||
|
||||
return(err);
|
||||
|
|
|
@ -1419,11 +1419,13 @@ row_insert_for_mysql(
|
|||
&blob_heap);
|
||||
|
||||
if (ins_mode != ROW_INS_NORMAL) {
|
||||
#ifndef DBUG_OFF
|
||||
ut_ad(table->vers_start != table->vers_end);
|
||||
const mysql_row_templ_t* t
|
||||
= prebuilt->get_template_by_col(table->vers_end);
|
||||
ut_ad(t);
|
||||
ut_ad(t->mysql_col_len == 8);
|
||||
#endif
|
||||
|
||||
if (ins_mode == ROW_INS_HISTORICAL) {
|
||||
set_tuple_col_8(node->row, table->vers_end, trx->id,
|
||||
|
@ -1431,9 +1433,11 @@ row_insert_for_mysql(
|
|||
} else /* ROW_INS_VERSIONED */ {
|
||||
set_tuple_col_8(node->row, table->vers_end, TRX_ID_MAX,
|
||||
node->vers_end_buf);
|
||||
#ifndef DBUG_OFF
|
||||
t = prebuilt->get_template_by_col(table->vers_start);
|
||||
ut_ad(t);
|
||||
ut_ad(t->mysql_col_len == 8);
|
||||
#endif
|
||||
set_tuple_col_8(node->row, table->vers_start, trx->id,
|
||||
node->vers_start_buf);
|
||||
}
|
||||
|
@ -2887,7 +2891,7 @@ row_discard_tablespace_begin(
|
|||
dict_table_t* table;
|
||||
|
||||
table = dict_table_open_on_name(
|
||||
name, TRUE, FALSE, DICT_ERR_IGNORE_NONE);
|
||||
name, TRUE, FALSE, DICT_ERR_IGNORE_FK_NOKEY);
|
||||
|
||||
if (table) {
|
||||
dict_stats_wait_bg_to_stop_using_table(table, trx);
|
||||
|
@ -3271,7 +3275,7 @@ row_drop_table_from_cache(
|
|||
|
||||
dict_sys.remove(table);
|
||||
|
||||
if (dict_load_table(tablename, true, DICT_ERR_IGNORE_NONE)) {
|
||||
if (dict_load_table(tablename, true, DICT_ERR_IGNORE_FK_NOKEY)) {
|
||||
ib::error() << "Not able to remove table "
|
||||
<< ut_get_name(trx, tablename)
|
||||
<< " from the dictionary cache!";
|
||||
|
@ -4183,7 +4187,7 @@ row_rename_table_for_mysql(
|
|||
dict_locked = trx->dict_operation_lock_mode == RW_X_LATCH;
|
||||
|
||||
table = dict_table_open_on_name(old_name, dict_locked, FALSE,
|
||||
DICT_ERR_IGNORE_NONE);
|
||||
DICT_ERR_IGNORE_FK_NOKEY);
|
||||
|
||||
/* We look for pattern #P# to see if the table is partitioned
|
||||
MySQL table. */
|
||||
|
@ -4231,7 +4235,7 @@ row_rename_table_for_mysql(
|
|||
par_case_name, old_name, FALSE);
|
||||
#endif
|
||||
table = dict_table_open_on_name(par_case_name, dict_locked, FALSE,
|
||||
DICT_ERR_IGNORE_NONE);
|
||||
DICT_ERR_IGNORE_FK_NOKEY);
|
||||
}
|
||||
|
||||
if (!table) {
|
||||
|
|
|
@ -2140,6 +2140,15 @@ files_checked:
|
|||
The data dictionary latch should guarantee that there is at
|
||||
most one data dictionary transaction active at a time. */
|
||||
if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) {
|
||||
/* If the following call is ever removed, the
|
||||
first-time ha_innobase::open() must hold (or
|
||||
acquire and release) a table lock that
|
||||
conflicts with trx_resurrect_table_locks(), to
|
||||
ensure that any recovered incomplete ALTER TABLE
|
||||
will have been rolled back. Otherwise,
|
||||
dict_table_t::instant could be cleared by rollback
|
||||
invoking dict_index_t::clear_instant_alter() while
|
||||
open table handles exist in client connections. */
|
||||
trx_rollback_recovered(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,13 +79,13 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
|
|||
MARIA_KEY key;
|
||||
float tmp_weight;
|
||||
DBUG_ENTER("walk_and_match");
|
||||
LINT_INIT_STRUCT(subkeys);
|
||||
|
||||
word->weight=LWS_FOR_QUERY;
|
||||
|
||||
_ma_ft_make_key(info, &key, aio->keynr, keybuff, word, 0);
|
||||
key.data_length-= HA_FT_WLEN;
|
||||
doc_cnt=0;
|
||||
subkeys.i= 0;
|
||||
|
||||
if (share->lock_key_trees)
|
||||
mysql_rwlock_rdlock(&share->keyinfo[aio->keynr].root_lock);
|
||||
|
|
|
@ -9007,10 +9007,12 @@ bool ha_mroonga::is_foreign_key_field(const char *table_name,
|
|||
|
||||
grn_obj *range = grn_ctx_at(ctx, grn_obj_get_range(ctx, column));
|
||||
if (!range) {
|
||||
grn_obj_unlink(ctx, column);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
if (!mrn::grn::is_table(range)) {
|
||||
grn_obj_unlink(ctx, column);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
@ -9024,6 +9026,7 @@ bool ha_mroonga::is_foreign_key_field(const char *table_name,
|
|||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
grn_obj_unlink(ctx, column);
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,13 +77,13 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
|
|||
uint extra= HA_FT_WLEN + info->s->rec_reflength;
|
||||
float tmp_weight;
|
||||
DBUG_ENTER("walk_and_match");
|
||||
LINT_INIT_STRUCT(subkeys);
|
||||
|
||||
word->weight=LWS_FOR_QUERY;
|
||||
|
||||
keylen=_ft_make_key(info,aio->keynr,keybuff,word,0);
|
||||
keylen-=HA_FT_WLEN;
|
||||
doc_cnt=0;
|
||||
subkeys.i= 0;
|
||||
|
||||
if (share->concurrent_insert)
|
||||
mysql_rwlock_rdlock(&share->key_root_lock[aio->keynr]);
|
||||
|
|
|
@ -26,6 +26,7 @@ start transaction with consistent snapshot;
|
|||
select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
|
||||
Has opened snapshots
|
||||
1
|
||||
connection default;
|
||||
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
|
||||
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
|
||||
set rocksdb_bulk_load=1;
|
||||
|
|
|
@ -26,6 +26,7 @@ start transaction with consistent snapshot;
|
|||
select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
|
||||
Has opened snapshots
|
||||
1
|
||||
connection default;
|
||||
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
|
||||
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
|
||||
set rocksdb_bulk_load=1;
|
||||
|
|
|
@ -26,6 +26,7 @@ start transaction with consistent snapshot;
|
|||
select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
|
||||
Has opened snapshots
|
||||
1
|
||||
connection default;
|
||||
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
|
||||
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
|
||||
set rocksdb_bulk_load=1;
|
||||
|
|
|
@ -26,6 +26,7 @@ start transaction with consistent snapshot;
|
|||
select VALUE > 0 as 'Has opened snapshots' from information_schema.rocksdb_dbstats where stat_type='DB_NUM_SNAPSHOTS';
|
||||
Has opened snapshots
|
||||
1
|
||||
connection default;
|
||||
SET @@GLOBAL.ROCKSDB_UPDATE_CF_OPTIONS=
|
||||
'cf1={write_buffer_size=8m;target_file_size_base=1m};';
|
||||
set rocksdb_bulk_load=1;
|
||||
|
|
|
@ -6680,7 +6680,7 @@ int spider_db_mbase_util::append_tables_top_down(
|
|||
int error_num;
|
||||
uint outer_join_backup;
|
||||
TABLE_LIST *cur_table_list, *prev_table_list = NULL, *cond_table_list = NULL;
|
||||
bool first;
|
||||
bool first = TRUE;
|
||||
DBUG_ENTER("spider_db_mbase_util::append_tables_top_down");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue