1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
Files
mariadb/mysql-test/suite/innodb/r/lock_insert_into_empty.result
Marko Mäkelä cffbb17480 MDEV-28933: Per-table unique FOREIGN KEY constraint names
Before MySQL 4.0.18, user-specified constraint names were ignored.
Starting with MySQL 4.0.18, the specified constraint name was
prepended with the schema name and '/'.  Now we are transforming
into a format where the constraint name is prepended with the
dict_table_t::name and the impossible UTF-8 sequence 0xff.
Generated constraint names will be ASCII decimal numbers.

On upgrade, old FOREIGN KEY constraint names will be displayed
without any schema name prefix. They will be updated to the new
format on DDL operations.

dict_foreign_t::sql_id(): Return the SQL constraint name
without any schemaname/tablename\377 or schemaname/ prefix.

row_rename_table_for_mysql(), dict_table_rename_in_cache():
Simplify the logic: Just rename constraints to the new format.

dict_table_get_foreign_id(): Replaces dict_table_get_highest_foreign_id().

innobase_get_foreign_key_info(): Let my_error() refer to erroneous
anonymous constraints as "(null)".

row_delete_constraint(): Try to drop all 3 constraint name variants.

Reviewed by: Thirunarayanan Balathandayuthapani
Tested by: Matthias Leich
2025-07-08 12:30:27 +03:00

63 lines
1.8 KiB
Plaintext

CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(0);
BEGIN;
DELETE FROM t1;
INSERT INTO t2 VALUES(1),(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
BEGIN;
SELECT * FROM t2 LOCK IN SHARE MODE;
a
connect con1,localhost,root,,;
SET innodb_lock_wait_timeout=0;
INSERT INTO t2 VALUES(2);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection default;
ROLLBACK;
connection con1;
INSERT INTO t2 VALUES(3);
COMMIT;
disconnect con1;
connection default;
SELECT * FROM t1;
a
SELECT * FROM t2;
a
3
DROP TABLE t1, t2;
#
# MDEV-24700 Assertion "lock not found"==0 in lock_table_x_unlock()
#
SET FOREIGN_KEY_CHECKS=OFF;
CREATE TABLE t1 (id INT PRIMARY KEY, f INT REFERENCES nonexistent(x))
ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS=ON;
BEGIN;
INSERT IGNORE INTO t1 VALUES (1,11);
Warnings:
Warning 1452 Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `1` FOREIGN KEY (`f`) REFERENCES `nonexistent` (`x`))
REPLACE INTO t1 VALUES (1,12);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `1` FOREIGN KEY (`f`) REFERENCES `nonexistent` (`x`))
COMMIT;
DROP TABLE t1;
#
# MDEV-25942 Assertion failed in trx_t::drop_table()
#
CREATE TABLE t1 (k INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 SET k=1;
START TRANSACTION;
INSERT INTO t1 SET k=2;
SELECT count(*) > 0 FROM mysql.innodb_index_stats lock in share mode;
count(*) > 0
1
connect con1,localhost,root,,test;
SET innodb_lock_wait_timeout=0;
CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB
AS SELECT k FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con1;
connection default;
SET innodb_lock_wait_timeout=default;
DROP TABLE t1;
DROP TABLE IF EXISTS t2;