1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

Auto-merge from mysql-5.5-bugteam.

This commit is contained in:
Alexander Nozdrin
2010-10-13 01:17:22 +04:00
140 changed files with 2439 additions and 1597 deletions

View File

@@ -918,9 +918,9 @@ ERROR HY000: Too big row
alter table t1 row_format=compact;
create index t1u on t1 (u(1));
drop table t1;
set global innodb_file_per_table=1;
set global innodb_file_format=Barracuda;
set global innodb_file_format_max=Barracuda;
set global innodb_file_per_table=0;
set global innodb_file_format=Antelope;
set global innodb_file_format_max=Antelope;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
CREATE TABLE t1(

View File

@@ -0,0 +1,68 @@
#
# TRUNCATE TABLE
#
# Truncating is disallowed for parent tables unless such table
# participates in self-referencing foreign keys only.
#
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB;
CREATE TABLE t2 (fk INT NOT NULL, FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
TRUNCATE TABLE t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `test`.`t1` (`pk`))
# Truncation of child should succeed.
TRUNCATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, fk INT,
FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
# Truncation of self-referencing table should succeed.
TRUNCATE TABLE t1;
DROP TABLE t1;
#
# Also, truncating such tables is allowed if foreign key
# checks are disabled.
#
SET @old_foreign_key_checks = @@SESSION.foreign_key_checks;
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB;
CREATE TABLE t2 (fk INT NOT NULL, FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
CREATE TABLE t3 (pk INT PRIMARY KEY, fk INT,
FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
SET @@SESSION.foreign_key_checks = 0;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
SET @@SESSION.foreign_key_checks = 1;
TRUNCATE TABLE t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `test`.`t1` (`pk`))
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
LOCK TABLES t1 WRITE;
SET @@SESSION.foreign_key_checks = 0;
TRUNCATE TABLE t1;
SET @@SESSION.foreign_key_checks = 1;
TRUNCATE TABLE t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`fk`) REFERENCES `test`.`t1` (`pk`))
UNLOCK TABLES;
DROP TABLE t3,t2,t1;
SET @@SESSION.foreign_key_checks = @old_foreign_key_checks;
#
# Test that TRUNCATE resets auto-increment.
#
CREATE TABLE t1 (a INT PRIMARY KEY NOT NULL AUTO_INCREMENT);
INSERT INTO t1 VALUES (NULL), (NULL);
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't1';
AUTO_INCREMENT
3
SELECT * FROM t1 ORDER BY a;
a
1
2
TRUNCATE TABLE t1;
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't1';
AUTO_INCREMENT
1
INSERT INTO t1 VALUES (NULL), (NULL);
SELECT * FROM t1 ORDER BY a;
a
1
2
DROP TABLE t1;

View File

@@ -394,8 +394,8 @@ table_schema table_name row_format
test t8 Compact
test t9 Redundant
drop table t8, t9;
set global innodb_file_per_table=1;
set global innodb_file_format=Barracuda;
set global innodb_file_per_table=0;
set global innodb_file_format=Antelope;
set global innodb_file_per_table=on;
set global innodb_file_format=`Barracuda`;
set global innodb_file_format_max=`Antelope`;

View File

@@ -2424,10 +2424,6 @@ drop table t1,t2;
CREATE TABLE t1 (
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
) ENGINE=InnoDB;
CREATE TABLE t2 (
id INTEGER NOT NULL,
FOREIGN KEY (id) REFERENCES t1 (id)
) ENGINE=InnoDB;
INSERT INTO t1 (id) VALUES (NULL);
SELECT * FROM t1;
id
@@ -2443,7 +2439,7 @@ INSERT INTO t1 (id) VALUES (NULL);
SELECT * FROM t1;
id
1
DROP TABLE t2, t1;
DROP TABLE t1;
CREATE TABLE t1
(
id INT PRIMARY KEY
@@ -2621,13 +2617,15 @@ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fail
update t4 set a=2;
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
truncate t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t1` (`a`))
truncate t3;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t3` (`a`))
truncate t2;
truncate t4;
truncate t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t1` (`a`))
truncate t3;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t3` (`a`))
drop table t4,t3,t2,t1;
create table t1 (a varchar(255) character set utf8,
b varchar(255) character set utf8,

View File

@@ -125,6 +125,6 @@ Warning 1264 Out of range value for column 'col78' at row 1
Warning 1265 Data truncated for column 'col79' at row 1
Warning 1264 Out of range value for column 'col84' at row 1
DROP TABLE bug52745;
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_format=Antelope;
SET GLOBAL innodb_file_format_max=Antelope;
SET GLOBAL innodb_file_per_table=1;
SET GLOBAL innodb_file_per_table=0;

View File

@@ -11,6 +11,6 @@ Error 139 Too big row
Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
Error 1030 Got error 139 from storage engine
DROP TABLE bug53591;
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_format=Antelope;
SET GLOBAL innodb_file_format_max=Antelope;
SET GLOBAL innodb_file_per_table=1;
SET GLOBAL innodb_file_per_table=0;

View File

@@ -1,6 +1,6 @@
select @@innodb_file_format;
@@innodb_file_format
Barracuda
Antelope
select @@innodb_file_format_check;
@@innodb_file_format_check
1
@@ -17,14 +17,14 @@ Barracuda
set global innodb_file_format=default;
select @@innodb_file_format;
@@innodb_file_format
Barracuda
Antelope
set global innodb_file_format=on;
ERROR 42000: Variable 'innodb_file_format' can't be set to the value of 'ON'
set global innodb_file_format=off;
ERROR 42000: Variable 'innodb_file_format' can't be set to the value of 'off'
select @@innodb_file_format;
@@innodb_file_format
Barracuda
Antelope
set global innodb_file_format_max=antelope;
set global innodb_file_format_max=barracuda;
set global innodb_file_format_max=cheetah;
@@ -46,5 +46,5 @@ Antelope
set global innodb_file_format_max=antelope;
set global innodb_file_format_check=off;
ERROR HY000: Variable 'innodb_file_format_check' is a read only variable
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_format=Antelope;
SET GLOBAL innodb_file_format_max=Antelope;

View File

@@ -1941,7 +1941,7 @@ INSERT INTO t2 VALUES (3,2);
SET AUTOCOMMIT = 0;
START TRANSACTION;
TRUNCATE TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `test`.`t1` (`id`))
SELECT * FROM t1;
id
1
@@ -1953,7 +1953,7 @@ id
2
START TRANSACTION;
TRUNCATE TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `test`.`t1` (`id`))
SELECT * FROM t1;
id
1
@@ -1971,7 +1971,7 @@ id
2
COMMIT;
TRUNCATE TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `test`.`t1` (`id`))
SELECT * FROM t1;
id
1
@@ -1983,9 +1983,12 @@ id
1
2
TRUNCATE TABLE t1;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `test`.`t1` (`id`))
ROLLBACK;
SELECT * FROM t1;
id
1
2
TRUNCATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
@@ -2077,9 +2080,9 @@ i i
** error handling inside a row iteration.
**
DROP TRIGGER trg;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t3 VALUES (1),(2),(3),(4);
INSERT INTO t4 VALUES (3,3),(4,4);
@@ -2105,9 +2108,9 @@ DROP TRIGGER trg;
**
** Induce an error midway through an AFTER-trigger
**
TRUNCATE TABLE t4;
TRUNCATE TABLE t1;
TRUNCATE TABLE t3;
DELETE FROM t4;
DELETE FROM t1;
DELETE FROM t3;
INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t3 VALUES (1),(2),(3),(4);
CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW

View File

