summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/vcol/r/vcol_syntax.result
blob: 0063f38ea361babdb66b6db0b41d8058bd235d20 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
create table t1 (a int, b int generated always  as (a+1));
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) GENERATED ALWAYS AS (`a` + 1) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int, b int as (a+1) virtual);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) GENERATED ALWAYS AS (`a` + 1) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int, b int generated always  as (a+1) persistent);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) GENERATED ALWAYS AS (`a` + 1) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
set session sql_mode='ORACLE';
create table t1 (a int, b int as (a+1));
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) DEFAULT NULL,
  "b" int(11) GENERATED ALWAYS AS ("a" + 1) VIRTUAL
)
drop table t1;
create table t1 (a int, b int generated always as (a+1) virtual);
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) DEFAULT NULL,
  "b" int(11) GENERATED ALWAYS AS ("a" + 1) VIRTUAL
)
drop table t1;
create table t1 (a int, b int as (a+1) persistent);
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) DEFAULT NULL,
  "b" int(11) GENERATED ALWAYS AS ("a" + 1) STORED
)
drop table t1;
set session sql_mode=@OLD_SQL_MODE;
#
# MDEV-25091 CREATE TABLE: field references qualified by a wrong table name succeed
#
create table t2 (x int);
create table t1 (x int, y int generated always as (t2.x));
ERROR 42S22: Unknown column '`t2`.`x`' in 'GENERATED ALWAYS'
create table t1 (x int, y int check (y > t2.x));
ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK'
create table t1 (x int, y int default t2.x);
ERROR 42S22: Unknown column '`t2`.`x`' in 'DEFAULT'
create table t1 (x int, check (t2.x > 0));
ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK'
create table t1 (x int);
alter table t1 add column y int generated always as (t2.x);
ERROR 42S22: Unknown column '`t2`.`x`' in 'GENERATED ALWAYS'
alter table t1 add column y int check (z > t2.x);
ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK'
alter table t1 add column y int default t2.x;
ERROR 42S22: Unknown column '`t2`.`x`' in 'DEFAULT'
alter table t1 add constraint check (t2.x > 0);
ERROR 42S22: Unknown column '`t2`.`x`' in 'CHECK'
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;
create table t1 (x int, y int generated always as (test2.t1.x));
ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'GENERATED ALWAYS'
create table t1 (x int, y int check (y > test2.t1.x));
ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK'
create table t1 (x int, y int default test2.t1.x);
ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'DEFAULT'
create table t1 (x int, check (test2.t1.x > 0));
ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK'
#
# MDEV-25672 table alias from previous statement interferes later commands
#
create table t1 (a int, v_a int generated always as (a));
update t1 as x set a = 1;
alter table t1 force;
drop table t1;
#
# End of 10.2 tests
#