Skip to content

Commit

Permalink
update fk error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Sep 8, 2023
1 parent fa6f6d1 commit c301cdc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions go/vt/vterrors/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ var (

VT12001 = errorWithoutState("VT12001", vtrpcpb.Code_UNIMPLEMENTED, "unsupported: %s", "This statement is unsupported by Vitess. Please rewrite your query to use supported syntax.")
VT12002 = errorWithoutState("VT12002", vtrpcpb.Code_UNIMPLEMENTED, "unsupported: cross-shard foreign keys", "Vitess does not support cross shard foreign keys.")
VT12003 = errorWithoutState("VT12002", vtrpcpb.Code_UNIMPLEMENTED, "unsupported: foreign keys management at vitess", "Vitess does not support managing foreign keys tables.")

// VT13001 General Error
VT13001 = errorWithoutState("VT13001", vtrpcpb.Code_INTERNAL, "[BUG] %s", "This error should not happen and is a bug. Please file an issue on GitHub: https://github.com/vitessio/vitess/issues/new/choose.")
Expand Down Expand Up @@ -148,7 +147,6 @@ var (
VT10001,
VT12001,
VT12002,
VT12003,
VT13001,
VT13002,
VT14001,
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/planbuilder/operators/ast_to_update_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func createOperatorFromUpdate(ctx *plancontext.PlanningContext, updStmt *sqlpars

// If the delete statement has a limit, we don't support it yet.
if updStmt.Limit != nil {
return nil, vterrors.VT12001("foreign keys management at vitess with limit")
return nil, vterrors.VT12001("update with limit with foreign key constraints")
}

return buildFkOperator(ctx, updOp, updClone, parentFks, childFks, vindexTable)
Expand Down Expand Up @@ -180,7 +180,7 @@ func getFKRequirementsForUpdate(ctx *plancontext.PlanningContext, updateExprs sq
func buildFkOperator(ctx *plancontext.PlanningContext, updOp ops.Operator, updClone *sqlparser.Update, parentFks []vindexes.ParentFKInfo, childFks []vindexes.ChildFKInfo, updatedTable *vindexes.Table) (ops.Operator, error) {
// We only support simple expressions in update queries for foreign key handling.
if sqlparser.IsNonLiteral(updClone.Exprs) {
return nil, vterrors.VT12001("foreign keys management at vitess with non-literal values")
return nil, vterrors.VT12001("update expression with non-literal values with foreign key constraints")
}

restrictChildFks, cascadeChildFks := splitChildFks(childFks)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/operators/fk_cascade.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ func (fkc *FkCascade) GetOrdering() ([]ops.OrderBy, error) {

// ShortDescription implements the Operator interface
func (fkc *FkCascade) ShortDescription() string {
return "FkCascade"
return ""
}
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/operators/fk_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ func (fkv *FkVerify) GetOrdering() ([]ops.OrderBy, error) {

// ShortDescription implements the Operator interface
func (fkv *FkVerify) ShortDescription() string {
return "FkVerify"
return ""
}
8 changes: 4 additions & 4 deletions go/vt/vtgate/planbuilder/testdata/foreignkey_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -786,17 +786,17 @@
{
"comment": "update in a table with limit - disallowed",
"query": "update u_tbl2 set col2 = 'bar' limit 2",
"plan": "VT12001: unsupported: foreign keys management at vitess with limit"
"plan": "VT12001: unsupported: update with limit with foreign key constraints"
},
{
"comment": "update in a table with non-literal value - set null fail due to child update where condition",
"query": "update u_tbl2 set m = 2, col2 = col1 + 'bar' where id = 1",
"plan": "VT12001: unsupported: foreign keys management at vitess with non-literal values"
"plan": "VT12001: unsupported: update expression with non-literal values with foreign key constraints"
},
{
"comment": "update in a table with non-literal value - with cascade fail as the cascade value is not known",
"query": "update u_tbl1 set m = 2, col1 = x + 'bar' where id = 1",
"plan": "VT12001: unsupported: foreign keys management at vitess with non-literal values"
"plan": "VT12001: unsupported: update expression with non-literal values with foreign key constraints"
},
{
"comment": "update in a table with a child table having SET DEFAULT constraint - disallowed",
Expand All @@ -811,7 +811,7 @@
{
"comment": "update with fk on cross-shard with a where condition on non-literal value - disallowed",
"query": "update tbl3 set coly = colx + 10 where coly = 10",
"plan": "VT12001: unsupported: foreign keys management at vitess with non-literal values"
"plan": "VT12001: unsupported: update expression with non-literal values with foreign key constraints"
},
{
"comment": "update with fk on cross-shard with a where condition",
Expand Down

0 comments on commit c301cdc

Please sign in to comment.