File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -3068,3 +3068,11 @@ t1 CREATE TABLE `t1` (
3068
3068
`a` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT concat('A')
3069
3069
) ENGINE=MyISAM DEFAULT CHARSET=latin1
3070
3070
DROP TABLE t1;
3071
+ create table t1 (a int default 1, b int default (1+1), c int);
3072
+ insert t1 (c) values (a);
3073
+ insert t1 (c) values (b);
3074
+ select * from t1;
3075
+ a b c
3076
+ 1 2 1
3077
+ 1 2 NULL
3078
+ drop table t1;
Original file line number Diff line number Diff line change @@ -1840,3 +1840,12 @@ CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET latin1 DEFAULT CONCAT('
1840
1840
CREATE OR REPLACE TABLE t1 (a char(2) default concat('A') COLLATE utf8mb4_unicode_ci);
1841
1841
SHOW CREATE TABLE t1;
1842
1842
DROP TABLE t1;
1843
+
1844
+ #
1845
+ # Order of evaluation:
1846
+ #
1847
+ create table t1 (a int default 1, b int default (1+1), c int);
1848
+ insert t1 (c) values (a);
1849
+ insert t1 (c) values (b);
1850
+ select * from t1;
1851
+ drop table t1;
Original file line number Diff line number Diff line change @@ -942,13 +942,16 @@ bool Item_field::register_field_in_write_map(void *arg)
942
942
943
943
Fields are initialized in this order:
944
944
- All fields that have default value as a constant are initialized first.
945
+ - Then user-specified values from the INSERT list
945
946
- Then all fields that has a default expression, in field_index order.
946
947
- Last all virtual fields, in field_index order.
947
948
948
949
This means:
949
950
- For default fields we can't access the same field or a field after
950
951
itself that doesn't have a non-constant default value.
951
952
- A virtual fields can't access itself or a virtual field after itself.
953
+ - user-specified values will not see virtual fields or default expressions,
954
+ as in INSERT t1 (a) VALUES (b);
952
955
953
956
This is used by fix_vcol_expr() when a table is opened
954
957
You can’t perform that action at this time.
0 commit comments