Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: wangweicugw <wangweicugw@163.com>
  • Loading branch information
wangweicugw committed Mar 12, 2024
1 parent ca2609f commit 4b18193
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions go/vt/vtgate/autocommit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ func TestAutocommitDeleteIn(t *testing.T) {
require.NoError(t, err)

assertQueries(t, sbc1, []*querypb.BoundQuery{{
Sql: "delete from user_extra where user_id in (1, 2)",
BindVariables: map[string]*querypb.BindVariable{},
Sql: "delete from user_extra where user_id in ::__vals",
BindVariables: map[string]*querypb.BindVariable{
"__vals": sqltypes.TestBindVariable([]any{int64(1), int64(2)}),
},
}})
testCommitCount(t, "sbc1", sbc1, 0)

Expand Down Expand Up @@ -391,11 +393,12 @@ func TestAutocommitTransactionStarted(t *testing.T) {

// multi shard query - savepoint needed
sql = "update `user` set a = 2 where id in (1, 4)"
expectedSql := "update `user` set a = 2 where id in ::__vals"
_, err = executor.Execute(context.Background(), nil, "TestExecute", NewSafeSession(session), sql, map[string]*querypb.BindVariable{})
require.NoError(t, err)
require.Len(t, sbc1.Queries, 2)
require.Contains(t, sbc1.Queries[0].Sql, "savepoint")
require.Equal(t, sql, sbc1.Queries[1].Sql)
require.Equal(t, expectedSql, sbc1.Queries[1].Sql)
testCommitCount(t, "sbc1", sbc1, 0)
}

Expand Down
14 changes: 9 additions & 5 deletions go/vt/vtgate/executor_dml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,10 @@ func TestUpdateUseHigherCostVindexIfBackfilling(t *testing.T) {
Sql: "select id, wo_lu_col, erl_lu_col, srl_lu_col, nrl_lu_col, nv_lu_col, lu_col, lu_col = 5 from t2_lookup where wo_lu_col = 2 and lu_col in (1, 2) for update",
BindVariables: map[string]*querypb.BindVariable{},
}, {
Sql: "update t2_lookup set lu_col = 5 where wo_lu_col = 2 and lu_col in (1, 2)",
BindVariables: map[string]*querypb.BindVariable{},
Sql: "update t2_lookup set lu_col = 5 where wo_lu_col = 2 and lu_col in ::__vals",
BindVariables: map[string]*querypb.BindVariable{
"__vals": sqltypes.TestBindVariable([]any{int64(1), int64(2)}),
},
}}

vars, _ := sqltypes.BuildBindVariable([]any{
Expand Down Expand Up @@ -1109,8 +1111,10 @@ func TestDeleteUseHigherCostVindexIfBackfilling(t *testing.T) {
Sql: "select id, wo_lu_col, erl_lu_col, srl_lu_col, nrl_lu_col, nv_lu_col, lu_col from t2_lookup where wo_lu_col = 1 and lu_col in (1, 2) for update",
BindVariables: map[string]*querypb.BindVariable{},
}, {
Sql: "delete from t2_lookup where wo_lu_col = 1 and lu_col in (1, 2)",
BindVariables: map[string]*querypb.BindVariable{},
Sql: "delete from t2_lookup where wo_lu_col = 1 and lu_col in ::__vals",
BindVariables: map[string]*querypb.BindVariable{
"__vals": sqltypes.TestBindVariable([]any{int64(1), int64(2)}),
},
}}

vars, _ := sqltypes.BuildBindVariable([]any{
Expand Down Expand Up @@ -3042,7 +3046,7 @@ func TestDeleteMultiTable(t *testing.T) {
{Sql: "select `user`.id, `user`.col from `user`", BindVariables: map[string]*querypb.BindVariable{}},
bq, bq, bq, bq, bq, bq, bq, bq,
{Sql: "select `user`.Id, `user`.`name` from `user` where `user`.id in ::dml_vals for update", BindVariables: map[string]*querypb.BindVariable{"dml_vals": {Type: querypb.Type_TUPLE, Values: dmlVals}}},
{Sql: "delete from `user` where `user`.id in ::dml_vals", BindVariables: map[string]*querypb.BindVariable{"dml_vals": {Type: querypb.Type_TUPLE, Values: dmlVals}}}}
{Sql: "delete from `user` where `user`.id in ::dml_vals", BindVariables: map[string]*querypb.BindVariable{"__vals": sqltypes.TestBindVariable([]any{int64(1), int64(1), int64(1), int64(1), int64(1), int64(1), int64(1), int64(1)}), "dml_vals": {Type: querypb.Type_TUPLE, Values: dmlVals}}}}
assertQueries(t, sbc1, wantQueries)

wantQueries = []*querypb.BoundQuery{
Expand Down

0 comments on commit 4b18193

Please sign in to comment.