Commit b4844f21 authored by Aleksey Midenkov's avatar Aleksey Midenkov

Review

parent 62bd5446
......@@ -157,25 +157,25 @@ test.t1 check status OK
test.t2 check Note Found 1 foreign keys
test.t2 check status OK
drop table t2, t1;
create database D;
create table D.T1(id int primary key);
create table t2(id int primary key, f1 int references D.T1(id));
select * from D.T1;
create database Test_MariaDB;
create table Test_MariaDB.T1(id int primary key);
create table t2(id int primary key, f1 int references Test_MariaDB.T1(id));
select * from Test_MariaDB.T1;
id
check table D.T1;
check table Test_MariaDB.T1;
Table Op Msg_type Msg_text
D.T1 check Note Found 1 referenced keys
D.T1 check status OK
Test_MariaDB.T1 check Note Found 1 referenced keys
Test_MariaDB.T1 check status OK
drop table t2;
check table D.T1;
check table Test_MariaDB.T1;
Table Op Msg_type Msg_text
D.T1 check status OK
Test_MariaDB.T1 check status OK
flush tables;
check table D.T1;
check table Test_MariaDB.T1;
Table Op Msg_type Msg_text
D.T1 check status OK
drop table D.T1;
drop database D;
Test_MariaDB.T1 check status OK
drop table Test_MariaDB.T1;
drop database Test_MariaDB;
# Check rename column, lock tables
create or replace table t1 (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);
select * from t1;
id
create or replace database test2;
create or replace database test3;
create or replace database test4;
use test2;
create or replace table ch1 (
id int, id2 int,
foreign key (id) references test.t1 (id));
select * from ch1;
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;
create or replace table ch2 (
id int, id2 int,
foreign key (id) references test3.par2 (id));
drop database test2;
check tables t1;
Table Op Msg_type Msg_text
......@@ -465,6 +483,11 @@ check tables t1;
Table Op Msg_type Msg_text
test.t1 check status OK
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
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);
......
......@@ -175,20 +175,20 @@ flush tables;
check tables t1, t2;
drop table t2, t1;
create database D;
create table D.T1(id int primary key);
create table t2(id int primary key, f1 int references D.T1(id));
select * from D.T1;
--replace_result d.t1 D.T1
check table D.T1;
create database Test_MariaDB;
create table Test_MariaDB.T1(id int primary key);
create table t2(id int primary key, f1 int references Test_MariaDB.T1(id));
select * from Test_MariaDB.T1;
--replace_result test_mariadb.t1 Test_MariaDB.T1
check table Test_MariaDB.T1;
drop table t2;
--replace_result d.t1 D.T1
check table D.T1;
--replace_result test_mariadb.t1 Test_MariaDB.T1
check table Test_MariaDB.T1;
flush tables;
--replace_result d.t1 D.T1
check table D.T1;
drop table D.T1;
drop database D;
--replace_result test_mariadb.t1 Test_MariaDB.T1
check table Test_MariaDB.T1;
drop table Test_MariaDB.T1;
drop database Test_MariaDB;
--echo # Check rename column, lock tables
create or replace table t1 (id int primary key);
......@@ -312,17 +312,38 @@ drop tables ch1, t1;
create or replace table t1 (id int primary key);
select * from t1;
create or replace database test2;
create or replace database test3;
create or replace database test4;
use test2;
create or replace table ch1 (
id int, id2 int,
foreign key (id) references test.t1 (id));
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;
create or replace table ch2 (
id int, id2 int,
foreign key (id) references test3.par2 (id));
drop database test2;
check tables t1;
flush tables t1;
check 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
create or replace table t1(fld1 int not null primary key);
......
......@@ -360,9 +360,8 @@ bool Extra2_info::read(const uchar *frm_image, size_t frm_size)
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;
/* write the extra2 segment */
pos = frm_image + FRM_HEADER_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 <= 0xffff - FRM_HEADER_SIZE - 4);
#if 0
int4store(pos, filepos); // end of the extra2 segment
#endif
return pos;
}
......@@ -496,7 +492,7 @@ int TABLE_SHARE::fk_write_shadow_frm(THD *thd)
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,
"Cannot create table %`s: "
......
......@@ -211,7 +211,7 @@ struct Extra2_info
}
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;
......
......@@ -58,6 +58,7 @@ enum enum_explain_filename_mode
/* depends on errmsg.txt Database `db`, Table `t` ... */
#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_INSTALL_SHADOW 2
#define WFRM_KEEP_SHARE 4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment