Debian Codegraph @

mysql-test/suite/vcol/inc/vcol_dependancies_on_vcol.inc

raw
1 ################################################################################
2 # inc/vcol_dependencies_on_vcol.inc #
3 # #
4 # Purpose: #
5 # Testing scenarios when columns depend on virtual columns, i.e. such as #
6 # - a virtual column is based on a virtual column #
7 # - a "real" column on which a virtual one is renamed/dropped #
8 # - a virtual column involved in partitioning is renamed/dropped #
9 # #
10 #------------------------------------------------------------------------------#
11 # Original Author: Andrey Zhakov #
12 # Original Date: 2008-09-02 #
13 # Change Author: Oleksandr Byelkin (Monty program Ab)
14 # Date: 2009-03-24
15 # Change: Syntax changed
16 ################################################################################
17
18 --echo # Can't define a virtual column on another virtual column
19 --error ER_VCOL_BASED_ON_VCOL
20 create table t1 (a int, b int as (a+1), c int as (b+1));
21 create table t1 (a int, b int as (a+1));
22 --error ER_VCOL_BASED_ON_VCOL
23 alter table t1 add column c int as (b+1);
24 drop table t1;
25
26 --echo # Can't rename or drop a column used in the function of a virtual column
27 create table t1 (a int, b int as (a+1));
28 --echo # On renaming/dropping a column on which a virtual field is
29 --echo # defined the following error is displayed:
30 --echo # "Unknown column 'a' in 'virtual column function'"
31 --error ER_BAD_FIELD_ERROR
32 alter table t1 drop column a;
33 --error ER_BAD_FIELD_ERROR
34 alter table t1 change a c int;
35 drop table t1;
36
37 --echo # Can't rename or drop a virtual column used by the paritition function
38 create table t1 (a int, b int as (a+1)) partition by hash(b);
39 --error ER_BAD_FIELD_ERROR
40 alter table t1 drop b;
41 --error ER_BAD_FIELD_ERROR
42 alter table t1 change b c int as (a+1);
43