1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name

Use temporary constraint names for temporary tables. The constraints
are not added to cache (skipped in dict_table_rename_in_cache()).

The scheme for temporary constraint names is as follows:

    for old table: db_name/\xFFconstraint_name
    for new table: db_name/\xFF\xFFconstraint_name

normalize_table_name_c_low(): wrong comparison "less than FN_REFLEN -
1". Somewhere array of FN_REFLEN includes the trailing 0, somewhere
array of FN_REFLEN + 1 includes trailing 0, but nowhere array of
FN_REFLEN - 1 must include trailing 0.
This commit is contained in:
Aleksey Midenkov
2022-08-31 11:55:06 +03:00
parent f1e1c1335b
commit cf6c517632
11 changed files with 221 additions and 22 deletions

View File

@ -863,3 +863,31 @@ select * from t2;
a
unlock tables;
drop tables t2, t1;
#
# MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name
#
use test;
create table t (a int primary key) engine=innodb;
create or replace table u (
a int primary key,
constraint c foreign key d (a) references t (a)) engine=innodb;
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
test/c test/u test/t 1 0
select * from information_schema.innodb_sys_foreign_cols;
ID FOR_COL_NAME REF_COL_NAME POS
test/c a a 0
create or replace table u (
a int primary key,
constraint c foreign key d (a) references t (a)) engine=innodb;
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
test/c test/u test/t 1 0
select * from information_schema.innodb_sys_foreign_cols;
ID FOR_COL_NAME REF_COL_NAME POS
test/c a a 0
drop tables u, t;
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
ID FOR_COL_NAME REF_COL_NAME POS