-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
blob enginetests #1061
blob enginetests #1061
Conversation
Add a small set of blob enginetests. Binary types are passed as byte arrays. Prevent binary primary keys. Add filter for binary indexes ensuring an index prefix less between 0 and 1000 is set or implicit from table schema. Need more blob index tests. Need to split binary types into their own format, probably when collations are added (all binary types have fixed binary collation).
4a7916b
to
92c5d78
Compare
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.
Mostly good but your key restrictions are too narrow. You're catching binary and varbinary types, which are valid in keys.
@@ -86,8 +86,6 @@ var ForeignKeyTests = []ScriptTest{ | |||
SetUpScript: []string{ | |||
"CREATE TABLE parent1 (pk BIGINT PRIMARY KEY, v1 CHAR(20), INDEX (v1));", | |||
"CREATE TABLE parent2 (pk BIGINT PRIMARY KEY, v1 VARCHAR(20), INDEX (v1));", | |||
"CREATE TABLE parent3 (pk BIGINT PRIMARY KEY, v1 BINARY(20), INDEX (v1));", |
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.
Why are these deleted? Binary and carbinary are valid index types
"", // ssl_cipher | ||
"", // x509_issuer | ||
"", // x509_subject | ||
[]byte(""), // ssl_cipher |
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.
Some places you're using uint8 and others byte. Standardize on byte everywhere you're doing this
func validateIndexType(cols []sql.IndexColumn, sch sql.Schema) error { | ||
for _, c := range cols { | ||
i := sch.IndexOfColName(c.Name) | ||
if sql.IsBlob(sch[i].Type) { |
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 isn't matching the right types and your check is too restrictive as a result
func IsBlob(t Type) bool {
switch t.Type() {
case sqltypes.Binary, sqltypes.VarBinary, sqltypes.Blob:
return true
default:
return false
}
}
You'll need to see what other places this is used, but I'm guessing it should be really be called IsByteType or similar
return sql.ErrUnknownIndexColumn.New(idxCol.Name, idx.IndexName) | ||
} | ||
|
||
if sql.IsBlob(col.Type) { |
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 comment
// validatePkTypes prevents creating tables with blob primary keys | ||
func validatePkTypes(tableSpec *plan.TableSpec) error { | ||
for _, col := range tableSpec.Schema.Schema { | ||
if col.PrimaryKey && sql.IsBlob(col.Type) { |
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 comment
sql/errors.go
Outdated
@@ -576,6 +576,15 @@ var ( | |||
|
|||
// ErrSpatialTypeConversion is returned when one spatial type cannot be converted to the other spatial type | |||
ErrSpatialTypeConversion = errors.NewKind("Cannot get geometry object from data you send to the GEOMETRY field") | |||
|
|||
// ErrInvalidBinaryPrimaryKey is returned when attempting to create a primary key with a binary column | |||
ErrInvalidBinaryPrimaryKey = errors.NewKind("invalid primary key on binary column '%s'") |
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.
Message / name needs adjusting
Binary columns are fine, it's specifically blob / text types that can't be used in keys
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 with one below
No description provided.