@@ -0,0 +1,65 @@
--source include/have_innodb.inc
--echo #
--echo # TRUNCATE TABLE
--echo #
--echo # Truncating is disallowed for parent tables unless such table
--echo # participates in self-referencing foreign keys only.
--echo #
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB;
CREATE TABLE t2 (fk INT NOT NULL, FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
--echo # Truncation of child should succeed.
TRUNCATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, fk INT,
FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
--echo # Truncation of self-referencing table should succeed.
TRUNCATE TABLE t1;
DROP TABLE t1;
--echo #
--echo # Also, truncating such tables is allowed if foreign key
--echo # checks are disabled.
--echo #
SET @old_foreign_key_checks = @@SESSION.foreign_key_checks;
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=INNODB;
CREATE TABLE t2 (fk INT NOT NULL, FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
CREATE TABLE t3 (pk INT PRIMARY KEY, fk INT,
FOREIGN KEY (fk) REFERENCES t1 (pk)) ENGINE=INNODB;
SET @@SESSION.foreign_key_checks = 0;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
SET @@SESSION.foreign_key_checks = 1;
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
LOCK TABLES t1 WRITE;
SET @@SESSION.foreign_key_checks = 0;
TRUNCATE TABLE t1;
SET @@SESSION.foreign_key_checks = 1;
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
UNLOCK TABLES;
DROP TABLE t3,t2,t1;
SET @@SESSION.foreign_key_checks = @old_foreign_key_checks;
--echo #
--echo # Test that TRUNCATE resets auto-increment.
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY NOT NULL AUTO_INCREMENT);
INSERT INTO t1 VALUES (NULL), (NULL);
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't1';
SELECT * FROM t1 ORDER BY a;
TRUNCATE TABLE t1;
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't1';
INSERT INTO t1 VALUES (NULL), (NULL);
SELECT * FROM t1 ORDER BY a;
DROP TABLE t1;

View File

@@ -1471,11 +1471,6 @@ CREATE TABLE t1 (
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
) ENGINE=InnoDB;
CREATE TABLE t2 (
id INTEGER NOT NULL,
FOREIGN KEY (id) REFERENCES t1 (id)
) ENGINE=InnoDB;
INSERT INTO t1 (id) VALUES (NULL);
SELECT * FROM t1;
TRUNCATE t1;
@@ -1488,7 +1483,7 @@ DELETE FROM t1;
TRUNCATE t1;
INSERT INTO t1 (id) VALUES (NULL);
SELECT * FROM t1;
DROP TABLE t2, t1;
DROP TABLE t1;
# Test that foreign keys in temporary tables are not accepted (bug #12084)
CREATE TABLE t1
@@ -1723,13 +1718,15 @@ update t2 set a=2;
update t3 set a=2;
-- error 1452
update t4 set a=2;
-- error 1451
-- error ER_TRUNCATE_ILLEGAL_FK
truncate t1;
-- error 1451
-- error ER_TRUNCATE_ILLEGAL_FK
truncate t3;
truncate t2;
truncate t4;
-- error ER_TRUNCATE_ILLEGAL_FK
truncate t1;
-- error ER_TRUNCATE_ILLEGAL_FK
truncate t3;
drop table t4,t3,t2,t1;

View File

@@ -151,14 +151,14 @@ INSERT INTO t2 VALUES (3,2);
SET AUTOCOMMIT = 0;
START TRANSACTION;
--error ER_ROW_IS_REFERENCED_2
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
SELECT * FROM t1;
COMMIT;
SELECT * FROM t1;
START TRANSACTION;
--error ER_ROW_IS_REFERENCED_2
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
SELECT * FROM t1;
ROLLBACK;
@@ -170,13 +170,14 @@ START TRANSACTION;
SELECT * FROM t1;
COMMIT;
--error ER_ROW_IS_REFERENCED_2
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
SELECT * FROM t1;
DELETE FROM t2 WHERE id = 3;
START TRANSACTION;
SELECT * FROM t1;
--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE TABLE t1;
ROLLBACK;
SELECT * FROM t1;
@@ -275,9 +276,9 @@ SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
--echo ** error handling inside a row iteration.
--echo **
DROP TRIGGER trg;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t3 VALUES (1),(2),(3),(4);
@@ -304,9 +305,9 @@ DROP TRIGGER trg;
--echo **
--echo ** Induce an error midway through an AFTER-trigger
--echo **
TRUNCATE TABLE t4;
TRUNCATE TABLE t1;
TRUNCATE TABLE t3;
DELETE FROM t4;
DELETE FROM t1;
DELETE FROM t3;
INSERT INTO t1 VALUES (1),(2),(3),(4);
INSERT INTO t3 VALUES (1),(2),(3),(4);
delimiter ||;