-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix: Vitess show character set where #5710
Conversation
Signed-off-by: Roni He <[email protected]>
Signed-off-by: Roni He <[email protected]>
Signed-off-by: Roni He <[email protected]>
Signed-off-by: Roni He <[email protected]>
Signed-off-by: Roni He <[email protected]>
7e1dab6
to
e34ade7
Compare
Signed-off-by: Roni He <[email protected]>
executor_test is failing:
I suggest changing the expected output for these cases and adding new cases to test with |
Signed-off-by: Roni He <[email protected]>
Signed-off-by: Roni He <[email protected]>
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.
LGTM
@Ronihe can you rebase or merge and resolve conflicts? |
go/vt/vtgate/executor.go
Outdated
row1 = append(row1, sqltypes.NewInt32(4)) | ||
rows = append(rows, row0, row1) | ||
|
||
charsets := []string{"utf8", "utf8mb4"} |
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.
Here you are using "magic" strings that are repeated in line 1580 of this file. I think it'd be better to use const
s of strings, or even an enum.
go/vt/vtgate/executor.go
Outdated
rightString := string(sqlVal.Val) | ||
|
||
switch cmpExp.Operator { | ||
case "=": |
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.
This file is full of magic strings, even before your changes. But we can improve the situation. Here I would suggest that you use the same string that the parser uses, which is sqlparser.EqualStr
. That way it's easy to find usages of this symbol.
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.
@systay do you mean create a file in sqlparser just for all the magic string/ words?
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.
Just replace =
with sqlparser.EqualStr
go/vt/vtgate/executor.go
Outdated
filteredColName = colName | ||
} | ||
} | ||
case "like": |
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.
Same as above, but with sqlparser.LikeStr
go/vt/vtgate/executor_test.go
Outdated
} | ||
for _, query := range []string{"show charset like 'utf8'", "show character set like 'utf8'", "show charset where charset = 'utf8'", "show character set where charset = 'utf8'"} { | ||
qr, err := executor.Execute(context.Background(), "TestExecute", session, query, nil) | ||
if 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.
There's a few of them in the new code, and it's probably because most of this file is doing it.
For new code, I think it's way better to write require.NoError(t, err)
.
I'll let @systay approve once his comments have been addressed
Signed-off-by: roni <[email protected]>
Signed-off-by: roni <[email protected]>
Signed-off-by: roni <[email protected]>
Signed-off-by: roni <[email protected]>
closes #5584
right now the show character set are hardcoded to be filtered with where statement.
since we don't really want to expand the results or forward the query to an underlying mysql because vitess only supports these 2 charsets.
Ideally there should be a where modular to do the function.