-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planner: Support assign DEFAULT
in ON DUPLICATE KEY UPDATE
statement
#13168
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13168 +/- ##
===========================================
Coverage 80.0039% 80.0039%
===========================================
Files 473 473
Lines 116258 116258
===========================================
Hits 93011 93011
Misses 15944 15944
Partials 7303 7303 |
on duplicate key update gc=default
on generated columnsDEFAULT
to generated column in on duplicate key update
statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check insert into t1 values (1,default,default) on duplicate key update a=2, b=default(t);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/rebuild |
/run-all-tests tidb-test=pr/935 |
/run-all-tests |
@wjhuang2016, @djshow832, @zimulala, PTAL. |
1 similar comment
@wjhuang2016, @djshow832, @zimulala, PTAL. |
/run-all-tests |
planner/core/planbuilder.go
Outdated
} | ||
// Note: For INSERT, REPLACE, and UPDATE, if a generated column is inserted into, replaced, or updated explicitly, the only permitted value is DEFAULT. | ||
// see https://dev.mysql.com/doc/refman/8.0/en/create-table-generated-columns.html | ||
if _, ok := generatedColumns[assign.Column.Name.L]; ok { | ||
if isDefaultExpr { | ||
if isDefault { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
if defaultExpr := extractDefaultExpr(assign.Expr); defaultExpr != nil {
defaultExpr.Name = assign.Column expr.Name = assign.Column
} }
...
if defaultExpr != nil {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment addressed, PTAL @wjhuang2016
/run-all-tests |
isDefault = true | ||
var defaultExpr *ast.DefaultExpr | ||
if defaultExpr = extractDefaultExpr(assign.Expr); defaultExpr != nil { | ||
defaultExpr.Name = assign.Column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultExpr := extractDefaultExpr(assign.Expr);
if defaultExpr != nil {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wjhuang2016 Address comment, PTAL
…nto update-default-value-gc
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
/run-all-tests |
cherry pick to release-3.1 failed |
cherry pick to release-3.0 failed |
cherry pick to release-2.1 failed |
What problem does this PR solve?
Fix #13071
What is changed and how it works?
In statement
insert into t value (1) on duplicate key update a=default
, when we build theInsertPlan
, we also check:If the column need to be updated on duplicate key is generated column?
default
?The value specified for generated column 'gc' in table 't' is not allowed.
insertPlan.OnDuplicate
Check List
Tests
Code changes
Side effects
Related changes
default
into generated columns #11901Release note
DEFAULT
inON DUPLICATE KEY UPDATE
statement