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

[release-16.0] Fix for "text type with an unknown/unsupported collation cannot be hashed" error (#13852) #13863

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions go/test/endtoend/preparestmt/stmt_methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,24 @@ func TestShowColumns(t *testing.T) {
require.Len(t, cols, 6)
require.False(t, rows.Next())
}

func TestBinaryColumn(t *testing.T) {
defer cluster.PanicHandler(t)
dbo := Connect(t, "interpolateParams=false")
defer dbo.Close()

_, err := dbo.Query(`SELECT DISTINCT
BINARY table_info.table_name AS table_name,
table_info.create_options AS create_options,
table_info.table_comment AS table_comment
FROM information_schema.tables AS table_info
JOIN information_schema.columns AS column_info
ON BINARY column_info.table_name = BINARY table_info.table_name
WHERE
table_info.table_schema = ?
AND column_info.table_schema = ?
-- Exclude views.
AND table_info.table_type = 'BASE TABLE'
ORDER BY BINARY table_info.table_name`, keyspaceName, keyspaceName)
require.NoError(t, err)
}
10 changes: 10 additions & 0 deletions go/vt/vtgate/semantics/semantic_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ func (st *SemTable) TypeFor(e sqlparser.Expr) *querypb.Type {
if found {
return &typ.Type
}

// We add a lot of WeightString() expressions to queries at late stages of the planning,
// which means that they don't have any type information. We can safely assume that they
// are VarBinary, since that's the only type that WeightString() can return.
_, isWS := e.(*sqlparser.WeightStringFuncExpr)
if isWS {
typ := sqltypes.VarBinary
return &typ
}

return nil
}

Expand Down
Loading