Skip to content
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

Max/sqlerror codes #297

Merged
merged 9 commits into from Feb 16, 2021
Merged

Max/sqlerror codes #297

merged 9 commits into from Feb 16, 2021

Conversation

max-hoffman
Copy link
Contributor

@max-hoffman max-hoffman commented Feb 11, 2021

Append error codes/sql state to error messages for downstream clients.

@CLAassistant
Copy link

CLAassistant commented Feb 11, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, not complete

@@ -321,7 +321,7 @@ func (h *Handler) doQuery(
}()
if err != nil {
logrus.Tracef("Error running query %s: %s", query, err)
return err
return sql.CastSQLError(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need this in more places. Check out the other return code paths.

Or to make it easier, you might wrap the invocation of this entire function in another that inspects the error as necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ended up adding the new function because of go's type/value interface nil idiosyncrasies

sql/errors.go Outdated
var sqlState string = ""
switch {
case ErrTableNotFound.Is(err):
code = 1146
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to use the constants for these that vitess defines. They can be exported if they aren't already. Hard to review changes here with them being magic numbers.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@@ -156,7 +159,10 @@ func (h *Handler) ComQuery(
query string,
callback func(*sqltypes.Result) error,
) error {
return h.doQuery(c, query, nil, callback)
if err := h.doQuery(c, query, nil, callback); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: just make CastSQLError handle the nil err case and you don't need the conditional logic

@@ -321,7 +321,7 @@ func (h *Handler) doQuery(
}()
if err != nil {
logrus.Tracef("Error running query %s: %s", query, err)
return err
return sql.CastSQLError(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove now?

@max-hoffman max-hoffman marked this pull request as ready for review February 16, 2021 18:23
@max-hoffman max-hoffman merged commit 4b47ce7 into master Feb 16, 2021
@max-hoffman max-hoffman deleted the max/sqlerror-codes branch February 16, 2021 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants