Commit 8e764986 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge 10.0-galera into 10.1

parents f9448bcb 7cda4bee
...@@ -138,6 +138,7 @@ INCLUDE(cpack_rpm) ...@@ -138,6 +138,7 @@ INCLUDE(cpack_rpm)
INCLUDE(cpack_deb) INCLUDE(cpack_deb)
# Add macros # Add macros
INCLUDE(wsrep)
INCLUDE(character_sets) INCLUDE(character_sets)
INCLUDE(cpu_info) INCLUDE(cpu_info)
INCLUDE(zlib) INCLUDE(zlib)
...@@ -151,7 +152,6 @@ INCLUDE(ctest) ...@@ -151,7 +152,6 @@ INCLUDE(ctest)
INCLUDE(plugin) INCLUDE(plugin)
INCLUDE(install_macros) INCLUDE(install_macros)
INCLUDE(mysql_add_executable) INCLUDE(mysql_add_executable)
INCLUDE(wsrep)
# Handle options # Handle options
OPTION(DISABLE_SHARED OPTION(DISABLE_SHARED
...@@ -236,6 +236,7 @@ MARK_AS_ADVANCED(WITH_FAST_MUTEXES) ...@@ -236,6 +236,7 @@ MARK_AS_ADVANCED(WITH_FAST_MUTEXES)
OPTION(WITH_INNODB_DISALLOW_WRITES "InnoDB freeze writes patch from Google" ${WITH_WSREP}) OPTION(WITH_INNODB_DISALLOW_WRITES "InnoDB freeze writes patch from Google" ${WITH_WSREP})
IF (WITH_INNODB_DISALLOW_WRITES) IF (WITH_INNODB_DISALLOW_WRITES)
MESSAGE(STATUS "INNODB_DISALLOW_WRITES")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_INNODB_DISALLOW_WRITES") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_INNODB_DISALLOW_WRITES")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_INNODB_DISALLOW_WRITES") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_INNODB_DISALLOW_WRITES")
ENDIF() ENDIF()
......
...@@ -153,8 +153,8 @@ SETA(CPACK_RPM_server_PACKAGE_REQUIRES ...@@ -153,8 +153,8 @@ SETA(CPACK_RPM_server_PACKAGE_REQUIRES
IF(WITH_WSREP) IF(WITH_WSREP)
SETA(CPACK_RPM_server_PACKAGE_REQUIRES SETA(CPACK_RPM_server_PACKAGE_REQUIRES
"galera" "rsync" "lsof" "socat" "grep" "gawk" "iproute" "galera" "rsync" "lsof" "grep" "gawk" "iproute"
"coreutils" "findutils") "coreutils" "findutils" "tar")
ENDIF() ENDIF()
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
......
...@@ -31,11 +31,11 @@ SET(WSREP_PATCH_VERSION "10") ...@@ -31,11 +31,11 @@ SET(WSREP_PATCH_VERSION "10")
# MariaDB addition: Revision number of the last revision merged from # MariaDB addition: Revision number of the last revision merged from
# codership branch visible in @@version_comment. # codership branch visible in @@version_comment.
# Branch : codership-mysql/5.6 # Branch : codership-mysql/5.6
SET(WSREP_PATCH_REVNO "4123") # Should be updated on every merge. SET(WSREP_PATCH_REVNO "4144") # Should be updated on every merge.
# MariaDB addition: Revision number of the last revision merged from # MariaDB addition: Revision number of the last revision merged from
# Branch : lp:maria/maria-10.0-galera # Branch : lp:maria/maria-10.0-galera
SET(WSREP_PATCH_REVNO2 "3867") # Should be updated on every merge. SET(WSREP_PATCH_REVNO2 "3919") # Should be updated on every merge.
# MariaDB: Obtain patch revision number: # MariaDB: Obtain patch revision number:
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set. # Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.
......
...@@ -158,13 +158,13 @@ innodb_flush_method = O_DIRECT ...@@ -158,13 +158,13 @@ innodb_flush_method = O_DIRECT
# Mandatory settings # Mandatory settings
#wsrep_provider= #wsrep_provider=
#wsrep_cluster_address= #wsrep_cluster_address=
#wsrep_slave_threads=1
#binlog_format=row #binlog_format=row
#default_storage_engine=InnoDB #default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2 #innodb_autoinc_lock_mode=2
#bind-address=0.0.0.0 #bind-address=0.0.0.0
# #
# Optional setting # Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0 #innodb_flush_log_at_trx_commit=0
[mysqldump] [mysqldump]
......
...@@ -189,14 +189,14 @@ Description: MariaDB database regression test suite ...@@ -189,14 +189,14 @@ Description: MariaDB database regression test suite
Package: mariadb-server-10.1 Package: mariadb-server-10.1
Architecture: any Architecture: any
Suggests: tinyca, mailx, mariadb-test Suggests: tinyca, mailx, mariadb-test, netcat-openbsd, socat
Recommends: libhtml-template-perl Recommends: libhtml-template-perl
Pre-Depends: mariadb-common, adduser (>= 3.40), debconf Pre-Depends: mariadb-common, adduser (>= 3.40), debconf
Depends: mariadb-client-10.1 (>= ${source:Version}), libdbi-perl, Depends: mariadb-client-10.1 (>= ${source:Version}), libdbi-perl,
perl (>= 5.6), ${shlibs:Depends}, ${misc:Depends}, psmisc, passwd, perl (>= 5.6), ${shlibs:Depends}, ${misc:Depends}, psmisc, passwd,
lsb-base (>= 3.0-10), mariadb-server-core-10.1 (>= ${binary:Version}), lsb-base (>= 3.0-10), mariadb-server-core-10.1 (>= ${binary:Version}),
galera (>=25.2), rsync, lsof, socat | netcat, grep, gawk, iproute, galera (>=25.2), rsync, lsof, grep, gawk, iproute,
coreutils, bsdutils, findutils coreutils, bsdutils, findutils, tar
Provides: mariadb-server, mysql-server, virtual-mysql-server Provides: mariadb-server, mysql-server, virtual-mysql-server
Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}),
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5,
......
...@@ -183,14 +183,14 @@ Description: MariaDB database regression test suite ...@@ -183,14 +183,14 @@ Description: MariaDB database regression test suite
Package: mariadb-server-10.1 Package: mariadb-server-10.1
Architecture: any Architecture: any
Suggests: tinyca, mailx, mariadb-test Suggests: tinyca, mailx, mariadb-test, netcat-openbsd, socat
Recommends: libhtml-template-perl Recommends: libhtml-template-perl
Pre-Depends: mariadb-common, adduser (>= 3.40), debconf Pre-Depends: mariadb-common, adduser (>= 3.40), debconf
Depends: mariadb-client-10.1 (>= ${source:Version}), libdbi-perl, Depends: mariadb-client-10.1 (>= ${source:Version}), libdbi-perl,
perl (>= 5.6), ${shlibs:Depends}, ${misc:Depends}, psmisc, passwd, perl (>= 5.6), ${shlibs:Depends}, ${misc:Depends}, psmisc, passwd,
lsb-base (>= 3.0-10), mariadb-server-core-10.1 (>= ${binary:Version}), lsb-base (>= 3.0-10), mariadb-server-core-10.1 (>= ${binary:Version}),
galera (>=25.2), rsync, lsof, socat | netcat, grep, gawk, iproute, galera (>=25.2), rsync, lsof, grep, gawk, iproute,
coreutils, bsdutils, findutils coreutils, bsdutils, findutils, tar
Provides: mariadb-server, mysql-server, virtual-mysql-server Provides: mariadb-server, mysql-server, virtual-mysql-server
Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}), Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}),
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5,
......
if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE
VARIABLE_NAME LIKE 'wsrep_provider' AND VARIABLE_VALUE NOT LIKE 'none'`)
{
--skip Test requires wsrep provider library (libgalera_smm.so)
}
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
[mysqld]
wsrep-on=1
binlog-format=row
innodb-autoinc-lock-mode=2
default-storage-engine=innodb
wsrep-cluster-address=gcomm://
wsrep-provider=@ENV.WSREP_PROVIDER
# enforce read-committed characteristics across the cluster
wsrep-causal-reads=ON
wsrep-sync-wait=7
[mysqld.1]
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_provider_options='base_port=@mysqld.1.#galera_port'
wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port'
wsrep_node_incoming_address=127.0.0.1
[mysqld.2]
#galera_port=@OPT.port
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
wsrep_provider_options='base_port=@mysqld.2.#galera_port'
wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
[ENV]
NODE_MYPORT_1= @mysqld.1.port
NODE_MYSOCK_1= @mysqld.1.socket
NODE_MYPORT_2= @mysqld.2.port
NODE_MYSOCK_2= @mysqld.2.socket
!include galera_2nodes.cnf
...@@ -27,21 +27,4 @@ c1 ...@@ -27,21 +27,4 @@ c1
4 4
5 5
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-7397: SIGSEGV on inserting into a key-less table
#
# On node_1
USE test;
CREATE TABLE t1(c1 INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
c1
1
# On node_2
SELECT * FROM test.t1;
c1
1
DROP TABLE t1;
# End of test # End of test
#
# MDEV-6924 : Server crashed on CREATE TABLE ... SELECT
#
SET @wsrep_forced_binlog_format_saved=@@GLOBAL.wsrep_forced_binlog_format;
SET @@GLOBAL.wsrep_forced_binlog_format=STATEMENT;
SHOW VARIABLES LIKE '%log%bin%';
Variable_name Value
log_bin OFF
log_bin_trust_function_creators ON
sql_log_bin ON
USE test;
CREATE TABLE t1(i INT) ENGINE=INNODB;
INSERT INTO t1 VALUES(1);
CREATE TEMPORARY TABLE `t1_temp` AS SELECT * FROM `t1` WHERE i = 1;
SELECT * FROM t1;
i
1
SELECT * FROM t1_temp;
i
1
DROP TABLE t1;
SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved;
# End of tests
USE test;
# On node_1
CREATE TABLE networks (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`admin_state_up` tinyint(1) DEFAULT NULL,
`shared` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE ports (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`network_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`mac_address` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`admin_state_up` tinyint(1) NOT NULL,
`status` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
`device_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`device_owner` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `network_id` (`network_id`),
CONSTRAINT `ports_ibfk_1` FOREIGN KEY (`network_id`) REFERENCES networks (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE subnets (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`network_id` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
`ip_version` int(11) NOT NULL,
`cidr` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`gateway_ip` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`enable_dhcp` tinyint(1) DEFAULT NULL,
`shared` tinyint(1) DEFAULT NULL,
`ipv6_ra_mode` enum('slaac','dhcpv6-stateful','dhcpv6-stateless') COLLATE utf8_unicode_ci DEFAULT NULL,
`ipv6_address_mode` enum('slaac','dhcpv6-stateful','dhcpv6-stateless') COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `network_id` (`network_id`),
CONSTRAINT `subnets_ibfk_1` FOREIGN KEY (`network_id`) REFERENCES networks (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `ipallocations` (
`port_id` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
`ip_address` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`subnet_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`network_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`ip_address`,`subnet_id`,`network_id`),
KEY `port_id` (`port_id`),
KEY `subnet_id` (`subnet_id`),
KEY `network_id` (`network_id`),
CONSTRAINT `ipallocations_ibfk_1` FOREIGN KEY (`port_id`) REFERENCES `ports` (`id`) ON DELETE CASCADE,
CONSTRAINT `ipallocations_ibfk_2` FOREIGN KEY (`subnet_id`) REFERENCES `subnets` (`id`) ON DELETE CASCADE,
CONSTRAINT `ipallocations_ibfk_3` FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO networks VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','MyNet','ACTIVE',0,0);
INSERT INTO ports VALUES ('','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','fa:16:3e:e3:cc:bb',1,'DOWN','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','network:router_gateway');
INSERT INTO subnets VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','ext-subnet','f37aa3fe-ab99-4d0f-a566-6cd3169d7516',4,'10.25.0.0/24','10.25.0.4',0,1,NULL,NULL);
INSERT INTO ipallocations VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','10.25.0.17','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','f37aa3fe-ab99-4d0f-a566-6cd3169d7516');
select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 fa:16:3e:e3:cc:bb 1 DOWN f37aa3fe-ab99-4d0f-a566-6cd3169d7516 network:router_gateway
select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 fa:16:3e:e3:cc:bb 1 DOWN f37aa3fe-ab99-4d0f-a566-6cd3169d7516 network:router_gateway
DELETE FROM ports WHERE ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
select * from networks;
tenant_id id name status admin_state_up shared
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 MyNet ACTIVE 0 0
select * from ports;
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
select * from subnets;
tenant_id id name network_id ip_version cidr gateway_ip enable_dhcp shared ipv6_ra_mode ipv6_address_mode
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 ext-subnet f37aa3fe-ab99-4d0f-a566-6cd3169d7516 4 10.25.0.0/24 10.25.0.4 0 1 NULL NULL
select * from ipallocations;
port_id ip_address subnet_id network_id
select * from ports;
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
# On node_2
select * from networks;
tenant_id id name status admin_state_up shared
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 MyNet ACTIVE 0 0
select * from ports;
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
select * from subnets;
tenant_id id name network_id ip_version cidr gateway_ip enable_dhcp shared ipv6_ra_mode ipv6_address_mode
f37aa3fe-ab99-4d0f-a566-6cd3169d7516 f37aa3fe-ab99-4d0f-a566-6cd3169d7516 ext-subnet f37aa3fe-ab99-4d0f-a566-6cd3169d7516 4 10.25.0.0/24 10.25.0.4 0 1 NULL NULL
select * from ipallocations;
port_id ip_address subnet_id network_id
select * from ports;
tenant_id id name network_id mac_address admin_state_up status device_id device_owner
drop table ipallocations;
drop table subnets;
drop table ports;
drop table networks;
CREATE TABLE grandparent (
id INT NOT NULL PRIMARY KEY
) ENGINE=InnoDB;
CREATE TABLE parent (
id INT NOT NULL PRIMARY KEY,
grandparent_id INT,
FOREIGN KEY (grandparent_id)
REFERENCES grandparent(id)
ON DELETE CASCADE
) ENGINE=InnoDB;
CREATE TABLE child (
id INT NOT NULL PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO grandparent VALUES (1),(2);
INSERT INTO parent VALUES (1,1), (2,2);
INSERT INTO child VALUES (1,1), (2,2);
DELETE FROM grandparent WHERE id = 1;
SELECT COUNT(*) = 0 FROM parent WHERE grandparent_id = 1;
COUNT(*) = 0
1
SELECT COUNT(*) = 0 FROM child WHERE parent_id = 1;
COUNT(*) = 0
1
DROP TABLE child;
DROP TABLE parent;
DROP TABLE grandparent;
CREATE TABLE grandparent (
id INT NOT NULL PRIMARY KEY
) ENGINE=InnoDB;
CREATE TABLE parent (
id INT NOT NULL PRIMARY KEY,
grandparent_id INT,
FOREIGN KEY (grandparent_id)
REFERENCES grandparent(id)
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE child (
id INT NOT NULL PRIMARY KEY,
grandparent_id INT,
FOREIGN KEY (grandparent_id)
REFERENCES parent(grandparent_id)
ON UPDATE CASCADE
) ENGINE=InnoDB;
INSERT INTO grandparent VALUES (1),(2);
INSERT INTO parent VALUES (1,1), (2,2);
INSERT INTO child VALUES (1,1), (2,2);
UPDATE grandparent SET id = 3 WHERE id = 1;
SELECT COUNT(*) = 1 FROM parent WHERE grandparent_id = 3;
COUNT(*) = 1
1
SELECT COUNT(*) = 1 FROM child WHERE grandparent_id = 3;
COUNT(*) = 1
1
DROP TABLE child;
DROP TABLE parent;
DROP TABLE grandparent;
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1), (2);
INSERT INTO child VALUES (1,1);
SET AUTOCOMMIT = OFF;
START TRANSACTION;
DELETE FROM parent WHERE id = 2;
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO child VALUES (2, 2);
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE parent (
id1 INT,
id2 INT,
PRIMARY KEY (id1, id2) /* Multipart PK */
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id1 INT,
FOREIGN KEY (parent_id1)
REFERENCES parent(id1) /* FK is subset of PK above */
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1, 2);
INSERT INTO child VALUES (1, 1);
UPDATE parent SET id1 = 3 WHERE id1 = 1;
SELECT COUNT(*) = 1 FROM child WHERE parent_id1 = 3;
COUNT(*) = 1
1
DELETE FROM parent WHERE id1 = 3;
SELECT COUNT(*) = 0 FROM child WHERE parent_id1 = 3;
COUNT(*) = 0
1
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE t0 (
f1 INT PRIMARY KEY,
f2 INT UNIQUE
) ENGINE=INNODB;
CREATE TABLE t1 (
f1 INT PRIMARY KEY,
FOREIGN KEY (f1)
REFERENCES t0(f1)
ON UPDATE CASCADE
) ENGINE=INNODB;
CREATE TABLE t2 (
f2 INT PRIMARY KEY,
FOREIGN KEY (f2)
REFERENCES t0(f2)
ON UPDATE CASCADE
) ENGINE=INNODB;
INSERT INTO t0 VALUES (0, 0);
INSERT INTO t1 VALUES (0);
INSERT INTO t2 VALUES (0);
UPDATE t0 SET f1 = 1, f2 = 2;
SELECT f1 = 1 FROM t1 WHERE f1 = 1;
f1 = 1
1
SELECT f2 = 2 FROM t2 WHERE f2 = 2;
f2 = 2
1
SELECT f1 = 1 FROM t1;
f1 = 1
1
SELECT f2 = 2 FROM t2;
f2 = 2
1
DROP TABLE t2;
DROP TABLE t1;
DROP TABLE t0;
CREATE TABLE t0 (
f0 INT PRIMARY KEY
) ENGINE=INNODB;
CREATE TABLE t1 (
f1 INT PRIMARY KEY,
f0 INTEGER,
FOREIGN KEY (f0)
REFERENCES t0(f0)
ON DELETE CASCADE
) ENGINE=INNODB;
INSERT INTO t0 VALUES (0), (1);
INSERT INTO t1 VALUES (0, 0);
INSERT INTO t1 VALUES (1, 0);
DELETE t0.*, t1.* FROM t0, t1 WHERE t0.f0 = 0 AND t1.f1 = 0;
SELECT COUNT(*) = 1 FROM t0;
COUNT(*) = 1
1
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
DROP TABLE t1;
DROP TABLE t0;
CREATE TABLE parent (
id INT,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1), (1), (2), (2);
INSERT INTO child VALUES (1,1), (2,2), (1,1), (2,2);
DELETE FROM parent WHERE id = 1;
SELECT COUNT(*) = 0 FROM child WHERE id = 1;
COUNT(*) = 0
1
UPDATE parent SET id = 3 WHERE id = 2;
SELECT COUNT(*) = 0 FROM child WHERE parent_id = 1;
COUNT(*) = 0
1
SELECT parent_id = 3 FROM child WHERE id = 2;
parent_id = 3
1
1
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE t1 (
f1 INT NOT NULL PRIMARY KEY,
f2 INT,
FOREIGN KEY (f2)
REFERENCES t1(f1)
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1), (2, 1);
DELETE FROM t1 WHERE f1 = 1;
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
DROP TABLE t1;
CREATE TABLE parent (
id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON UPDATE SET NULL
ON DELETE SET NULL
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1),(2);
INSERT INTO child VALUES (1,1),(2,2);
DELETE FROM parent WHERE id = 1;
SELECT parent_id IS NULL FROM child WHERE id = 1;
parent_id IS NULL
1
SELECT parent_id IS NULL FROM child WHERE id = 1;
parent_id IS NULL
1
UPDATE parent SET id = 3 WHERE id = 2;
SELECT parent_id IS NULL FROM child WHERE id = 2;
parent_id IS NULL
1
SELECT parent_id IS NULL FROM child WHERE id = 2;
parent_id IS NULL
1
DROP TABLE child;
DROP TABLE parent;
This diff is collapsed.
CREATE TABLE t1 (f1 VARCHAR(767) PRIMARY KEY) ENGINE=InnoDB;
CREATE UNIQUE INDEX i63 ON t1(f1);
CREATE UNIQUE INDEX i62 ON t1(f1);
CREATE UNIQUE INDEX i61 ON t1(f1);
CREATE UNIQUE INDEX i60 ON t1(f1);
CREATE UNIQUE INDEX i59 ON t1(f1);
CREATE UNIQUE INDEX i58 ON t1(f1);
CREATE UNIQUE INDEX i57 ON t1(f1);
CREATE UNIQUE INDEX i56 ON t1(f1);
CREATE UNIQUE INDEX i55 ON t1(f1);
CREATE UNIQUE INDEX i54 ON t1(f1);
CREATE UNIQUE INDEX i53 ON t1(f1);
CREATE UNIQUE INDEX i52 ON t1(f1);
CREATE UNIQUE INDEX i51 ON t1(f1);
CREATE UNIQUE INDEX i50 ON t1(f1);
CREATE UNIQUE INDEX i49 ON t1(f1);
CREATE UNIQUE INDEX i48 ON t1(f1);
CREATE UNIQUE INDEX i47 ON t1(f1);
CREATE UNIQUE INDEX i46 ON t1(f1);
CREATE UNIQUE INDEX i45 ON t1(f1);
CREATE UNIQUE INDEX i44 ON t1(f1);
CREATE UNIQUE INDEX i43 ON t1(f1);
CREATE UNIQUE INDEX i42 ON t1(f1);
CREATE UNIQUE INDEX i41 ON t1(f1);
CREATE UNIQUE INDEX i40 ON t1(f1);
CREATE UNIQUE INDEX i39 ON t1(f1);
CREATE UNIQUE INDEX i38 ON t1(f1);
CREATE UNIQUE INDEX i37 ON t1(f1);
CREATE UNIQUE INDEX i36 ON t1(f1);
CREATE UNIQUE INDEX i35 ON t1(f1);
CREATE UNIQUE INDEX i34 ON t1(f1);
CREATE UNIQUE INDEX i33 ON t1(f1);
CREATE UNIQUE INDEX i32 ON t1(f1);
CREATE UNIQUE INDEX i31 ON t1(f1);
CREATE UNIQUE INDEX i30 ON t1(f1);
CREATE UNIQUE INDEX i29 ON t1(f1);
CREATE UNIQUE INDEX i28 ON t1(f1);
CREATE UNIQUE INDEX i27 ON t1(f1);
CREATE UNIQUE INDEX i26 ON t1(f1);
CREATE UNIQUE INDEX i25 ON t1(f1);
CREATE UNIQUE INDEX i24 ON t1(f1);
CREATE UNIQUE INDEX i23 ON t1(f1);
CREATE UNIQUE INDEX i22 ON t1(f1);
CREATE UNIQUE INDEX i21 ON t1(f1);
CREATE UNIQUE INDEX i20 ON t1(f1);
CREATE UNIQUE INDEX i19 ON t1(f1);
CREATE UNIQUE INDEX i18 ON t1(f1);
CREATE UNIQUE INDEX i17 ON t1(f1);
CREATE UNIQUE INDEX i16 ON t1(f1);
CREATE UNIQUE INDEX i15 ON t1(f1);
CREATE UNIQUE INDEX i14 ON t1(f1);
CREATE UNIQUE INDEX i13 ON t1(f1);
CREATE UNIQUE INDEX i12 ON t1(f1);
CREATE UNIQUE INDEX i11 ON t1(f1);
CREATE UNIQUE INDEX i10 ON t1(f1);
CREATE UNIQUE INDEX i9 ON t1(f1);
CREATE UNIQUE INDEX i8 ON t1(f1);
CREATE UNIQUE INDEX i7 ON t1(f1);
CREATE UNIQUE INDEX i6 ON t1(f1);
CREATE UNIQUE INDEX i5 ON t1(f1);
CREATE UNIQUE INDEX i4 ON t1(f1);
CREATE UNIQUE INDEX i3 ON t1(f1);
CREATE UNIQUE INDEX i2 ON t1(f1);
CREATE UNIQUE INDEX i1 ON t1(f1);
INSERT INTO t1 VALUES (REPEAT('a', 767));
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
SELECT LENGTH(f1) = 767 FROM t1;
LENGTH(f1) = 767
1
EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (PRIMARY) WHERE f1 = REPEAT('a', 767);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 769 const 1 Using index
SELECT COUNT(*) = 1 FROM t1 FORCE KEY (PRIMARY) WHERE f1 = REPEAT('a', 767);
COUNT(*) = 1
1
EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i1) WHERE f1 = REPEAT('a', 767);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const i1 i1 769 const 1 Using index
SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i1) WHERE f1 = REPEAT('a', 767);
COUNT(*) = 1
1
EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i63) WHERE f1 = REPEAT('a', 767);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const i63 i63 769 const 1 Using index
SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i63) WHERE f1 = REPEAT('a', 767);
COUNT(*) = 1
1
INSERT INTO t1 VALUES (REPEAT('b', 767));
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
SELECT COUNT(*) = 2 FROM t1;
COUNT(*) = 2
1
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
DELETE FROM t1 WHERE f1 = REPEAT('b', 767);
SET AUTOCOMMIT=OFF;
START TRANSACTION;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
INSERT INTO t1 (f1) VALUES (REPEAT('c', 767));
ROLLBACK;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
START TRANSACTION;
SET AUTOCOMMIT=OFF;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
START TRANSACTION;
START TRANSACTION;
UPDATE t1 SET f1 = REPEAT('e', 767);
UPDATE t1 SET f1 = REPEAT('f', 767);
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE t1;
CREATE TABLE ten (f1 INTEGER) ENGINE=INNODB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
SELECT COUNT(*) = 100000 FROM t1;
COUNT(*) = 100000
1
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
1
UPDATE t1 SET f2 = 1;
SELECT COUNT(*) = 200000 FROM t1 WHERE f2 = 1;
COUNT(*) = 200000
1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
ROLLBACK;
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
1
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t1 SET f2 = 2;
ROLLBACK;
START TRANSACTION;
SELECT COUNT(*) = 200000 FROM t1;
COUNT(*) = 200000
1
UPDATE t1 SET f2 = 3;
START TRANSACTION;
UPDATE t1 SET f2 = 4;
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE t1;
DROP TABLE ten;
CREATE TABLE t1 (f1 BIT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),(0),(b'1');
SELECT f1 IS NULL, f1 = b'1' FROM t1;
f1 IS NULL f1 = b'1'
1 NULL
0 0
0 1
DELETE FROM t1 WHERE f1 = b'1';
UPDATE t1 SET f1 = b'1' WHERE f1 IS NULL;
UPDATE t1 SET f1 = 1 WHERE f1 = b'0';
SELECT f1 IS NULL, f1 = b'1' FROM t1;
f1 IS NULL f1 = b'1'
0 1
0 1
CREATE TABLE t2 (f1 BIT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (NULL);
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 0 WHERE f1 IS NULL;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 1 WHERE f1 IS NULL;
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1 (f1 BLOB) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),('abc');
SELECT f1 FROM t1;
f1
NULL
abc
DELETE FROM t1 WHERE f1 IS NULL;
UPDATE t1 SET f1 = 'xyz' WHERE f1 = 'abc';
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
SELECT f1 = 'abc' FROM t1;
f1 = 'abc'
0
CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB;
INSERT INTO t2 VALUES (NULL);
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'abc' WHERE f1 IS NULL;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'xyz' WHERE f1 IS NULL;
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1 (f1 VARCHAR(8000)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),(CONCAT(REPEAT('x', 7999), 'a'));
SELECT LENGTH(f1) FROM t1;
LENGTH(f1)
NULL
8000
DELETE FROM t1 WHERE f1 IS NULL;
UPDATE t1 SET f1 = CONCAT(REPEAT('x', 7999), 'b') WHERE f1 = CONCAT(REPEAT('x', 7999), 'a');
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
SELECT LENGTH(f1) = 8000 FROM t1;
LENGTH(f1) = 8000
1
SELECT f1 = CONCAT(REPEAT('x', 7999), 'b') FROM t1;
f1 = CONCAT(REPEAT('x', 7999), 'b')
1
CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB;
INSERT INTO t2 VALUES (CONCAT(REPEAT('x', 7999), 'a'));
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'abc' WHERE f1 = CONCAT(REPEAT('x', 7999), 'a');
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'xyz' WHERE f1 = CONCAT(REPEAT('x', 7999), 'a');
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE t1;
DROP TABLE t2;
SET GLOBAL wsrep_sync_wait = 7;
SET GLOBAL wsrep_sync_wait = 7;
CREATE DATABASE `database with space`;
USE `database with space`;
CREATE TABLE `table with space` (
`column with space` INTEGER AUTO_INCREMENT PRIMARY KEY,
`second column with space` INTEGER,
UNIQUE `index name with space` (`second column with space`)
) ENGINE=INNODB;
INSERT INTO `table with space` VALUES (DEFAULT, 1);
CREATE DATABASE `база`;
USE `база`;
CREATE TABLE `таблица` (
`първа_колона` INTEGER PRIMARY KEY,
`втора_колона` INTEGER,
UNIQUE `индекс` (`втора_колона`)
) ENGINE=INNODB;
INSERT INTO `таблица` VALUES (1, 1);
CREATE DATABASE `втора база`;
USE `втора база`;
CREATE TABLE `втора таблица` (
`първа колона` INTEGER,
`втора колона` INTEGER,
KEY `първи индекс` (`първа колона`)
) ENGINE=INNODB;
INSERT INTO `втора таблица` VALUES (1, 1);
USE `database with space`;
SELECT * FROM `table with space`;
column with space second column with space
1 1
USE `база`;
SELECT * FROM `таблица`;
първа_колона втора_колона
1 1
USE `втора база`;
SELECT * FROM `втора таблица`;
първа колона втора колона
1 1
SET GLOBAL wsrep_sync_wait = (SELECT @@wsrep_sync_wait);
DROP TABLE `database with space`.`table with space`;
DROP TABLE `база`.`таблица`;
DROP TABLE `втора база`.`втора таблица`;
DROP DATABASE `database with space`;
DROP DATABASE `база`;
DROP DATABASE `втора база`;
SET GLOBAL wsrep_sync_wait = (SELECT @@wsrep_sync_wait);
SET GLOBAL wsrep_auto_increment_control = OFF;
SET GLOBAL auto_increment_increment = 1;
SET GLOBAL auto_increment_offset = 1;
SET GLOBAL wsrep_auto_increment_control = OFF;
SET GLOBAL auto_increment_increment = 1;
SET GLOBAL auto_increment_offset = 1;
SELECT @@auto_increment_increment = 1;
@@auto_increment_increment = 1
1
SELECT @@auto_increment_offset = 1;
@@auto_increment_offset = 1
1
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL AUTO_INCREMENT,
`node` varchar(10) DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL AUTO_INCREMENT,
`node` varchar(10) DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT @@auto_increment_increment = 1;
@@auto_increment_increment = 1
1
SELECT @@auto_increment_offset = 1;
@@auto_increment_offset = 1
1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 (node) VALUES ('node1');
SELECT f1 FROM t1;
f1
1
SELECT @@auto_increment_increment = 1;
@@auto_increment_increment = 1
1
SELECT @@auto_increment_offset = 1;
@@auto_increment_offset = 1
1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 (node) VALUES ('node2');
SELECT f1 FROM t1;
f1
1
COMMIT;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
SELECT * FROM t1;
f1 node
1 node1
SELECT * FROM t1;
f1 node
1 node1
SET GLOBAL wsrep_auto_increment_control = 1;
SET GLOBAL auto_increment_increment = 2;
SET GLOBAL auto_increment_offset = 1;
SET GLOBAL wsrep_auto_increment_control = 1;
SET GLOBAL auto_increment_increment = 2;
SET GLOBAL auto_increment_offset = 2;
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL AUTO_INCREMENT,
`node` varchar(10) DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size');
@@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size')
1
SELECT @@auto_increment_offset = 1;
@@auto_increment_offset = 1
1
INSERT INTO t1 VALUES (DEFAULT, 'node1');;
INSERT INTO t1 VALUES (DEFAULT, 'node2');;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL AUTO_INCREMENT,
`node` varchar(10) DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size');
@@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size')
1
SELECT @@auto_increment_offset = 2;
@@auto_increment_offset = 2
1
INSERT INTO t1 VALUES (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2');;
INSERT INTO t1 VALUES (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1');;
SELECT COUNT(*) = 22 FROM t1;
COUNT(*) = 22
1
SELECT COUNT(DISTINCT f1) = 22 FROM t1;
COUNT(DISTINCT f1) = 22
1
SELECT COUNT(*) = 22 FROM t1;
COUNT(*) = 22
1
SELECT COUNT(DISTINCT f1) = 22 FROM t1;
COUNT(DISTINCT f1) = 22
1
DROP TABLE t1;
SET GLOBAL wsrep_certify_nonPK = OFF;
SET GLOBAL wsrep_certify_nonPK = OFF;
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB /* Table has no primary key */;
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
INSERT INTO t2 VALUES (1), (2);
UPDATE t2 SET f1 = 3 WHERE f1 = 1;
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
SELECT COUNT(*) = 2 FROM t2;
COUNT(*) = 2
1
SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 3;
COUNT(*) = 1
1
SET GLOBAL wsrep_certify_nonPK = 1;
SET GLOBAL wsrep_certify_nonPK = 1;
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1);
INSERT INTO child VALUES (1,1);
SET SESSION foreign_key_checks = 0;
INSERT INTO child VALUES (2,2);
SELECT COUNT(*) = 1 FROM child WHERE id = 2;
COUNT(*) = 1
1
INSERT INTO child VALUES (3,3);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`))
SET SESSION foreign_key_checks = 0;
DELETE FROM parent;
SELECT COUNT(*) = 0 FROM parent;
COUNT(*) = 0
1
DROP TABLE child;
DROP TABLE parent;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB;
SET GLOBAL wsrep_mysql_replication_bundle = 2;
INSERT INTO t1 VALUES (1);
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
0
INSERT INTO t1 VALUES (2);
SELECT COUNT(*) = 2 FROM t1;
COUNT(*) = 2
1
SET GLOBAL wsrep_mysql_replication_bundle = 0;
DROP TABLE t1;
SET GLOBAL wsrep_replicate_myisam = FALSE;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM;
INSERT INTO t1 VALUES (1);
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
SET GLOBAL wsrep_replicate_myisam = 0;
DROP TABLE t1;
SET GLOBAL wsrep_replicate_myisam = TRUE;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM;
INSERT INTO t1 VALUES (1);
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
SET GLOBAL wsrep_replicate_myisam = 0;
DROP TABLE t1;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB;
SET GLOBAL wsrep_sync_wait = 1;
SHOW TABLES LIKE '%t1';
Tables_in_test (%t1)
t1
SELECT COUNT(*) = 0 FROM t1;
COUNT(*) = 0
1
CREATE TABLE t2 (f1 INT PRIMARY KEY) Engine=InnoDB;
SET GLOBAL wsrep_sync_wait = 4;
INSERT INTO t2 VALUES (1);
CREATE TABLE t3 (f1 INT PRIMARY KEY) Engine=InnoDB;
INSERT INTO t3 VALUES (1);
SET GLOBAL wsrep_sync_wait = 2;
UPDATE t3 SET f1 = 2;
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
SET GLOBAL wsrep_sync_wait = 7;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
This diff is collapsed.
package My::Suite::GALERA;
use File::Basename;
use My::Find;
@ISA = qw(My::Suite);
return "Not run for embedded server" if $::opt_embedded_server;
return "WSREP is not compiled in" unless defined $::mysqld_variables{'wsrep-on'};
my ($provider) = grep { -f $_ } $ENV{WSREP_PROVIDER},
"/usr/lib/galera/libgalera_smm.so",
"/usr/lib64/galera/libgalera_smm.so";
return "No wsrep provider library" unless -f $provider;
$ENV{WSREP_PROVIDER} = $provider;
my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir;
return "No SST scripts" unless $spath;
my ($epath) = grep { -f "$_/my_print_defaults"; } "$::bindir/extra", $::path_client_bindir;
return "No my_print_defaults" unless $epath;
push @::global_suppressions,
(
qr(WSREP: Failed to guess base node address),
qr(WSREP: Guessing address for incoming client connections failed),
qr(WSREP: wsrep_sst_receive_address is set to '127.0.0.1),
qr(WSREP: Could not open saved state file for reading: ),
qr(WSREP: Gap in state sequence. Need state transfer.),
qr(WSREP: Failed to prepare for incremental state transfer:),
qr(WSREP:.*down context.*),
qr(WSREP: Failed to send state UUID:),
qr(WSREP: last inactive check more than .* skipping check),
qr(WSREP: SQL statement was ineffective),
qr(WSREP: Releasing seqno [0-9]* before [0-9]* was assigned.),
);
$ENV{PATH}="$epath:$ENV{PATH}";
$ENV{PATH}="$spath:$ENV{PATH}" unless $epath eq $spath;
bless { };
...@@ -22,27 +22,5 @@ SELECT * FROM test.t1; ...@@ -22,27 +22,5 @@ SELECT * FROM test.t1;
# Cleanup # Cleanup
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-7397: SIGSEGV on inserting into a key-less table
--echo #
--echo
--echo # On node_1
--connection node_1
USE test;
CREATE TABLE t1(c1 INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
--echo
--echo # On node_2
--connection node_2
SELECT * FROM test.t1;
--let $galera_diff_statement = SELECT * FROM t1
--source include/galera_diff.inc
# Cleanup
DROP TABLE t1;
--source include/galera_end.inc --source include/galera_end.inc
--echo # End of test --echo # End of test
--source include/galera_cluster.inc
--source include/have_innodb.inc
--echo #
--echo # MDEV-6924 : Server crashed on CREATE TABLE ... SELECT
--echo #
SET @wsrep_forced_binlog_format_saved=@@GLOBAL.wsrep_forced_binlog_format;
SET @@GLOBAL.wsrep_forced_binlog_format=STATEMENT;
# @@log_bin must be OFF
SHOW VARIABLES LIKE '%log%bin%';
USE test;
CREATE TABLE t1(i INT) ENGINE=INNODB;
INSERT INTO t1 VALUES(1);
CREATE TEMPORARY TABLE `t1_temp` AS SELECT * FROM `t1` WHERE i = 1;
SELECT * FROM t1;
SELECT * FROM t1_temp;
# Cleanup
DROP TABLE t1;
SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved;
--echo # End of tests
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# MDEV-6651: MariaDB galera cluster crashes in file row0mysql.cc line 684
# DELETE FROM ports WHERE ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516'
# where table ports have foreign keys
#
USE test;
--echo
--echo # On node_1
--connection node_1
CREATE TABLE networks (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`admin_state_up` tinyint(1) DEFAULT NULL,
`shared` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE ports (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`network_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`mac_address` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`admin_state_up` tinyint(1) NOT NULL,
`status` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
`device_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`device_owner` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `network_id` (`network_id`),
CONSTRAINT `ports_ibfk_1` FOREIGN KEY (`network_id`) REFERENCES networks (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE subnets (
`tenant_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`network_id` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
`ip_version` int(11) NOT NULL,
`cidr` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`gateway_ip` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`enable_dhcp` tinyint(1) DEFAULT NULL,
`shared` tinyint(1) DEFAULT NULL,
`ipv6_ra_mode` enum('slaac','dhcpv6-stateful','dhcpv6-stateless') COLLATE utf8_unicode_ci DEFAULT NULL,
`ipv6_address_mode` enum('slaac','dhcpv6-stateful','dhcpv6-stateless') COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `network_id` (`network_id`),
CONSTRAINT `subnets_ibfk_1` FOREIGN KEY (`network_id`) REFERENCES networks (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `ipallocations` (
`port_id` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
`ip_address` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`subnet_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
`network_id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`ip_address`,`subnet_id`,`network_id`),
KEY `port_id` (`port_id`),
KEY `subnet_id` (`subnet_id`),
KEY `network_id` (`network_id`),
CONSTRAINT `ipallocations_ibfk_1` FOREIGN KEY (`port_id`) REFERENCES `ports` (`id`) ON DELETE CASCADE,
CONSTRAINT `ipallocations_ibfk_2` FOREIGN KEY (`subnet_id`) REFERENCES `subnets` (`id`) ON DELETE CASCADE,
CONSTRAINT `ipallocations_ibfk_3` FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO networks VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','MyNet','ACTIVE',0,0);
INSERT INTO ports VALUES ('','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','fa:16:3e:e3:cc:bb',1,'DOWN','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','network:router_gateway');
INSERT INTO subnets VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','ext-subnet','f37aa3fe-ab99-4d0f-a566-6cd3169d7516',4,'10.25.0.0/24','10.25.0.4',0,1,NULL,NULL);
INSERT INTO ipallocations VALUES ('f37aa3fe-ab99-4d0f-a566-6cd3169d7516','10.25.0.17','f37aa3fe-ab99-4d0f-a566-6cd3169d7516','f37aa3fe-ab99-4d0f-a566-6cd3169d7516');
select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
--connection node_2
select * from ports where ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
--let $galera_diff_statement = SELECT * FROM ports
--source include/galera_diff.inc
--connection node_1
DELETE FROM ports WHERE ports.id = 'f37aa3fe-ab99-4d0f-a566-6cd3169d7516';
select * from networks;
select * from ports;
select * from subnets;
select * from ipallocations;
select * from ports;
--echo
--echo # On node_2
--connection node_2
select * from networks;
select * from ports;
select * from subnets;
select * from ipallocations;
select * from ports;
--let $galera_diff_statement = SELECT * FROM ports
--source include/galera_diff.inc
--connection node_1
drop table ipallocations;
drop table subnets;
drop table ports;
drop table networks;
--source include/galera_end.inc
#
# Test Foreign Key Cascading DELETEs
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE grandparent (
id INT NOT NULL PRIMARY KEY
) ENGINE=InnoDB;
CREATE TABLE parent (
id INT NOT NULL PRIMARY KEY,
grandparent_id INT,
FOREIGN KEY (grandparent_id)
REFERENCES grandparent(id)
ON DELETE CASCADE
) ENGINE=InnoDB;
CREATE TABLE child (
id INT NOT NULL PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO grandparent VALUES (1),(2);
INSERT INTO parent VALUES (1,1), (2,2);
INSERT INTO child VALUES (1,1), (2,2);
--connection node_2
DELETE FROM grandparent WHERE id = 1;
--connection node_1
SELECT COUNT(*) = 0 FROM parent WHERE grandparent_id = 1;
SELECT COUNT(*) = 0 FROM child WHERE parent_id = 1;
DROP TABLE child;
DROP TABLE parent;
DROP TABLE grandparent;
#
# Test Foreign Key Cascading UPDATEs
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE grandparent (
id INT NOT NULL PRIMARY KEY
) ENGINE=InnoDB;
CREATE TABLE parent (
id INT NOT NULL PRIMARY KEY,
grandparent_id INT,
FOREIGN KEY (grandparent_id)
REFERENCES grandparent(id)
ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE child (
id INT NOT NULL PRIMARY KEY,
grandparent_id INT,
FOREIGN KEY (grandparent_id)
REFERENCES parent(grandparent_id)
ON UPDATE CASCADE
) ENGINE=InnoDB;
INSERT INTO grandparent VALUES (1),(2);
INSERT INTO parent VALUES (1,1), (2,2);
INSERT INTO child VALUES (1,1), (2,2);
--connection node_2
UPDATE grandparent SET id = 3 WHERE id = 1;
--connection node_1
SELECT COUNT(*) = 1 FROM parent WHERE grandparent_id = 3;
SELECT COUNT(*) = 1 FROM child WHERE grandparent_id = 3;
DROP TABLE child;
DROP TABLE parent;
DROP TABLE grandparent;
#
# Test two transactions on separate nodes which conflict on a FK
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1), (2);
INSERT INTO child VALUES (1,1);
--connection node_1
SET AUTOCOMMIT = OFF;
START TRANSACTION;
DELETE FROM parent WHERE id = 2;
--connection node_2
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO child VALUES (2, 2);
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE child;
DROP TABLE parent;
#
# Test the operation where the definition of the FK is different from the one of the underlying key
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE parent (
id1 INT,
id2 INT,
PRIMARY KEY (id1, id2) /* Multipart PK */
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id1 INT,
FOREIGN KEY (parent_id1)
REFERENCES parent(id1) /* FK is subset of PK above */
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1, 2);
INSERT INTO child VALUES (1, 1);
--connection node_2
UPDATE parent SET id1 = 3 WHERE id1 = 1;
--connection node_1
SELECT COUNT(*) = 1 FROM child WHERE parent_id1 = 3;
DELETE FROM parent WHERE id1 = 3;
--connection node_2
SELECT COUNT(*) = 0 FROM child WHERE parent_id1 = 3;
DROP TABLE child;
DROP TABLE parent;
#
# Test UPDATE on multiple columns with multiple FKs
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t0 (
f1 INT PRIMARY KEY,
f2 INT UNIQUE
) ENGINE=INNODB;
CREATE TABLE t1 (
f1 INT PRIMARY KEY,
FOREIGN KEY (f1)
REFERENCES t0(f1)
ON UPDATE CASCADE
) ENGINE=INNODB;
CREATE TABLE t2 (
f2 INT PRIMARY KEY,
FOREIGN KEY (f2)
REFERENCES t0(f2)
ON UPDATE CASCADE
) ENGINE=INNODB;
INSERT INTO t0 VALUES (0, 0);
INSERT INTO t1 VALUES (0);
INSERT INTO t2 VALUES (0);
--connection node_2
UPDATE t0 SET f1 = 1, f2 = 2;
--connection node_1
SELECT f1 = 1 FROM t1 WHERE f1 = 1;
SELECT f2 = 2 FROM t2 WHERE f2 = 2;
SELECT f1 = 1 FROM t1;
SELECT f2 = 2 FROM t2;
DROP TABLE t2;
DROP TABLE t1;
DROP TABLE t0;
#
# Test multi-table DELETE in the presence of FKs
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t0 (
f0 INT PRIMARY KEY
) ENGINE=INNODB;
CREATE TABLE t1 (
f1 INT PRIMARY KEY,
f0 INTEGER,
FOREIGN KEY (f0)
REFERENCES t0(f0)
ON DELETE CASCADE
) ENGINE=INNODB;
INSERT INTO t0 VALUES (0), (1);
INSERT INTO t1 VALUES (0, 0);
INSERT INTO t1 VALUES (1, 0);
--connection node_2
DELETE t0.*, t1.* FROM t0, t1 WHERE t0.f0 = 0 AND t1.f1 = 0;
--connection node_1
SELECT COUNT(*) = 1 FROM t0;
SELECT COUNT(*) = 0 FROM t1;
DROP TABLE t1;
DROP TABLE t0;
#
# Test foreign keys if no PK is present
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE parent (
id INT,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1), (1), (2), (2);
INSERT INTO child VALUES (1,1), (2,2), (1,1), (2,2);
--connection node_2
DELETE FROM parent WHERE id = 1;
SELECT COUNT(*) = 0 FROM child WHERE id = 1;
--connection node_1
UPDATE parent SET id = 3 WHERE id = 2;
--connection node_2
SELECT COUNT(*) = 0 FROM child WHERE parent_id = 1;
SELECT parent_id = 3 FROM child WHERE id = 2;
DROP TABLE child;
DROP TABLE parent;
#
# Test self-referential foreign keys
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (
f1 INT NOT NULL PRIMARY KEY,
f2 INT,
FOREIGN KEY (f2)
REFERENCES t1(f1)
ON DELETE CASCADE
) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1), (2, 1);
--connection node_2
DELETE FROM t1 WHERE f1 = 1;
--connection node_1
SELECT COUNT(*) = 0 FROM t1;
DROP TABLE t1;
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE parent (
id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
ON UPDATE SET NULL
ON DELETE SET NULL
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1),(2);
INSERT INTO child VALUES (1,1),(2,2);
--connection node_2
DELETE FROM parent WHERE id = 1;
SELECT parent_id IS NULL FROM child WHERE id = 1;
--connection node_1
SELECT parent_id IS NULL FROM child WHERE id = 1;
UPDATE parent SET id = 3 WHERE id = 2;
SELECT parent_id IS NULL FROM child WHERE id = 2;
--connection node_2
SELECT parent_id IS NULL FROM child WHERE id = 2;
--connection node_1
DROP TABLE child;
DROP TABLE parent;
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (f1017 VARCHAR(3) DEFAULT 'ABC') ENGINE=InnoDB;
--let $count = 1016
while ($count)
{
--disable_query_log
--eval SET @ddl_var1 = CONCAT("ALTER TABLE t1 ADD COLUMN f", $count, " VARCHAR(3) DEFAULT 'ABC'")
--let $ddl_var = `SELECT @ddl_var1`
--enable_query_log
--eval $ddl_var
--dec $count
}
ALTER TABLE t1 ADD PRIMARY KEY (f1, f1017);
INSERT INTO t1 (f1) VALUES (DEFAULT);
--connection node_2
SELECT f1 = 'ABC', f1017 = 'ABC' FROM t1;
UPDATE t1 SET f1 = 'XYZ', f1017 = 'XYZ' ;
--connection node_1
SELECT f1 = 'XYZ', f1017 = 'XYZ' FROM t1 WHERE f1 = 'XYZ' AND f1017 = 'XYZ';
# Deadlock
--connection node_1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t1 SET f2 = 'KLM' WHERE f1 = 'XYZ' AND f1017 = 'XYZ';
--connection node_2
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t1 SET f2 = 'CDE' WHERE f1 = 'XYZ' AND f1017 = 'XYZ';
COMMIT;
--connection node_1
--error ER_LOCK_DEADLOCK
COMMIT;
ROLLBACK;
--connection node_2
ROLLBACK;
# Rollback
--connection node_1
START TRANSACTION;
INSERT INTO t1 (f1, f1017) VALUES ('BCE','BCE');
INSERT INTO t1 (f1, f1017) VALUES ('CED','CED');
INSERT INTO t1 (f1, f1017) VALUES ('EDF','EDF');
INSERT INTO t1 (f1, f1017) VALUES ('FED','FED');
ROLLBACK;
SELECT COUNT(*) = 1 FROM t1;
--connection node_2
SELECT COUNT(*) = 1 FROM t1;
DROP TABLE t1;
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (f1 VARCHAR(767) PRIMARY KEY) ENGINE=InnoDB;
# MySQL complains about multiple identical indexes on the same column
--disable_warnings
--let $count = 63
while ($count)
{
--disable_query_log
--eval SET @ddl_var1 = CONCAT("CREATE UNIQUE INDEX i", $count, " ON t1(f1)")
--let $ddl_var = `SELECT @ddl_var1`
--enable_query_log
--eval $ddl_var
--dec $count
}
--enable_warnings
INSERT INTO t1 VALUES (REPEAT('a', 767));
--connection node_2
SELECT COUNT(*) = 1 FROM t1;
SELECT LENGTH(f1) = 767 FROM t1;
EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (PRIMARY) WHERE f1 = REPEAT('a', 767);
SELECT COUNT(*) = 1 FROM t1 FORCE KEY (PRIMARY) WHERE f1 = REPEAT('a', 767);
EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i1) WHERE f1 = REPEAT('a', 767);
SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i1) WHERE f1 = REPEAT('a', 767);
EXPLAIN SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i63) WHERE f1 = REPEAT('a', 767);
SELECT COUNT(*) = 1 FROM t1 FORCE KEY (i63) WHERE f1 = REPEAT('a', 767);
INSERT INTO t1 VALUES (REPEAT('b', 767));
ANALYZE TABLE t1;
--connection node_1
SELECT COUNT(*) = 2 FROM t1;
ANALYZE TABLE t1;
DELETE FROM t1 WHERE f1 = REPEAT('b', 767);
# Rollback
--connection node_1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
SELECT COUNT(*) = 1 FROM t1;
INSERT INTO t1 (f1) VALUES (REPEAT('c', 767));
ROLLBACK;
SELECT COUNT(*) = 1 FROM t1;
--connection node_2
START TRANSACTION;
SET AUTOCOMMIT=OFF;
SELECT COUNT(*) = 1 FROM t1;
# Deadlock
--connection node_1
START TRANSACTION;
--connection node_2
START TRANSACTION;
--connection node_1
UPDATE t1 SET f1 = REPEAT('e', 767);
--connection node_2
UPDATE t1 SET f1 = REPEAT('f', 767);
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE t1;
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE ten (f1 INTEGER) ENGINE=INNODB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_2
SELECT COUNT(*) = 100000 FROM t1;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_1
SELECT COUNT(*) = 200000 FROM t1;
UPDATE t1 SET f2 = 1;
--connection node_2
SELECT COUNT(*) = 200000 FROM t1 WHERE f2 = 1;
# Rollback
--connection node_1
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
ROLLBACK;
SELECT COUNT(*) = 200000 FROM t1;
--connection node_2
SELECT COUNT(*) = 200000 FROM t1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t1 SET f2 = 2;
ROLLBACK;
--connection node_1
START TRANSACTION;
SELECT COUNT(*) = 200000 FROM t1;
UPDATE t1 SET f2 = 3;
--connection node_2
START TRANSACTION;
UPDATE t1 SET f2 = 4;
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE t1;
DROP TABLE ten;
#
# This checks that even tables with a single BIT column are replicated properly without a PK
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (f1 BIT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),(0),(b'1');
--connection node_2
SELECT f1 IS NULL, f1 = b'1' FROM t1;
DELETE FROM t1 WHERE f1 = b'1';
UPDATE t1 SET f1 = b'1' WHERE f1 IS NULL;
UPDATE t1 SET f1 = 1 WHERE f1 = b'0';
--connection node_1
SELECT f1 IS NULL, f1 = b'1' FROM t1;
#
# Provoke a conflict
#
--connection node_1
CREATE TABLE t2 (f1 BIT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (NULL);
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 0 WHERE f1 IS NULL;
--connection node_2
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 1 WHERE f1 IS NULL;
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE t1;
DROP TABLE t2;
#
# This checks that even tables with a single BLOB column and no FK are replicated properly
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (f1 BLOB) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),('abc');
--connection node_2
SELECT f1 FROM t1;
DELETE FROM t1 WHERE f1 IS NULL;
UPDATE t1 SET f1 = 'xyz' WHERE f1 = 'abc';
--connection node_1
SELECT COUNT(*) = 1 FROM t1;
SELECT f1 = 'abc' FROM t1;
#
# Provoke a conflict
#
--connection node_1
CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB;
INSERT INTO t2 VALUES (NULL);
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'abc' WHERE f1 IS NULL;
--connection node_2
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'xyz' WHERE f1 IS NULL;
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE t1;
DROP TABLE t2;
#
# This checks that even tables with a single long VARCHARcolumn and no FK are replicated properly
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
# From the Innodb manual: "The maximum row length, except for variable-length columns (VARBINARY, VARCHAR, BLOB and TEXT),
# is slightly less than half of a database page. That is, the maximum row length is about 8000 bytes"
CREATE TABLE t1 (f1 VARCHAR(8000)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL),(CONCAT(REPEAT('x', 7999), 'a'));
--connection node_2
SELECT LENGTH(f1) FROM t1;
DELETE FROM t1 WHERE f1 IS NULL;
UPDATE t1 SET f1 = CONCAT(REPEAT('x', 7999), 'b') WHERE f1 = CONCAT(REPEAT('x', 7999), 'a');
--connection node_1
SELECT COUNT(*) = 1 FROM t1;
SELECT LENGTH(f1) = 8000 FROM t1;
SELECT f1 = CONCAT(REPEAT('x', 7999), 'b') FROM t1;
#
# Provoke a conflict
#
--connection node_1
CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB;
INSERT INTO t2 VALUES (CONCAT(REPEAT('x', 7999), 'a'));
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'abc' WHERE f1 = CONCAT(REPEAT('x', 7999), 'a');
--connection node_2
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t2 SET f1 = 'xyz' WHERE f1 = CONCAT(REPEAT('x', 7999), 'a');
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE t1;
DROP TABLE t2;
#
# Test non-ascii table, column and index names
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $wsrep_sync_wait_orig = (SELECT @@wsrep_sync_wait)
SET GLOBAL wsrep_sync_wait = 7;
--connection node_2
SET GLOBAL wsrep_sync_wait = 7;
--connection node_1
# Spaces in identifiers
CREATE DATABASE `database with space`;
USE `database with space`;
CREATE TABLE `table with space` (
`column with space` INTEGER AUTO_INCREMENT PRIMARY KEY,
`second column with space` INTEGER,
UNIQUE `index name with space` (`second column with space`)
) ENGINE=INNODB;
INSERT INTO `table with space` VALUES (DEFAULT, 1);
# Unicode identifiers
CREATE DATABASE `база`;
USE `база`;
CREATE TABLE `таблица` (
`първа_колона` INTEGER PRIMARY KEY,
`втора_колона` INTEGER,
UNIQUE `индекс` (`втора_колона`)
) ENGINE=INNODB;
INSERT INTO `таблица` VALUES (1, 1);
# Without a PK
CREATE DATABASE `втора база`;
USE `втора база`;
CREATE TABLE `втора таблица` (
`първа колона` INTEGER,
`втора колона` INTEGER,
KEY `първи индекс` (`първа колона`)
) ENGINE=INNODB;
INSERT INTO `втора таблица` VALUES (1, 1);
--connection node_2
USE `database with space`;
SELECT * FROM `table with space`;
USE `база`;
SELECT * FROM `таблица`;
USE `втора база`;
SELECT * FROM `втора таблица`;
--eval SET GLOBAL wsrep_sync_wait = $wsrep_sync_wait_orig
--connection node_1
DROP TABLE `database with space`.`table with space`;
DROP TABLE `база`.`таблица`;
DROP TABLE `втора база`.`втора таблица`;
DROP DATABASE `database with space`;
DROP DATABASE `база`;
DROP DATABASE `втора база`;
--eval SET GLOBAL wsrep_sync_wait = $wsrep_sync_wait_orig
#
# Test wsrep_auto_increment_control = OFF
# We issue two concurrent INSERTs and one will fail with a deadlock error
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $auto_increment_control_orig = `SELECT @@wsrep_auto_increment_control`
#
# Preserve existing variable values
#
--connection node_1
--let $auto_increment_increment_node1 = `SELECT @@auto_increment_increment`
--let $auto_increment_offset_node1 = `SELECT @@auto_increment_offset`
# Restore stock MySQL defaults
SET GLOBAL wsrep_auto_increment_control = OFF;
SET GLOBAL auto_increment_increment = 1;
SET GLOBAL auto_increment_offset = 1;
#Open a fresh connection to node_1 so that the variables above take effect
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc
--connection node_2
--let $auto_increment_increment_node2 = `SELECT @@auto_increment_increment`
--let $auto_increment_offset_node2 = `SELECT @@auto_increment_offset`
SET GLOBAL wsrep_auto_increment_control = OFF;
SET GLOBAL auto_increment_increment = 1;
SET GLOBAL auto_increment_offset = 1;
#Open a fresh connection to node_2
--let $galera_connection_name = node_2a
--let $galera_server_number = 2
--source include/galera_connect.inc
--connection node_1a
SELECT @@auto_increment_increment = 1;
SELECT @@auto_increment_offset = 1;
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB;
#
# We expect that SHOW CREATE TABLE on both nodes will return identical values
#
SHOW CREATE TABLE t1;
--connection node_2a
SHOW CREATE TABLE t1;
--connection node_1a
SELECT @@auto_increment_increment = 1;
SELECT @@auto_increment_offset = 1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 (node) VALUES ('node1');
SELECT f1 FROM t1;
--connection node_2a
SELECT @@auto_increment_increment = 1;
SELECT @@auto_increment_offset = 1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 (node) VALUES ('node2');
SELECT f1 FROM t1;
--connection node_1a
COMMIT;
--connection node_2a
--error ER_LOCK_DEADLOCK
COMMIT;
--connection node_1a
SELECT * FROM t1;
--connection node_2a
SELECT * FROM t1;
#
# Restore all variables as they were
#
--connection node_1
--eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig
--eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node1
--eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node1
--connection node_2
--eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig
--eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node2
--eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node2
DROP TABLE t1;
#
# Test the operation of wsrep_auto_increment_control = ON
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--connection node_1
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB;
SHOW CREATE TABLE t1;
# auto_increment_increment is equal to the number of nodes
# auto_increment_offset is equal to the ID of the node
SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size');
SELECT @@auto_increment_offset = 1;
# Expect no conflicts
--send INSERT INTO t1 VALUES (DEFAULT, 'node1');
--connection node_2
--send INSERT INTO t1 VALUES (DEFAULT, 'node2');
--connection node_1
--reap
--connection node_2
--reap
SHOW CREATE TABLE t1;
SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size');
SELECT @@auto_increment_offset = 2;
# Expect no conflicts
--send INSERT INTO t1 VALUES (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2');
--connection node_1
--send INSERT INTO t1 VALUES (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1'), (DEFAULT, 'node1');
--connection node_2
--reap
--connection node_1
--reap
--connection node_2
SELECT COUNT(*) = 22 FROM t1;
SELECT COUNT(DISTINCT f1) = 22 FROM t1;
--connection node_1
SELECT COUNT(*) = 22 FROM t1;
SELECT COUNT(DISTINCT f1) = 22 FROM t1;
DROP TABLE t1;
#
# Test wsrep_certify_nonPK = OFF
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $wsrep_certify_nonPK_orig = `SELECT @@wsrep_certify_nonPK`
SET GLOBAL wsrep_certify_nonPK = OFF;
--connection node_2
SET GLOBAL wsrep_certify_nonPK = OFF;
--connection node_1
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB /* Table has no primary key */;
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
# All DML without a PK is rejected with an error
--error ER_LOCK_DEADLOCK
INSERT INTO t1 VALUES (1), (2);
# DML with a PK is allowed to proceed
INSERT INTO t2 VALUES (1), (2);
UPDATE t2 SET f1 = 3 WHERE f1 = 1;
--connection node_2
SELECT COUNT(*) = 0 FROM t1;
SELECT COUNT(*) = 2 FROM t2;
SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 3;
--connection node_1
--eval SET GLOBAL wsrep_certify_nonPK = $wsrep_certify_nonPK_orig
--connection node_2
--eval SET GLOBAL wsrep_certify_nonPK = $wsrep_certify_nonPK_orig
DROP TABLE t1;
DROP TABLE t2;
#
# Test the operation on the foreign_key_checks variable
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1);
INSERT INTO child VALUES (1,1);
SET SESSION foreign_key_checks = 0;
INSERT INTO child VALUES (2,2);
--connection node_2
SELECT COUNT(*) = 1 FROM child WHERE id = 2;
--error ER_NO_REFERENCED_ROW_2
INSERT INTO child VALUES (3,3);
SET SESSION foreign_key_checks = 0;
DELETE FROM parent;
--connection node_1
SELECT COUNT(*) = 0 FROM parent;
DROP TABLE child;
DROP TABLE parent;
#
# Simple test for the operation on the wsrep-mysql-replication-bundle
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $wsrep_mysql_replication_bundle_orig = `SELECT @@wsrep_mysql_replication_bundle`
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB;
SET GLOBAL wsrep_mysql_replication_bundle = 2;
--connection node_1
# This statement will not be replicated immediately
INSERT INTO t1 VALUES (1);
--connection node_2
SELECT COUNT(*) = 0 FROM t1;
--connection node_1
INSERT INTO t1 VALUES (2);
--connection node_2
SELECT COUNT(*) = 2 FROM t1;
--connection node_1
--eval SET GLOBAL wsrep_mysql_replication_bundle = $wsrep_mysql_replication_bundle_orig
DROP TABLE t1;
#
# Simple test for wsrep-replicate-myisam = FALSE
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $wsrep_replicate_myisam_orig = `SELECT @@wsrep_replicate_myisam`
SET GLOBAL wsrep_replicate_myisam = FALSE;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM;
INSERT INTO t1 VALUES (1);
--connection node_2
SELECT COUNT(*) = 0 FROM t1;
--connection node_1
--eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig
DROP TABLE t1;
#
# Simple test for wsrep-replicate-myisam = ON
#
--source include/galera_cluster.inc
--source include/have_innodb.inc
--let $wsrep_replicate_myisam_orig = `SELECT @@wsrep_replicate_myisam`
SET GLOBAL wsrep_replicate_myisam = TRUE;
CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM;
INSERT INTO t1 VALUES (1);
--connection node_2
SELECT COUNT(*) = 1 FROM t1;
--connection node_1
--eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig
DROP TABLE t1;
This diff is collapsed.
This diff is collapsed.
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/have_innodb.inc
--echo # --echo #
--echo # MDEV#5552 Deadlock when inserting NULL column value in column with --echo # MDEV#5552 Deadlock when inserting NULL column value in column with
...@@ -19,12 +20,14 @@ SELECT * FROM test.t1; ...@@ -19,12 +20,14 @@ SELECT * FROM test.t1;
--connection node_2 --connection node_2
SELECT * FROM test.t1; SELECT * FROM test.t1;
--echo --echo
--echo # On node_1 --echo # On node_1
--connection node_1 --connection node_1
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
UPDATE t1 SET c1=NULL WHERE c1=1; UPDATE t1 SET c1=NULL WHERE c1=1;
SELECT * FROM test.t1; SELECT * FROM test.t1;
--echo --echo
--echo # On node_2 --echo # On node_2
--connection node_2 --connection node_2
......
* 'wsrep' suite is designated for tests which do not require a multi-node
galera cluster.
* As these tests are specific to wsrep-related functionalities, they must skip
on server built without wsrep patch (vanilla). (-DWITH_WSREP=OFF)
See : include/have_wsrep.inc, include/have_wsrep_enabled.inc, not_wsrep.inc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
--log-bin --innodb_autoinc_lock_mode=2 --wsrep-provider=$WSREP_PROVIDER --wsrep-cluster-address=gcomm://
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment