Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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), typ enum('individual','soho','enterprise'), sport set('football','cricket','baseball'),ts timestamp not null default current_timestamp, primary key(cid));
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_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, primary key(oid));
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/vreplication/unsharded_init_data.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
insert into customer(cid, name, typ, sport) values(1, 'john',1,'football,baseball');
insert into customer(cid, name, typ, sport) values(2, 'paul','soho','cricket');
insert into customer(cid, name, typ, sport, meta) values(1, 'john',1,'football,baseball','{}');
insert into customer(cid, name, typ, sport, meta) values(2, 'paul','soho','cricket',convert(x'7b7d' using utf8mb4));
insert into customer(cid, name, typ, sport) values(3, 'ringo','enterprise','');
insert into merchant(mname, category) values('monoprice', 'electronics');
insert into merchant(mname, category) values('newegg', 'electronics');
Expand Down
2 changes: 2 additions & 0 deletions go/test/endtoend/vreplication/vreplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ func shardCustomer(t *testing.T, testReverse bool, cells []*Cell, sourceCellOrAl

insertQuery2 = "insert into customer(name, cid) values('tempCustomer4', 102)" //ID 102, hence due to reverse_bits in shard -80
require.True(t, validateThatQueryExecutesOnTablet(t, vtgateConn, customerTab1, "customer", insertQuery2, matchInsertQuery2))

execVtgateQuery(t, vtgateConn, "customer", "update customer set meta = convert(x'7b7d' using utf8mb4) where cid = 1")
reverseKsWorkflow := "product.p2c_reverse"
if testReverse {
//Reverse Replicate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,11 @@ func (tpb *tablePlanBuilder) generateUpdateStatement() *sqlparser.ParsedQuery {
switch cexpr.operation {
case opExpr:
bvf.mode = bvAfter
buf.Myprintf("%v", cexpr.expr)
if cexpr.colType == querypb.Type_JSON {
buf.Myprintf("convert(%v using utf8mb4)", cexpr.expr)
} else {
buf.Myprintf("%v", cexpr.expr)
}
case opCount:
buf.Myprintf("%v", cexpr.colName)
case opSum:
Expand Down
19 changes: 15 additions & 4 deletions go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,11 @@ func TestPlayerRowMove(t *testing.T) {

func TestPlayerTypes(t *testing.T) {
log.Errorf("TestPlayerTypes: flavor is %s", env.Flavor)

enableJSONColumnTesting := true
flavor := strings.ToLower(env.Flavor)
if strings.Contains(flavor, "percona") || strings.Contains(flavor, "mariadb") {
enableJSONColumnTesting = false
}
defer deleteTablet(addTablet(100))

execStatements(t, []string{
Expand Down Expand Up @@ -1303,7 +1307,7 @@ func TestPlayerTypes(t *testing.T) {
"drop table binary_pk",
fmt.Sprintf("drop table %s.binary_pk", vrepldb),
})
if strings.Contains(env.Flavor, "mysql57") {
if enableJSONColumnTesting {
execStatements(t, []string{
"create table vitess_json(id int auto_increment, val1 json, val2 json, val3 json, val4 json, val5 json, primary key(id))",
fmt.Sprintf("create table %s.vitess_json(id int, val1 json, val2 json, val3 json, val4 json, val5 json, primary key(id))", vrepldb),
Expand Down Expand Up @@ -1386,8 +1390,7 @@ func TestPlayerTypes(t *testing.T) {
{"a\x00\x00\x00", "bbb"},
},
}}

if strings.Contains(env.Flavor, "mysql57") {
if enableJSONColumnTesting {
testcases = append(testcases, testcase{
input: "insert into vitess_json(val1,val2,val3,val4,val5) values (null,'{}','123','{\"a\":[42,100]}', '{\"foo\":\"bar\"}')",
output: "insert into vitess_json(id,val1,val2,val3,val4,val5) values (1," +
Expand All @@ -1398,6 +1401,14 @@ func TestPlayerTypes(t *testing.T) {
{"1", "", "{}", "123", `{"a": [42, 100]}`, `{"foo": "bar"}`},
},
})
testcases = append(testcases, testcase{
input: "update vitess_json set val4 = '{\"a\": [98, 123]}', val5 = convert(x'7b7d' using utf8mb4)",
output: "update vitess_json set val1=convert(null using utf8mb4), val2=convert('{}' using utf8mb4), val3=convert('123' using utf8mb4), val4=convert('{\\\"a\\\":[98,123]}' using utf8mb4), val5=convert('{}' using utf8mb4) where id=1",
table: "vitess_json",
data: [][]string{
{"1", "", "{}", "123", `{"a": [98, 123]}`, `{}`},
},
})
}

for _, tcases := range testcases {
Expand Down