Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
3687edee
Commit
3687edee
authored
Jun 29, 2016
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarify the order of evaluation for INSERT
parent
f93a2a3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
mysql-test/r/default.result
mysql-test/r/default.result
+8
-0
mysql-test/t/default.test
mysql-test/t/default.test
+9
-0
sql/item.cc
sql/item.cc
+3
-0
No files found.
mysql-test/r/default.result
View file @
3687edee
...
@@ -3068,3 +3068,11 @@ t1 CREATE TABLE `t1` (
...
@@ -3068,3 +3068,11 @@ t1 CREATE TABLE `t1` (
`a` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT concat('A')
`a` char(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT concat('A')
) ENGINE=MyISAM DEFAULT CHARSET=latin1
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP TABLE t1;
create table t1 (a int default 1, b int default (1+1), c int);
insert t1 (c) values (a);
insert t1 (c) values (b);
select * from t1;
a b c
1 2 1
1 2 NULL
drop table t1;
mysql-test/t/default.test
View file @
3687edee
...
@@ -1840,3 +1840,12 @@ CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET latin1 DEFAULT CONCAT('
...
@@ -1840,3 +1840,12 @@ CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET latin1 DEFAULT CONCAT('
CREATE
OR
REPLACE
TABLE
t1
(
a
char
(
2
)
default
concat
(
'A'
)
COLLATE
utf8mb4_unicode_ci
);
CREATE
OR
REPLACE
TABLE
t1
(
a
char
(
2
)
default
concat
(
'A'
)
COLLATE
utf8mb4_unicode_ci
);
SHOW
CREATE
TABLE
t1
;
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Order of evaluation:
#
create
table
t1
(
a
int
default
1
,
b
int
default
(
1
+
1
),
c
int
);
insert
t1
(
c
)
values
(
a
);
insert
t1
(
c
)
values
(
b
);
select
*
from
t1
;
drop
table
t1
;
sql/item.cc
View file @
3687edee
...
@@ -942,6 +942,7 @@ bool Item_field::register_field_in_write_map(void *arg)
...
@@ -942,6 +942,7 @@ bool Item_field::register_field_in_write_map(void *arg)
Fields are initialized in this order:
Fields are initialized in this order:
- All fields that have default value as a constant are initialized first.
- All fields that have default value as a constant are initialized first.
- Then user-specified values from the INSERT list
- Then all fields that has a default expression, in field_index order.
- Then all fields that has a default expression, in field_index order.
- Last all virtual fields, in field_index order.
- Last all virtual fields, in field_index order.
...
@@ -949,6 +950,8 @@ bool Item_field::register_field_in_write_map(void *arg)
...
@@ -949,6 +950,8 @@ bool Item_field::register_field_in_write_map(void *arg)
- For default fields we can't access the same field or a field after
- For default fields we can't access the same field or a field after
itself that doesn't have a non-constant default value.
itself that doesn't have a non-constant default value.
- A virtual fields can't access itself or a virtual field after itself.
- A virtual fields can't access itself or a virtual field after itself.
- user-specified values will not see virtual fields or default expressions,
as in INSERT t1 (a) VALUES (b);
This is used by fix_vcol_expr() when a table is opened
This is used by fix_vcol_expr() when a table is opened
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment