-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Max/sqlerror codes #297
Conversation
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.
Good start, not complete
server/handler.go
Outdated
@@ -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) |
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.
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.
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.
Remove now?
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.
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 |
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.
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.
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.
LG
server/handler.go
Outdated
@@ -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 { |
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.
Nit: just make CastSQLError handle the nil err case and you don't need the conditional logic
server/handler.go
Outdated
@@ -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) |
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.
Remove now?
Append error codes/sql state to error messages for downstream clients.