Skip to content

Commit

Permalink
opt: add hint to column type mismatch on mutation error
Browse files Browse the repository at this point in the history
Fixes #52298.

Release justification: low risk, high benefit change to existing
functionality

Release note: None
  • Loading branch information
rohany committed Aug 26, 2020
1 parent c046a2b commit 1d76346
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/sql/opt/optbuilder/mutation_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,11 @@ func checkDatumTypeFitsColumnType(col *cat.Column, typ *types.T) {
}

colName := string(col.ColName())
panic(pgerror.Newf(pgcode.DatatypeMismatch,
err := pgerror.Newf(pgcode.DatatypeMismatch,
"value type %s doesn't match type %s of column %q",
typ, col.DatumType(), tree.ErrNameString(colName)))
typ, col.DatumType(), tree.ErrNameString(colName))
err = errors.WithHint(err, "you will need to rewrite or cast the expression")
panic(err)
}

// partialIndexCount returns the number of public, write-only, and delete-only
Expand Down

0 comments on commit 1d76346

Please sign in to comment.