Merge branch '10.3' into 10.4
This commit is contained in:
commit
f5844e7c4b
@ -242,8 +242,6 @@ IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(wsrep)
|
||||
INCLUDE(cpack_rpm)
|
||||
INCLUDE(cpack_deb)
|
||||
|
||||
OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_EXIT()" ON)
|
||||
IF(WITH_DBUG_TRACE)
|
||||
@ -369,8 +367,6 @@ MYSQL_CHECK_SSL()
|
||||
MYSQL_CHECK_READLINE()
|
||||
|
||||
SET(MALLOC_LIBRARY "system")
|
||||
SET(PYTHON_SHEBANG "/usr/bin/env python" CACHE STRING "python shebang")
|
||||
MARK_AS_ADVANCED(PYTHON_SHEBANG)
|
||||
|
||||
CHECK_PCRE()
|
||||
|
||||
@ -407,6 +403,12 @@ SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "")
|
||||
|
||||
INCLUDE(mariadb_connector_c) # this does ADD_SUBDIRECTORY(libmariadb)
|
||||
|
||||
INCLUDE(cpack_rpm)
|
||||
INCLUDE(cpack_deb)
|
||||
|
||||
SET(PYTHON_SHEBANG "/usr/bin/env python" CACHE STRING "python shebang")
|
||||
MARK_AS_ADVANCED(PYTHON_SHEBANG)
|
||||
|
||||
# Add storage engines and plugins.
|
||||
CONFIGURE_PLUGINS()
|
||||
|
||||
|
@ -114,12 +114,16 @@ SET(ignored
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/lib/systemd"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/lib/systemd/system"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/lib/tmpfiles.d"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/lib/sysusers.d"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/lib64"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/sbin"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/aclocal"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/doc"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/man"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man1"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man8"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man1*"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man8*"
|
||||
"%ignore ${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
|
||||
@ -192,9 +196,10 @@ SET(CPACK_RPM_compat_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/
|
||||
SET(CPACK_RPM_compat_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh)
|
||||
|
||||
MACRO(ALTERNATIVE_NAME real alt)
|
||||
SET(ver "%{version}-%{release}")
|
||||
IF (${epoch})
|
||||
SET(ver "${epoch}:${ver}")
|
||||
IF(${ARGC} GREATER 2)
|
||||
SET(ver ${ARGV2})
|
||||
ELSE()
|
||||
SET(ver "${epoch}%{version}-%{release}")
|
||||
ENDIF()
|
||||
|
||||
SET(p "CPACK_RPM_${real}_PACKAGE_PROVIDES")
|
||||
@ -209,17 +214,40 @@ ALTERNATIVE_NAME("test" "mysql-test")
|
||||
|
||||
# Argh! Different distributions call packages differently, to be a drop-in
|
||||
# replacement we have to fake distribution-specific dependencies
|
||||
# NOTE, use ALTERNATIVE_NAME when a package has a different name
|
||||
# in some distribution, it's not for adding new PROVIDES
|
||||
|
||||
IF(RPM MATCHES "(rhel|centos)6")
|
||||
ALTERNATIVE_NAME("client" "mysql")
|
||||
ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7")
|
||||
SET(epoch 1) # this is fedora
|
||||
SET(epoch 1:) # this is fedora
|
||||
ALTERNATIVE_NAME("client" "mariadb")
|
||||
ALTERNATIVE_NAME("client" "mysql")
|
||||
ALTERNATIVE_NAME("devel" "mariadb-devel")
|
||||
ALTERNATIVE_NAME("server" "mariadb-server")
|
||||
ALTERNATIVE_NAME("server" "mysql-compat-server")
|
||||
ALTERNATIVE_NAME("test" "mariadb-test")
|
||||
ELSEIF(RPM MATCHES "(rhel|centos)8")
|
||||
SET(epoch 3:)
|
||||
ALTERNATIVE_NAME("backup" "mariadb-backup")
|
||||
ALTERNATIVE_NAME("client" "mariadb")
|
||||
ALTERNATIVE_NAME("common" "mariadb-common")
|
||||
ALTERNATIVE_NAME("common" "mariadb-errmsg")
|
||||
ALTERNATIVE_NAME("server" "mariadb-server")
|
||||
ALTERNATIVE_NAME("server" "mariadb-server-utils")
|
||||
ALTERNATIVE_NAME("shared" "mariadb-connector-c" ${MARIADB_CONNECTOR_C_VERSION}-1)
|
||||
ALTERNATIVE_NAME("shared" "mariadb-connector-c-config" ${MARIADB_CONNECTOR_C_VERSION}-1)
|
||||
SETA(CPACK_RPM_client_PACKAGE_PROVIDES "mariadb-galera = 3:%{version}-%{release}")
|
||||
SETA(CPACK_RPM_common_PACKAGE_PROVIDES "mariadb-galera-common = 3:%{version}-%{release}")
|
||||
SETA(CPACK_RPM_common_PACKAGE_REQUIRES "MariaDB-shared")
|
||||
ELSEIF(RPM MATCHES "sles")
|
||||
ALTERNATIVE_NAME("server" "mariadb")
|
||||
SETA(CPACK_RPM_server_PACKAGE_PROVIDES
|
||||
"mysql = %{version}-%{release}"
|
||||
"mariadb_${MAJOR_VERSION}${MINOR_VERSION} = %{version}-%{release}"
|
||||
"mariadb-${MAJOR_VERSION}${MINOR_VERSION} = %{version}-%{release}"
|
||||
"mariadb-server = %{version}-%{release}"
|
||||
)
|
||||
ENDIF()
|
||||
IF(RPM MATCHES "fedora31" OR RPM MATCHES "(rhel|centos)8")
|
||||
SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang")
|
||||
|
@ -42,3 +42,6 @@ ADD_SUBDIRECTORY(libmariadb)
|
||||
IF(TARGET caching_sha2_password AND CMAKE_C_FLAGS_DEBUG MATCHES "-Werror")
|
||||
SET_PROPERTY(TARGET caching_sha2_password APPEND_STRING PROPERTY COMPILE_FLAGS -Wno-unused-function)
|
||||
ENDIF()
|
||||
|
||||
GET_DIRECTORY_PROPERTY(MARIADB_CONNECTOR_C_VERSION DIRECTORY libmariadb DEFINITION CPACK_PACKAGE_VERSION)
|
||||
MESSAGE1(MARIADB_CONNECTOR_C_VERSION "MariaDB Connector/C ${MARIADB_CONNECTOR_C_VERSION}")
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ca8f94f727dba19a6ac43691df53fdc829e2124e
|
||||
Subproject commit 2759b87d72926b7c9b5426437a7c8dd15ff57945
|
@ -1,3 +1,4 @@
|
||||
set @save_session_track_system_variables=@@session_track_system_variables;
|
||||
SELECT @@session.character_set_connection;
|
||||
@@session.character_set_connection
|
||||
latin1
|
||||
@ -28,4 +29,19 @@ SET NAMES 'utf8';
|
||||
|
||||
# tracking info off once
|
||||
SET NAMES 'big5';
|
||||
SET @@session.session_track_system_variables= default;
|
||||
SET @@session.session_track_system_variables= @save_session_track_system_variables;
|
||||
#
|
||||
# MDEV-22504: session tracking return incorrectly long traking data
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
SET @@session.session_track_system_variables='optimizer_switch';
|
||||
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- optimizer_switch
|
||||
-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
|
||||
|
||||
Warnings:
|
||||
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
SET @@session.session_track_system_variables= @save_session_track_system_variables;
|
||||
# End of 10.2 tests
|
||||
|
@ -2,6 +2,9 @@
|
||||
--source include/no_protocol.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
|
||||
set @save_session_track_system_variables=@@session_track_system_variables;
|
||||
|
||||
SELECT @@session.character_set_connection;
|
||||
SET @@session.session_track_system_variables='character_set_connection';
|
||||
|
||||
@ -22,4 +25,23 @@ SET NAMES 'utf8';
|
||||
SET NAMES 'big5';
|
||||
--disable_session_track_info
|
||||
|
||||
SET @@session.session_track_system_variables= default;
|
||||
SET @@session.session_track_system_variables= @save_session_track_system_variables;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-22504: session tracking return incorrectly long traking data
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
SET @@session.session_track_system_variables='optimizer_switch';
|
||||
|
||||
--enable_session_track_info
|
||||
set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off';
|
||||
--disable_session_track_info
|
||||
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
|
||||
SET @@session.session_track_system_variables= @save_session_track_system_variables;
|
||||
|
||||
--echo # End of 10.2 tests
|
||||
|
@ -3,10 +3,11 @@
|
||||
#
|
||||
connect con1,localhost,root,,;
|
||||
connection con1;
|
||||
SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync';
|
||||
SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync WAIT_FOR go';
|
||||
connection default;
|
||||
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
|
||||
FOUND 1 /sleep \(30\)/ in MDEV-20466.text
|
||||
FOUND 1 /sleep/ in MDEV-20466.text
|
||||
SET DEBUG_SYNC= 'now SIGNAL go';
|
||||
disconnect con1;
|
||||
SET DEBUG_SYNC = 'RESET';
|
||||
End of 5.5 tests
|
||||
|
@ -1,6 +1,7 @@
|
||||
source include/have_debug.inc;
|
||||
source include/have_debug_sync.inc;
|
||||
source include/not_embedded.inc;
|
||||
source include/count_sessions.inc;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20466: SHOW PROCESSLIST truncates query text on \0 bytes
|
||||
@ -10,9 +11,9 @@ connect (con1,localhost,root,,);
|
||||
|
||||
connection con1;
|
||||
|
||||
let $q= `select CONCAT("SELECT user FROM mysql.user WHERE user ='some", CHAR(0), "' or sleep (30)")`;
|
||||
let $q= `select CONCAT("SELECT user FROM mysql.user WHERE user ='some", CHAR(0), "sleep'")`;
|
||||
|
||||
SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync';
|
||||
SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync WAIT_FOR go';
|
||||
--disable_query_log
|
||||
--send_eval $q;
|
||||
--enable_query_log
|
||||
@ -23,12 +24,16 @@ SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
|
||||
exec $MYSQL test -e "SHOW PROCESSLIST" > $MYSQLTEST_VARDIR/tmp/MDEV-20466.text;
|
||||
|
||||
let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/MDEV-20466.text;
|
||||
let SEARCH_PATTERN=sleep \(30\);
|
||||
let SEARCH_PATTERN=sleep;
|
||||
source include/search_pattern_in_file.inc;
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/MDEV-20466.text;
|
||||
|
||||
SET DEBUG_SYNC= 'now SIGNAL go';
|
||||
|
||||
disconnect con1;
|
||||
|
||||
SET DEBUG_SYNC = 'RESET';
|
||||
|
||||
source include/wait_until_count_sessions.inc;
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
@ -210,6 +210,7 @@ ERROR 70100: Query execution was interrupted
|
||||
connection con1;
|
||||
ROLLBACK;
|
||||
connection default;
|
||||
disconnect con1;
|
||||
DROP TABLE t3,t1;
|
||||
#
|
||||
# MDEV-18222 InnoDB: Failing assertion: heap->magic_n == MEM_BLOCK_MAGIC_N
|
||||
@ -291,6 +292,121 @@ ALTER TABLE t1 DROP f3;
|
||||
ALTER TABLE t1 CHANGE f f3 INT;
|
||||
DROP TABLE t1;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
#
|
||||
# Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE
|
||||
# ADD FOREIGN KEY
|
||||
#
|
||||
CREATE TABLE `department` (`department_id` INT, `department_people_fk` INT,
|
||||
PRIMARY KEY (`department_id`)) engine=innodb;
|
||||
CREATE TABLE `title` (`title_id` INT, `title_manager_fk` INT,
|
||||
`title_reporter_fk` INT, PRIMARY KEY (`title_id`)) engine=innodb;
|
||||
CREATE TABLE `people` (`people_id` INT, PRIMARY KEY (`people_id`)) engine=innodb;
|
||||
ALTER TABLE `department` ADD FOREIGN KEY (`department_people_fk`) REFERENCES
|
||||
`people` (`people_id`);
|
||||
ALTER TABLE `title` ADD FOREIGN KEY (`title_manager_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
ALTER TABLE `title` ADD FOREIGN KEY (`title_reporter_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
drop table title, department, people;
|
||||
create table t1 (a int primary key, b int) engine=innodb;
|
||||
create table t2 (c int primary key, d int,
|
||||
foreign key (d) references t1 (a) on update cascade) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
insert t2 values (4,1),(5,2),(6,3);
|
||||
flush table t2 with read lock;
|
||||
connect con1,localhost,root;
|
||||
delete from t1 where a=2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
|
||||
update t1 set a=10 where a=1;
|
||||
connection default;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
connection default;
|
||||
lock table t2 write;
|
||||
connection con1;
|
||||
delete from t1 where a=2;
|
||||
connection default;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE)
|
||||
connection default;
|
||||
unlock tables;
|
||||
disconnect con1;
|
||||
create user foo;
|
||||
grant select,update on test.t1 to foo;
|
||||
connect foo,localhost,foo;
|
||||
update t1 set a=30 where a=3;
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from t2;
|
||||
c d
|
||||
5 2
|
||||
4 10
|
||||
6 30
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
#
|
||||
# MDEV-17595 - Server crashes in copy_data_between_tables or
|
||||
# Assertion `thd->transaction.stmt.is_empty() ||
|
||||
# (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)'
|
||||
# fails in close_tables_for_reopen upon concurrent
|
||||
# ALTER TABLE and FLUSH
|
||||
#
|
||||
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(1),(2);
|
||||
CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES(2);
|
||||
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
|
||||
DROP TABLE t2, t1;
|
||||
create table t1 (pk int primary key, data int) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 (t1_pk int, foreign key (t1_pk) references t1 (pk)) engine=innodb;
|
||||
insert t2 values (1),(2);
|
||||
insert t2 values (10);
|
||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_pk`) REFERENCES `t1` (`pk`))
|
||||
flush tables;
|
||||
flush status;
|
||||
update t1 set data=10 where pk+1>10;
|
||||
show status like '%opened_tab%';
|
||||
Variable_name Value
|
||||
Opened_table_definitions 4
|
||||
Opened_tables 4
|
||||
flush tables;
|
||||
flush status;
|
||||
update t2 set t1_pk=11 where t1_pk+1>10;
|
||||
show status like '%opened_tab%';
|
||||
Variable_name Value
|
||||
Opened_table_definitions 4
|
||||
Opened_tables 4
|
||||
flush tables;
|
||||
flush status;
|
||||
lock tables t1 write;
|
||||
show status like '%opened_tab%';
|
||||
Variable_name Value
|
||||
Opened_table_definitions 2
|
||||
Opened_tables 2
|
||||
insert t1 values (4,4);
|
||||
show status like '%opened_tab%';
|
||||
Variable_name Value
|
||||
Opened_table_definitions 5
|
||||
Opened_tables 5
|
||||
unlock tables;
|
||||
create function foo() returns int
|
||||
begin
|
||||
insert t1 values (5,5);
|
||||
return 5;
|
||||
end|
|
||||
flush tables;
|
||||
flush status;
|
||||
select foo();
|
||||
foo()
|
||||
5
|
||||
show status like '%opened_tab%';
|
||||
Variable_name Value
|
||||
Opened_table_definitions 5
|
||||
Opened_tables 5
|
||||
drop function foo;
|
||||
drop table t2, t1;
|
||||
# Start of 10.2 tests
|
||||
#
|
||||
# MDEV-13246 Stale rows despite ON DELETE CASCADE constraint
|
||||
@ -328,6 +444,7 @@ INSERT INTO matchmaking_group_users VALUES (10,1),(11,2);
|
||||
INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
|
||||
BEGIN;
|
||||
UPDATE users SET name = 'qux' WHERE id = 1;
|
||||
connect con1,localhost,root;
|
||||
connection con1;
|
||||
SET innodb_lock_wait_timeout= 1;
|
||||
DELETE FROM matchmaking_groups WHERE id = 10;
|
||||
@ -538,6 +655,65 @@ Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
||||
#
|
||||
# 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'
|
||||
# End of 10.2 tests
|
||||
CREATE TABLE t1 (a GEOMETRY, INDEX(a(8)),
|
||||
FOREIGN KEY (a) REFERENCES x (xx)) ENGINE=InnoDB;
|
||||
|
60
mysql-test/suite/innodb/r/foreign_key_debug.result
Normal file
60
mysql-test/suite/innodb/r/foreign_key_debug.result
Normal file
@ -0,0 +1,60 @@
|
||||
create table t1 (f1 int primary key) engine=innodb;
|
||||
create table t2 (f2 int primary key) engine=innodb;
|
||||
create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
insert into t2 values (1),(2),(3),(4),(5);
|
||||
insert into t3 values (1),(2),(3),(4),(5);
|
||||
connect con1,localhost,root;
|
||||
set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2';
|
||||
alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade;
|
||||
connection default;
|
||||
set debug_sync='before_execute_sql_command wait_for g1';
|
||||
update t1 set f1 = f1 + 100000 limit 2;
|
||||
connect con2,localhost,root;
|
||||
kill query UPDATE;
|
||||
disconnect con2;
|
||||
connection default;
|
||||
ERROR 70100: Query execution was interrupted
|
||||
set debug_sync='now signal g2';
|
||||
connection con1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`f2` int(11) NOT NULL,
|
||||
PRIMARY KEY (`f2`),
|
||||
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
disconnect con1;
|
||||
connection default;
|
||||
select * from t2 where f2 not in (select f1 from t1);
|
||||
f2
|
||||
select * from t3 where f3 not in (select f2 from t2);
|
||||
f3
|
||||
drop table t3;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
set debug_sync='reset';
|
||||
#
|
||||
# MDEV-16060 - InnoDB: Failing assertion: ut_strcmp(index->name, key->name)
|
||||
#
|
||||
CREATE TABLE t1 (`pk` INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
FLUSH TABLES;
|
||||
SET debug_sync='alter_table_intermediate_table_created SIGNAL ready WAIT_FOR go';
|
||||
ALTER TABLE t1 ADD FOREIGN KEY(pk) REFERENCES t2(pk) ON UPDATE CASCADE;
|
||||
connect con1, localhost, root;
|
||||
SET debug_sync='now WAIT_FOR ready';
|
||||
SET lock_wait_timeout=0;
|
||||
UPDATE t2 SET pk=10 WHERE pk=1;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
PREPARE stmt FROM 'UPDATE t2 SET pk=10 WHERE pk=1';
|
||||
DEALLOCATE PREPARE stmt;
|
||||
SET debug_sync='now SIGNAL go';
|
||||
connection default;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
SET debug_sync='reset';
|
||||
SHOW OPEN TABLES FROM test;
|
||||
Database Table In_use Name_locked
|
||||
test t2 0 0
|
||||
DROP TABLE t1, t2;
|
@ -195,6 +195,7 @@ reap;
|
||||
connection con1;
|
||||
ROLLBACK;
|
||||
connection default;
|
||||
disconnect con1;
|
||||
|
||||
DROP TABLE t3,t1;
|
||||
|
||||
@ -281,6 +282,136 @@ DROP TABLE t1;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE
|
||||
--echo # ADD FOREIGN KEY
|
||||
--echo #
|
||||
|
||||
CREATE TABLE `department` (`department_id` INT, `department_people_fk` INT,
|
||||
PRIMARY KEY (`department_id`)) engine=innodb;
|
||||
|
||||
CREATE TABLE `title` (`title_id` INT, `title_manager_fk` INT,
|
||||
`title_reporter_fk` INT, PRIMARY KEY (`title_id`)) engine=innodb;
|
||||
|
||||
CREATE TABLE `people` (`people_id` INT, PRIMARY KEY (`people_id`)) engine=innodb;
|
||||
|
||||
ALTER TABLE `department` ADD FOREIGN KEY (`department_people_fk`) REFERENCES
|
||||
`people` (`people_id`);
|
||||
|
||||
ALTER TABLE `title` ADD FOREIGN KEY (`title_manager_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
|
||||
ALTER TABLE `title` ADD FOREIGN KEY (`title_reporter_fk`) REFERENCES `people`
|
||||
(`people_id`);
|
||||
|
||||
drop table title, department, people;
|
||||
|
||||
#
|
||||
# FK and prelocking:
|
||||
# child table accesses (reads and writes) wait for locks.
|
||||
#
|
||||
create table t1 (a int primary key, b int) engine=innodb;
|
||||
create table t2 (c int primary key, d int,
|
||||
foreign key (d) references t1 (a) on update cascade) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
insert t2 values (4,1),(5,2),(6,3);
|
||||
flush table t2 with read lock; # this takes MDL_SHARED_NO_WRITE
|
||||
connect (con1,localhost,root);
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
delete from t1 where a=2;
|
||||
send update t1 set a=10 where a=1;
|
||||
connection default;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
|
||||
source include/wait_condition.inc;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
reap;
|
||||
connection default;
|
||||
lock table t2 write; # this takes MDL_SHARED_NO_READ_WRITE
|
||||
connection con1;
|
||||
send delete from t1 where a=2;
|
||||
connection default;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock';
|
||||
source include/wait_condition.inc;
|
||||
unlock tables;
|
||||
connection con1;
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
reap;
|
||||
connection default;
|
||||
unlock tables;
|
||||
disconnect con1;
|
||||
|
||||
# but privileges should not be checked
|
||||
create user foo;
|
||||
grant select,update on test.t1 to foo;
|
||||
connect(foo,localhost,foo);
|
||||
update t1 set a=30 where a=3;
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from t2;
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17595 - Server crashes in copy_data_between_tables or
|
||||
--echo # Assertion `thd->transaction.stmt.is_empty() ||
|
||||
--echo # (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)'
|
||||
--echo # fails in close_tables_for_reopen upon concurrent
|
||||
--echo # ALTER TABLE and FLUSH
|
||||
--echo #
|
||||
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(1),(2);
|
||||
CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES(2);
|
||||
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
|
||||
DROP TABLE t2, t1;
|
||||
|
||||
#
|
||||
# MDEV-22180 Planner opens unnecessary tables when updated table is referenced by foreign keys
|
||||
#
|
||||
|
||||
create table t1 (pk int primary key, data int) engine=innodb;
|
||||
insert t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 (t1_pk int, foreign key (t1_pk) references t1 (pk)) engine=innodb;
|
||||
insert t2 values (1),(2);
|
||||
error ER_NO_REFERENCED_ROW_2;
|
||||
insert t2 values (10);
|
||||
flush tables;
|
||||
flush status;
|
||||
# with ON UPDATE RESTRICT child tables are not opened
|
||||
update t1 set data=10 where pk+1>10;
|
||||
show status like '%opened_tab%';
|
||||
flush tables;
|
||||
flush status;
|
||||
# neither are parent tables
|
||||
update t2 set t1_pk=11 where t1_pk+1>10;
|
||||
show status like '%opened_tab%';
|
||||
# under LOCK TABLES
|
||||
flush tables;
|
||||
flush status;
|
||||
lock tables t1 write;
|
||||
show status like '%opened_tab%';
|
||||
insert t1 values (4,4);
|
||||
show status like '%opened_tab%';
|
||||
unlock tables;
|
||||
delimiter |;
|
||||
create function foo() returns int
|
||||
begin
|
||||
insert t1 values (5,5);
|
||||
return 5;
|
||||
end|
|
||||
delimiter ;|
|
||||
flush tables;
|
||||
flush status;
|
||||
select foo();
|
||||
show status like '%opened_tab%';
|
||||
drop function foo;
|
||||
drop table t2, t1;
|
||||
|
||||
#
|
||||
# End of 10.1 tests
|
||||
#
|
||||
|
||||
--echo # Start of 10.2 tests
|
||||
|
||||
--echo #
|
||||
@ -326,6 +457,7 @@ INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
|
||||
BEGIN;
|
||||
UPDATE users SET name = 'qux' WHERE id = 1;
|
||||
|
||||
connect (con1,localhost,root);
|
||||
--connection con1
|
||||
SET innodb_lock_wait_timeout= 1;
|
||||
DELETE FROM matchmaking_groups WHERE id = 10;
|
||||
@ -520,6 +652,52 @@ CHECK TABLE t1;
|
||||
DROP TABLE t1;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
||||
|
||||
--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;
|
||||
|
||||
--echo # End of 10.2 tests
|
||||
|
||||
# MDEV-21792 Server aborts upon attempt to create foreign key on spatial field
|
||||
|
77
mysql-test/suite/innodb/t/foreign_key_debug.test
Normal file
77
mysql-test/suite/innodb/t/foreign_key_debug.test
Normal file
@ -0,0 +1,77 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/have_debug_sync.inc
|
||||
|
||||
--enable_connect_log
|
||||
|
||||
#
|
||||
# MDEV-16465 Invalid (old?) table or database name or hang in ha_innobase::delete_table and log semaphore wait upon concurrent DDL with foreign keys
|
||||
#
|
||||
create table t1 (f1 int primary key) engine=innodb;
|
||||
create table t2 (f2 int primary key) engine=innodb;
|
||||
create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb;
|
||||
insert into t1 values (1),(2),(3),(4),(5);
|
||||
insert into t2 values (1),(2),(3),(4),(5);
|
||||
insert into t3 values (1),(2),(3),(4),(5);
|
||||
connect con1,localhost,root;
|
||||
set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2';
|
||||
send alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade;
|
||||
connection default;
|
||||
let $conn=`select connection_id()`;
|
||||
set debug_sync='before_execute_sql_command wait_for g1';
|
||||
send update t1 set f1 = f1 + 100000 limit 2;
|
||||
connect con2,localhost,root;
|
||||
let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock' and info like 'update t1 %';
|
||||
source include/wait_condition.inc;
|
||||
--replace_result $conn UPDATE
|
||||
eval kill query $conn;
|
||||
disconnect con2;
|
||||
connection default;
|
||||
error ER_QUERY_INTERRUPTED;
|
||||
reap;
|
||||
set debug_sync='now signal g2';
|
||||
connection con1;
|
||||
reap;
|
||||
show create table t2;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
select * from t2 where f2 not in (select f1 from t1);
|
||||
select * from t3 where f3 not in (select f2 from t2);
|
||||
drop table t3;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
set debug_sync='reset';
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16060 - InnoDB: Failing assertion: ut_strcmp(index->name, key->name)
|
||||
--echo #
|
||||
CREATE TABLE t1 (`pk` INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
FLUSH TABLES;
|
||||
|
||||
SET debug_sync='alter_table_intermediate_table_created SIGNAL ready WAIT_FOR go';
|
||||
send ALTER TABLE t1 ADD FOREIGN KEY(pk) REFERENCES t2(pk) ON UPDATE CASCADE;
|
||||
|
||||
connect con1, localhost, root;
|
||||
SET debug_sync='now WAIT_FOR ready';
|
||||
SET lock_wait_timeout=0;
|
||||
--error ER_LOCK_WAIT_TIMEOUT
|
||||
UPDATE t2 SET pk=10 WHERE pk=1;
|
||||
PREPARE stmt FROM 'UPDATE t2 SET pk=10 WHERE pk=1';
|
||||
DEALLOCATE PREPARE stmt;
|
||||
SET debug_sync='now SIGNAL go';
|
||||
|
||||
connection default;
|
||||
reap;
|
||||
|
||||
# Cleanup
|
||||
disconnect con1;
|
||||
|
||||
connection default;
|
||||
SET debug_sync='reset';
|
||||
SHOW OPEN TABLES FROM test;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
#
|
||||
# End of 10.1 tests
|
||||
#
|
@ -43,6 +43,7 @@ IF(HAVE_PAM_APPL_H)
|
||||
IF(INSTALL_PAMDIR)
|
||||
INSTALL(TARGETS pam_user_map DESTINATION ${INSTALL_PAMDIR} COMPONENT Server)
|
||||
INSTALL(FILES mapper/user_map.conf DESTINATION ${INSTALL_PAMDATADIR} COMPONENT Server)
|
||||
SET(CPACK_RPM_server_USER_FILELIST ${CPACK_RPM_server_USER_FILELIST} "%config(noreplace) ${INSTALL_PAMDATADIR}/*" PARENT_SCOPE)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(HAVE_PAM_APPL_H)
|
||||
|
@ -1230,7 +1230,7 @@ void Session_tracker::store(THD *thd, String *buf)
|
||||
|
||||
if ((size= net_length_size(length)) != 1)
|
||||
{
|
||||
if (buf->reserve(size - 1, EXTRA_ALLOC))
|
||||
if (buf->reserve(size - 1, 0))
|
||||
{
|
||||
buf->length(start); // it is safer to have 0-length block in case of error
|
||||
return;
|
||||
@ -1240,6 +1240,7 @@ void Session_tracker::store(THD *thd, String *buf)
|
||||
The 'buf->reserve()' can change the buf->ptr() so we cannot
|
||||
calculate the 'data' earlier.
|
||||
*/
|
||||
buf->length(buf->length() + (size - 1));
|
||||
data= (uchar *)(buf->ptr() + start);
|
||||
memmove(data + (size - 1), data, length);
|
||||
}
|
||||
|
@ -4870,10 +4870,19 @@ bool Lock_tables_prelocking_strategy::
|
||||
handle_table(THD *thd, Query_tables_list *prelocking_ctx,
|
||||
TABLE_LIST *table_list, bool *need_prelocking)
|
||||
{
|
||||
TABLE_LIST **last= prelocking_ctx->query_tables_last;
|
||||
|
||||
if (DML_prelocking_strategy::handle_table(thd, prelocking_ctx, table_list,
|
||||
need_prelocking))
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
normally we don't need to open FK-prelocked tables for RESTRICT,
|
||||
MDL is enough. But under LOCK TABLES we have to open everything
|
||||
*/
|
||||
for (TABLE_LIST *tl= *last; tl; tl= tl->next_global)
|
||||
tl->open_strategy= TABLE_LIST::OPEN_NORMAL;
|
||||
|
||||
/* We rely on a caller to check that table is going to be changed. */
|
||||
DBUG_ASSERT(table_list->lock_type >= TL_WRITE_ALLOW_WRITE);
|
||||
|
||||
|
@ -2109,6 +2109,9 @@ struct TABLE_LIST
|
||||
OT_BASE_ONLY);
|
||||
belong_to_view= belong_to_view_arg;
|
||||
trg_event_map= trg_event_map_arg;
|
||||
/* MDL is enough for read-only FK checks, we don't need the table */
|
||||
if (prelocking_type == PRELOCK_FK && lock_type < TL_WRITE_ALLOW_WRITE)
|
||||
open_strategy= OPEN_STUB;
|
||||
|
||||
**last_ptr= this;
|
||||
prev_global= *last_ptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user