Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions data/test/vtgate/dml_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1512,3 +1512,24 @@
"Query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)"
}
}

# update vindex value to null
"update user set name = null where id = 1"
{
"Original": "update user set name = null where id = 1",
"Instructions": {
"Opcode": "UpdateEqual",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "update user set name = null where id = 1",
"Vindex": "user_index",
"Values": [1],
"ChangedVindexValues": {
"name_user_map": [null]
},
"Table": "user",
"OwnedVindexQuery": "select Name, Costly from user where id = 1 for update"
}
}
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func generateUpdateSubquery(upd *sqlparser.Update, table *vindexes.Table) string
// it's holding. At the moment it only supports: StrVal, HexVal, IntVal, ValArg.
// If a complex expression is provided (e.g set name = name + 1), the update will be rejected.
func extractValueFromUpdate(upd *sqlparser.UpdateExpr) (pv sqltypes.PlanValue, err error) {
if !sqlparser.IsValue(upd.Expr) {
if !sqlparser.IsValue(upd.Expr) && !sqlparser.IsNull(upd.Expr) {
err := vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: Only values are supported. Invalid update on column: %v", upd.Name.Name)
return sqltypes.PlanValue{}, err
}
Expand Down