summaryrefslogtreecommitdiff
path: root/mysql-test/suite/vcol/t/vcol_syntax.test
blob: f425b52ab790a7bc951c0aba06bf361dafcb5131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#
# test syntax
#
--disable_warnings
drop table if exists t1;
--enable_warnings

set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
create table t1 (a int, b int generated always  as (a+1));
show create table t1;
drop table t1;
create table t1 (a int, b int as (a+1) virtual);
show create table t1;
drop table t1;
create table t1 (a int, b int generated always  as (a+1) persistent);
show create table t1;
drop table t1;

set session sql_mode='ORACLE';
create table t1 (a int, b int as (a+1));
show create table t1;
drop table t1;
create table t1 (a int, b int generated always as (a+1) virtual);
show create table t1;
drop table t1;
create table t1 (a int, b int as (a+1) persistent);
show create table t1;
drop table t1;
set session sql_mode=@OLD_SQL_MODE;

--echo #
--echo # MDEV-25091 CREATE TABLE: field references qualified by a wrong table name succeed
--echo #
create table t2 (x int);

--error ER_BAD_FIELD_ERROR
create table t1 (x int, y int generated always as (t2.x));
--error ER_BAD_FIELD_ERROR
create table t1 (x int, y int check (y > t2.x));
--error ER_BAD_FIELD_ERROR
create table t1 (x int, y int default t2.x);
--error ER_BAD_FIELD_ERROR
create table t1 (x int, check (t2.x > 0));

create table t1 (x int);
--error ER_BAD_FIELD_ERROR
alter table t1 add column y int generated always as (t2.x);
--error ER_BAD_FIELD_ERROR
alter table t1 add column y int check (z > t2.x);
--error ER_BAD_FIELD_ERROR
alter table t1 add column y int default t2.x;
--error ER_BAD_FIELD_ERROR
alter table t1 add constraint check (t2.x > 0);

create or replace table t1 (x int, y int generated always as (t1.x));
create or replace table t1 (x int, y int check (y > t1.x));
create or replace table t1 (x int, y int default t1.x);
create or replace table t1 (x int, check (t1.x > 0));

create or replace table t1 (x int, y int generated always as (test.t1.x));
create or replace table t1 (x int, y int check (y > test.t1.x));
create or replace table t1 (x int, y int default test.t1.x);
create or replace table t1 (x int, check (test.t1.x > 0));

drop tables t1, t2;

--error ER_BAD_FIELD_ERROR
create table t1 (x int, y int generated always as (test2.t1.x));
--error ER_BAD_FIELD_ERROR
create table t1 (x int, y int check (y > test2.t1.x));
--error ER_BAD_FIELD_ERROR
create table t1 (x int, y int default test2.t1.x);
--error ER_BAD_FIELD_ERROR
create table t1 (x int, check (test2.t1.x > 0));