-
Notifications
You must be signed in to change notification settings - Fork 66
backend: support stored generated columns in local/importer backends #505
Conversation
f212eff
to
8dad811
Compare
@@ -197,6 +197,7 @@ func newSession(options *SessionOptions) *session { | |||
vars.StmtCtx.TimeZone = vars.Location() | |||
vars.SetSystemVar("timestamp", strconv.FormatInt(options.Timestamp, 10)) | |||
vars.SetSystemVar(variable.TiDBRowFormatVersion, options.RowFormatVersion) | |||
vars.SetSystemVar(variable.MaxAllowedPacket, strconv.FormatUint(variable.MaxOfMaxAllowedPacket, 10)) |
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.
(the RPAD()
function relies on @@max_allowed_packet
)
LGTM |
return nil, logEvalGenExprFailed(logger, row, col, err) | ||
} | ||
mutRow.SetDatum(gc.index, value) | ||
record[gc.index] = value |
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
Why need these two setter both🤔
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.
@lance6716 Setting the MutRow is needed for cascading generated columns (think c as b+1
& a as b+1
, when calculating c
we need to calculate b
first).
Setting the record
is for inserting the result into the table.
MutRow
and []types.Datum
can't be cheaply converted between each other so we keep both of them.
What problem does this PR solve?
Properly support stored generated columns in local/importer backends.
Unlike virtual generated columns, the value of stored generated columns are saved into the KV entries. This is computed before
AddRecord()
. Therefore, before this PR, all stored generated columns imported using local or importer backends become NULL.What is changed and how it works?
We now fill in the stored generated columns by evaluating their expressions.
Check List
Tests
Side effects
Related changes
Release notes
Fixed: In local and importer backends, stored generated columns are properly filled in instead of being NULL.