mirror of
https://github.com/MariaDB/server.git
synced 2025-02-04 21:02:17 +01:00
8adb6107ce
when validating vcol's (default, check, etc) in ALTER TABLE vcol_info->flags are modified in place. This means that if ALTER TABLE fails for any reason we need to restore them to their original values. (mroonga was freeing the memory on ::reset() but not on ::close())
101 lines
7.8 KiB
Text
101 lines
7.8 KiB
Text
set default_storage_engine=innodb;
|
|
create table t1 (id int primary key, id2 int as (id) virtual, key id2 (id2));
|
|
create table t2 (id int key, constraint fk_id foreign key (id) references t1 (id) on delete cascade);
|
|
insert into t1 (id) values (1), (2);
|
|
insert into t2 (id) values (1), (2);
|
|
delete from t1;
|
|
select * from t1;
|
|
id id2
|
|
select * from t2;
|
|
id
|
|
drop table t2;
|
|
drop table t1;
|
|
#
|
|
# End of 10.2 tests
|
|
#
|
|
#
|
|
# MDEV-18114 Foreign Key Constraint actions don't affect Virtual Column
|
|
#
|
|
create table t1 (id int primary key);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update cascade);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on delete set null);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, key(id2), foreign key (id) references t1 (id) on update set null);
|
|
create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update cascade);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the GENERATED ALWAYS AS clause of `id2`
|
|
create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on delete set null);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the GENERATED ALWAYS AS clause of `id2`
|
|
create or replace table t2 (id int, id2 int as (id) stored, foreign key (id) references t1 (id) on update set null);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the GENERATED ALWAYS AS clause of `id2`
|
|
create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update cascade);
|
|
ERROR HY000: Function or expression 'id2' cannot be used in the GENERATED ALWAYS AS clause of `id3`
|
|
create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on delete set null);
|
|
ERROR HY000: Function or expression 'id2' cannot be used in the GENERATED ALWAYS AS clause of `id3`
|
|
create or replace table t2 (id int, id2 int as (id) virtual, id3 int as (id2) stored, foreign key (id) references t1 (id) on update set null);
|
|
ERROR HY000: Function or expression 'id2' cannot be used in the GENERATED ALWAYS AS clause of `id3`
|
|
create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update cascade);
|
|
create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on delete set null);
|
|
create or replace table t2 (id int, id2 int default (id), foreign key (id) references t1 (id) on update set null);
|
|
create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update cascade);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the CHECK clause of `id2`
|
|
create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on delete set null);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the CHECK clause of `id2`
|
|
create or replace table t2 (id int, id2 int check (id), foreign key (id) references t1 (id) on update set null);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the CHECK clause of `id2`
|
|
create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update cascade);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the CHECK clause of `CONSTRAINT_1`
|
|
create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on delete set null);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the CHECK clause of `CONSTRAINT_1`
|
|
create or replace table t2 (id int, id2 int, check (id), foreign key (id) references t1 (id) on update set null);
|
|
ERROR HY000: Function or expression 'id' cannot be used in the CHECK clause of `CONSTRAINT_1`
|
|
create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update restrict);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update no action);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on delete cascade);
|
|
create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update cascade);
|
|
ERROR HY000: Function or expression 'id2' cannot be used in the CHECK clause of `CONSTRAINT_1`
|
|
create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on delete set null);
|
|
ERROR HY000: Function or expression 'id2' cannot be used in the CHECK clause of `CONSTRAINT_1`
|
|
create or replace table t2 (id int, id2 int as (id) virtual, check (id2), foreign key (id) references t1 (id) on update set null);
|
|
ERROR HY000: Function or expression 'id2' cannot be used in the CHECK clause of `CONSTRAINT_1`
|
|
drop table if exists t2, t1;
|
|
Warnings:
|
|
Note 1051 Unknown table 'test.t2'
|
|
#
|
|
# MDEV-31853 Assertion failure in Column_definition::check_vcol_for_key upon adding FK
|
|
#
|
|
create table t (a int, b int, c int generated always as (a), key(b), key(c));
|
|
alter table t add foreign key (a) references t (b) on update set null, algorithm=nocopy;
|
|
ERROR 0A000: ALGORITHM=NOCOPY is not supported. Reason: Adding foreign keys needs foreign_key_checks=OFF. Try ALGORITHM=COPY
|
|
alter table t add foreign key (a) references t (b);
|
|
show create table t;
|
|
Table Create Table
|
|
t CREATE TABLE `t` (
|
|
`a` int(11) DEFAULT NULL,
|
|
`b` int(11) DEFAULT NULL,
|
|
`c` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
|
|
KEY `b` (`b`),
|
|
KEY `c` (`c`),
|
|
KEY `a` (`a`),
|
|
CONSTRAINT `t_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t` (`b`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
|
drop table t;
|
|
#
|
|
# End of 10.5 tests
|
|
#
|