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
b4844f21
Commit
b4844f21
authored
Mar 05, 2023
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review
parent
62bd5446
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
32 deletions
+73
-32
mysql-test/main/foreign_key.result
mysql-test/main/foreign_key.result
+36
-13
mysql-test/main/foreign_key.test
mysql-test/main/foreign_key.test
+33
-12
sql/datadict.cc
sql/datadict.cc
+2
-6
sql/datadict.h
sql/datadict.h
+1
-1
sql/sql_table.h
sql/sql_table.h
+1
-0
No files found.
mysql-test/main/foreign_key.result
View file @
b4844f21
...
@@ -157,25 +157,25 @@ test.t1 check status OK
...
@@ -157,25 +157,25 @@ test.t1 check status OK
test.t2 check Note Found 1 foreign keys
test.t2 check Note Found 1 foreign keys
test.t2 check status OK
test.t2 check status OK
drop table t2, t1;
drop table t2, t1;
create database
D
;
create database
Test_MariaDB
;
create table
D
.T1(id int primary key);
create table
Test_MariaDB
.T1(id int primary key);
create table t2(id int primary key, f1 int references
D
.T1(id));
create table t2(id int primary key, f1 int references
Test_MariaDB
.T1(id));
select * from
D
.T1;
select * from
Test_MariaDB
.T1;
id
id
check table
D
.T1;
check table
Test_MariaDB
.T1;
Table Op Msg_type Msg_text
Table Op Msg_type Msg_text
D
.T1 check Note Found 1 referenced keys
Test_MariaDB
.T1 check Note Found 1 referenced keys
D
.T1 check status OK
Test_MariaDB
.T1 check status OK
drop table t2;
drop table t2;
check table
D
.T1;
check table
Test_MariaDB
.T1;
Table Op Msg_type Msg_text
Table Op Msg_type Msg_text
D
.T1 check status OK
Test_MariaDB
.T1 check status OK
flush tables;
flush tables;
check table
D
.T1;
check table
Test_MariaDB
.T1;
Table Op Msg_type Msg_text
Table Op Msg_type Msg_text
D
.T1 check status OK
Test_MariaDB
.T1 check status OK
drop table
D
.T1;
drop table
Test_MariaDB
.T1;
drop database
D
;
drop database
Test_MariaDB
;
# Check rename column, lock tables
# Check rename column, lock tables
create or replace table t1 (id int primary key);
create or replace table t1 (id int primary key);
create or replace table t2 (id int primary key);
create or replace table t2 (id int primary key);
...
@@ -449,13 +449,31 @@ create or replace table t1 (id int primary key);
...
@@ -449,13 +449,31 @@ create or replace table t1 (id int primary key);
select * from t1;
select * from t1;
id
id
create or replace database test2;
create or replace database test2;
create or replace database test3;
create or replace database test4;
use test2;
use test2;
create or replace table ch1 (
create or replace table ch1 (
id int, id2 int,
id int, id2 int,
foreign key (id) references test.t1 (id));
foreign key (id) references test.t1 (id));
select * from ch1;
select * from ch1;
id id2
id id2
use test3;
create or replace table par2 (
id int primary key);
use test4;
create or replace table par3 (
id int primary key);
create or replace table ch3 (
id int, id2 int,
foreign key (id) references par3 (id));
select * from par3;
id
select * from ch3;
id id2
use test;
use test;
create or replace table ch2 (
id int, id2 int,
foreign key (id) references test3.par2 (id));
drop database test2;
drop database test2;
check tables t1;
check tables t1;
Table Op Msg_type Msg_text
Table Op Msg_type Msg_text
...
@@ -465,6 +483,11 @@ check tables t1;
...
@@ -465,6 +483,11 @@ check tables t1;
Table Op Msg_type Msg_text
Table Op Msg_type Msg_text
test.t1 check status OK
test.t1 check status OK
drop tables t1;
drop tables t1;
drop database test3;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (ch2_ibfk_1)
drop table ch2;
drop database test3;
drop database test4;
# Check add foreign key
# Check add foreign key
create or replace table t1(fld1 int not null primary key);
create or replace table t1(fld1 int not null primary key);
create or replace table t2(fld1 int not null, fld2 int as (fld1) virtual);
create or replace table t2(fld1 int not null, fld2 int as (fld1) virtual);
...
...
mysql-test/main/foreign_key.test
View file @
b4844f21
...
@@ -175,20 +175,20 @@ flush tables;
...
@@ -175,20 +175,20 @@ flush tables;
check
tables
t1
,
t2
;
check
tables
t1
,
t2
;
drop
table
t2
,
t1
;
drop
table
t2
,
t1
;
create
database
D
;
create
database
Test_MariaDB
;
create
table
D
.
T1
(
id
int
primary
key
);
create
table
Test_MariaDB
.
T1
(
id
int
primary
key
);
create
table
t2
(
id
int
primary
key
,
f1
int
references
D
.
T1
(
id
));
create
table
t2
(
id
int
primary
key
,
f1
int
references
Test_MariaDB
.
T1
(
id
));
select
*
from
D
.
T1
;
select
*
from
Test_MariaDB
.
T1
;
--
replace_result
d
.
t1
D
.
T1
--
replace_result
test_mariadb
.
t1
Test_MariaDB
.
T1
check
table
D
.
T1
;
check
table
Test_MariaDB
.
T1
;
drop
table
t2
;
drop
table
t2
;
--
replace_result
d
.
t1
D
.
T1
--
replace_result
test_mariadb
.
t1
Test_MariaDB
.
T1
check
table
D
.
T1
;
check
table
Test_MariaDB
.
T1
;
flush
tables
;
flush
tables
;
--
replace_result
d
.
t1
D
.
T1
--
replace_result
test_mariadb
.
t1
Test_MariaDB
.
T1
check
table
D
.
T1
;
check
table
Test_MariaDB
.
T1
;
drop
table
D
.
T1
;
drop
table
Test_MariaDB
.
T1
;
drop
database
D
;
drop
database
Test_MariaDB
;
--
echo
# Check rename column, lock tables
--
echo
# Check rename column, lock tables
create
or
replace
table
t1
(
id
int
primary
key
);
create
or
replace
table
t1
(
id
int
primary
key
);
...
@@ -312,17 +312,38 @@ drop tables ch1, t1;
...
@@ -312,17 +312,38 @@ drop tables ch1, t1;
create
or
replace
table
t1
(
id
int
primary
key
);
create
or
replace
table
t1
(
id
int
primary
key
);
select
*
from
t1
;
select
*
from
t1
;
create
or
replace
database
test2
;
create
or
replace
database
test2
;
create
or
replace
database
test3
;
create
or
replace
database
test4
;
use
test2
;
use
test2
;
create
or
replace
table
ch1
(
create
or
replace
table
ch1
(
id
int
,
id2
int
,
id
int
,
id2
int
,
foreign
key
(
id
)
references
test
.
t1
(
id
));
foreign
key
(
id
)
references
test
.
t1
(
id
));
select
*
from
ch1
;
select
*
from
ch1
;
use
test3
;
create
or
replace
table
par2
(
id
int
primary
key
);
use
test4
;
create
or
replace
table
par3
(
id
int
primary
key
);
create
or
replace
table
ch3
(
id
int
,
id2
int
,
foreign
key
(
id
)
references
par3
(
id
));
select
*
from
par3
;
select
*
from
ch3
;
use
test
;
use
test
;
create
or
replace
table
ch2
(
id
int
,
id2
int
,
foreign
key
(
id
)
references
test3
.
par2
(
id
));
drop
database
test2
;
drop
database
test2
;
check
tables
t1
;
check
tables
t1
;
flush
tables
t1
;
flush
tables
t1
;
check
tables
t1
;
check
tables
t1
;
drop
tables
t1
;
drop
tables
t1
;
--
error
ER_ROW_IS_REFERENCED_2
drop
database
test3
;
drop
table
ch2
;
drop
database
test3
;
drop
database
test4
;
--
echo
# Check add foreign key
--
echo
# Check add foreign key
create
or
replace
table
t1
(
fld1
int
not
null
primary
key
);
create
or
replace
table
t1
(
fld1
int
not
null
primary
key
);
...
...
sql/datadict.cc
View file @
b4844f21
...
@@ -360,9 +360,8 @@ bool Extra2_info::read(const uchar *frm_image, size_t frm_size)
...
@@ -360,9 +360,8 @@ bool Extra2_info::read(const uchar *frm_image, size_t frm_size)
uchar
*
uchar
*
Extra2_info
::
write
(
uchar
*
frm_image
,
size_t
frm_size
)
Extra2_info
::
write
(
uchar
*
frm_image
)
{
{
// FIXME: what to do with frm_size here (and in read())?
uchar
*
pos
;
uchar
*
pos
;
/* write the extra2 segment */
/* write the extra2 segment */
pos
=
frm_image
+
FRM_HEADER_SIZE
;
pos
=
frm_image
+
FRM_HEADER_SIZE
;
...
@@ -405,9 +404,6 @@ Extra2_info::write(uchar *frm_image, size_t frm_size)
...
@@ -405,9 +404,6 @@ Extra2_info::write(uchar *frm_image, size_t frm_size)
DBUG_ASSERT
(
write_size
==
store_size
());
DBUG_ASSERT
(
write_size
==
store_size
());
DBUG_ASSERT
(
write_size
<=
0xffff
-
FRM_HEADER_SIZE
-
4
);
DBUG_ASSERT
(
write_size
<=
0xffff
-
FRM_HEADER_SIZE
-
4
);
#if 0
int4store(pos, filepos); // end of the extra2 segment
#endif
return
pos
;
return
pos
;
}
}
...
@@ -496,7 +492,7 @@ int TABLE_SHARE::fk_write_shadow_frm(THD *thd)
...
@@ -496,7 +492,7 @@ int TABLE_SHARE::fk_write_shadow_frm(THD *thd)
memcpy
((
void
*
)
frm_dst
,
(
void
*
)
frm_src
,
FRM_HEADER_SIZE
);
memcpy
((
void
*
)
frm_dst
,
(
void
*
)
frm_src
,
FRM_HEADER_SIZE
);
if
(
!
(
pos
=
extra2
.
write
(
frm_dst
,
frm_size
)))
if
(
!
(
pos
=
extra2
.
write
(
frm_dst
)))
{
{
my_printf_error
(
ER_CANT_CREATE_TABLE
,
my_printf_error
(
ER_CANT_CREATE_TABLE
,
"Cannot create table %`s: "
"Cannot create table %`s: "
...
...
sql/datadict.h
View file @
b4844f21
...
@@ -211,7 +211,7 @@ struct Extra2_info
...
@@ -211,7 +211,7 @@ struct Extra2_info
}
}
bool
read
(
const
uchar
*
frm_image
,
size_t
frm_size
);
bool
read
(
const
uchar
*
frm_image
,
size_t
frm_size
);
uchar
*
write
(
uchar
*
frm_image
,
size_t
frm_size
);
uchar
*
write
(
uchar
*
frm_image
);
};
};
class
Table_name
;
class
Table_name
;
...
...
sql/sql_table.h
View file @
b4844f21
...
@@ -58,6 +58,7 @@ enum enum_explain_filename_mode
...
@@ -58,6 +58,7 @@ enum enum_explain_filename_mode
/* depends on errmsg.txt Database `db`, Table `t` ... */
/* depends on errmsg.txt Database `db`, Table `t` ... */
#define EXPLAIN_FILENAME_MAX_EXTRA_LENGTH 63
#define EXPLAIN_FILENAME_MAX_EXTRA_LENGTH 63
/* Shadow FRM is new FRM file that replaces the old one */
#define WFRM_WRITE_SHADOW 1
#define WFRM_WRITE_SHADOW 1
#define WFRM_INSTALL_SHADOW 2
#define WFRM_INSTALL_SHADOW 2
#define WFRM_KEEP_SHARE 4
#define WFRM_KEEP_SHARE 4
...
...
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