Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
347f6d01
Commit
347f6d01
authored
Jan 14, 2022
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge 10.7 into 10.8
parents
4b14874c
c669e764
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
11 deletions
+66
-11
mysql-test/suite/innodb/r/foreign_key.result
mysql-test/suite/innodb/r/foreign_key.result
+23
-0
mysql-test/suite/innodb/t/foreign_key.test
mysql-test/suite/innodb/t/foreign_key.test
+18
-0
sql/sql_table.cc
sql/sql_table.cc
+11
-7
storage/innobase/buf/buf0buf.cc
storage/innobase/buf/buf0buf.cc
+14
-4
No files found.
mysql-test/suite/innodb/r/foreign_key.result
View file @
347f6d01
...
...
@@ -897,6 +897,29 @@ create or replace table t1 (a varchar(4096) unique) engine=innodb;
create or replace table t2 (pk int primary key, a varchar(4096) unique, foreign key(a) references t1(a) on update cascade) engine=innodb;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
drop table t1;
#
# MDEV-26824 Can't add foreign key with empty referenced columns list
#
create table t2(a int primary key) engine=innodb;
create table t1(a int primary key, b int) engine=innodb;
alter table t2 add foreign key(a) references t1(a, b);
ERROR 42000: Incorrect foreign key definition for 'foreign key without name': Key reference and table reference don't match
create or replace table t1(a tinyint primary key) engine innodb;
alter table t2 add foreign key(a) references t1;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
create or replace table t1(b int primary key) engine innodb;
alter table t2 add foreign key(a) references t1;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
create or replace table t1(a int primary key, b int) engine innodb;
alter table t2 add foreign key(a) references t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) NOT NULL,
PRIMARY KEY (`a`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop tables t2, t1;
# End of 10.5 tests
#
# MDEV-26554 Table-rebuilding DDL on parent table causes crash
...
...
mysql-test/suite/innodb/t/foreign_key.test
View file @
347f6d01
...
...
@@ -901,6 +901,24 @@ create or replace table t2 (pk int primary key, a varchar(4096) unique, foreign
drop
table
t1
;
--
echo
#
--
echo
# MDEV-26824 Can't add foreign key with empty referenced columns list
--
echo
#
create
table
t2
(
a
int
primary
key
)
engine
=
innodb
;
create
table
t1
(
a
int
primary
key
,
b
int
)
engine
=
innodb
;
--
error
ER_WRONG_FK_DEF
alter
table
t2
add
foreign
key
(
a
)
references
t1
(
a
,
b
);
create
or
replace
table
t1
(
a
tinyint
primary
key
)
engine
innodb
;
--
error
ER_CANT_CREATE_TABLE
alter
table
t2
add
foreign
key
(
a
)
references
t1
;
create
or
replace
table
t1
(
b
int
primary
key
)
engine
innodb
;
--
error
ER_CANT_CREATE_TABLE
alter
table
t2
add
foreign
key
(
a
)
references
t1
;
create
or
replace
table
t1
(
a
int
primary
key
,
b
int
)
engine
innodb
;
alter
table
t2
add
foreign
key
(
a
)
references
t1
;
show
create
table
t2
;
drop
tables
t2
,
t1
;
--
echo
# End of 10.5 tests
--
echo
#
...
...
sql/sql_table.cc
View file @
347f6d01
...
...
@@ -2926,15 +2926,19 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
Foreign_key
*
fk_key
=
(
Foreign_key
*
)
key
;
if
(
fk_key
->
validate
(
alter_info
->
create_list
))
DBUG_RETURN
(
TRUE
);
if
(
fk_key
->
ref_columns
.
elements
&&
fk_key
->
ref_columns
.
elements
!=
fk_key
->
columns
.
elements
)
if
(
fk_key
->
ref_columns
.
elements
)
{
my_error
(
ER_WRONG_FK_DEF
,
MYF
(
0
),
(
fk_key
->
name
.
str
?
fk_key
->
name
.
str
:
"foreign key without name"
),
ER_THD
(
thd
,
ER_KEY_REF_DO_NOT_MATCH_TABLE_REF
));
DBUG_RETURN
(
TRUE
);
if
(
fk_key
->
ref_columns
.
elements
!=
fk_key
->
columns
.
elements
)
{
my_error
(
ER_WRONG_FK_DEF
,
MYF
(
0
),
(
fk_key
->
name
.
str
?
fk_key
->
name
.
str
:
"foreign key without name"
),
ER_THD
(
thd
,
ER_KEY_REF_DO_NOT_MATCH_TABLE_REF
));
DBUG_RETURN
(
TRUE
);
}
}
else
fk_key
->
ref_columns
.
append
(
&
fk_key
->
columns
);
continue
;
}
(
*
key_count
)
++
;
...
...
storage/innobase/buf/buf0buf.cc
View file @
347f6d01
...
...
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 202
1
, MariaDB Corporation.
Copyright (c) 2013, 202
2
, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
...
...
@@ -2232,6 +2232,10 @@ void buf_page_free(fil_space_t *space, uint32_t page, mtr_t *mtr)
}
block
->
page
.
lock
.
x_lock
();
#ifdef BTR_CUR_HASH_ADAPT
if
(
block
->
index
)
btr_search_drop_page_hash_index
(
block
);
#endif
/* BTR_CUR_HASH_ADAPT */
block
->
page
.
set_freed
(
block
->
page
.
state
());
mtr
->
memo_push
(
block
,
MTR_MEMO_PAGE_X_FIX
);
}
...
...
@@ -2943,9 +2947,12 @@ buf_page_get_gen(
{
if
(
buf_block_t
*
block
=
recv_sys
.
recover
(
page_id
))
{
ut_ad
(
!
block
->
page
.
is_io_fixed
());
/* Recovery is a special case; we fix() before acquiring lock. */
const
auto
s
=
block
->
page
.
fix
();
auto
s
=
block
->
page
.
fix
();
ut_ad
(
s
>=
buf_page_t
::
FREED
);
/* The block may be write-fixed at this point because we are not
holding a lock, but it must not be read-fixed. */
ut_ad
(
s
<
buf_page_t
::
READ_FIX
||
s
>=
buf_page_t
::
WRITE_FIX
);
if
(
err
)
*
err
=
DB_SUCCESS
;
const
bool
must_merge
=
allow_ibuf_merge
&&
...
...
@@ -2957,7 +2964,10 @@ buf_page_get_gen(
page_is_leaf
(
block
->
page
.
frame
))
{
block
->
page
.
lock
.
x_lock
();
if
(
block
->
page
.
is_freed
())
s
=
block
->
page
.
state
();
ut_ad
(
s
>
buf_page_t
::
FREED
);
ut_ad
(
s
<
buf_page_t
::
READ_FIX
);
if
(
s
<
buf_page_t
::
UNFIXED
)
ut_ad
(
mode
==
BUF_GET_POSSIBLY_FREED
||
mode
==
BUF_PEEK_IF_IN_POOL
);
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment