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

VDiff: Add BIT datatype to list of byte comparable types #8401

Merged
merged 3 commits into from
Jul 14, 2021
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
16 changes: 4 additions & 12 deletions go/test/endtoend/cluster/vtctl_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,11 @@ func (vtctl *VtctlProcess) AddCellInfo(Cell string) (err error) {

// CreateKeyspace executes vtctl command to create keyspace
func (vtctl *VtctlProcess) CreateKeyspace(keyspace string) (err error) {
tmpProcess := exec.Command(
vtctl.Binary,
"-topo_implementation", vtctl.TopoImplementation,
"-topo_global_server_address", vtctl.TopoGlobalAddress,
"-topo_global_root", vtctl.TopoGlobalRoot,
)
if *isCoverage {
tmpProcess.Args = append(tmpProcess.Args, "-test.coverprofile="+getCoveragePath("vtctl-create-ks.out"))
output, err := vtctl.ExecuteCommandWithOutput("CreateKeyspace", keyspace)
if err != nil {
log.Errorf("CreateKeyspace returned err: %s, output: %s", err, output)
}
tmpProcess.Args = append(tmpProcess.Args,
"CreateKeyspace", keyspace)
log.Infof("Running CreateKeyspace with command: %v", strings.Join(tmpProcess.Args, " "))
return tmpProcess.Run()
return err
}

// ExecuteCommandWithOutput executes any vtctlclient command and returns output
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vreplication/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package vreplication
var (
initialProductSchema = `
create table product(pid int, description varbinary(128), primary key(pid));
create table customer(cid int, name varbinary(128), meta json default null, typ enum('individual','soho','enterprise'), sport set('football','cricket','baseball'),ts timestamp not null default current_timestamp, primary key(cid)) CHARSET=utf8mb4;
create table customer(cid int, name varbinary(128), meta json default null, typ enum('individual','soho','enterprise'), sport set('football','cricket','baseball'),ts timestamp not null default current_timestamp, bits bit(2) default b'11', primary key(cid)) CHARSET=utf8mb4;
create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
create table merchant(mname varchar(128), category varchar(128), primary key(mname)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
create table orders(oid int, cid int, pid int, mname varchar(128), price int, qty int, total int as (qty * price), total2 int as (qty * price) stored, primary key(oid));
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/evalengine/arithmetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func isByteComparable(v sqltypes.Value) bool {
return true
}
switch v.Type() {
case sqltypes.Timestamp, sqltypes.Date, sqltypes.Time, sqltypes.Datetime, sqltypes.Enum, sqltypes.Set, sqltypes.TypeJSON:
case sqltypes.Timestamp, sqltypes.Date, sqltypes.Time, sqltypes.Datetime, sqltypes.Enum, sqltypes.Set, sqltypes.TypeJSON, sqltypes.Bit:
return true
}
return false
Expand Down
15 changes: 15 additions & 0 deletions go/vt/vtgate/evalengine/arithmetic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,21 @@ func TestNullsafeCompare(t *testing.T) {
v1: TestValue(querypb.Type_DATETIME, "1000-01-01 00:00:00"),
v2: TestValue(querypb.Type_BINARY, "2000-01-01 00:00:00"),
out: -1,
}, {
// Date/Time types
v1: TestValue(querypb.Type_BIT, "101"),
v2: TestValue(querypb.Type_BIT, "101"),
out: 0,
}, {
// Date/Time types
v1: TestValue(querypb.Type_BIT, "1"),
v2: TestValue(querypb.Type_BIT, "0"),
out: 1,
}, {
// Date/Time types
v1: TestValue(querypb.Type_BIT, "0"),
v2: TestValue(querypb.Type_BIT, "1"),
out: -1,
}}
for _, tcase := range tcases {
got, err := NullsafeCompare(tcase.v1, tcase.v2)
Expand Down
1 change: 0 additions & 1 deletion go/vt/vtgate/vindexes/consistent_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ func TestConsistentLookupUpdateBecauseUncomparableTypes(t *testing.T) {
{querypb.Type_TEXT, "some string"},
{querypb.Type_VARCHAR, "some string"},
{querypb.Type_CHAR, "some string"},
{querypb.Type_BIT, "some string"},
{querypb.Type_GEOMETRY, "some string"},
}

Expand Down
2 changes: 1 addition & 1 deletion go/vt/wrangler/vdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ func (wr *Wrangler) VDiff(ctx context.Context, targetKeyspace, workflowName, sou
}
// Perform the diff of source and target streams.
dr, err := td.diff(ctx, df.ts.wr, &rowsToCompare, debug, onlyPks)
dr.TableName = table
if err != nil {
return nil, vterrors.Wrap(err, "diff")
}
dr.TableName = table
diffReports[table] = dr
}
if format == "json" {
Expand Down