Skip to content
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
4 changes: 2 additions & 2 deletions data/test/vtexplain/multi-output/deletesharded-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ delete from music_extra where id=1

1 ks_sharded/-40: begin
1 ks_sharded/-40: delete from music_extra where id in (1) /* vtgate:: keyspace_id:166b40b44aba4bd6 */
2 ks_sharded/-40: commit
1 ks_sharded/-40: commit

----------------------------------------------------------------------
delete from music_extra where id=1 and extra='abc'

1 ks_sharded/-40: begin
1 ks_sharded/-40: select id from music_extra where id = 1 and extra = 'abc' limit 10001 for update /* vtgate:: keyspace_id:166b40b44aba4bd6 */
1 ks_sharded/-40: delete from music_extra where id in (1) /* vtgate:: keyspace_id:166b40b44aba4bd6 */
2 ks_sharded/-40: commit
1 ks_sharded/-40: commit

----------------------------------------------------------------------
delete from user where id=1
Expand Down
10 changes: 5 additions & 5 deletions data/test/vtexplain/multi-output/unsharded-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ insert into t1 (id,intval,floatval) values (1,2,3.14)

1 ks_unsharded/-: begin
1 ks_unsharded/-: insert into t1(id, intval, floatval) values (1, 2, 3.14)
2 ks_unsharded/-: commit
1 ks_unsharded/-: commit

----------------------------------------------------------------------
update t1 set intval = 10

1 ks_unsharded/-: begin
1 ks_unsharded/-: select id from t1 limit 10001 for update
1 ks_unsharded/-: update t1 set intval = 10 where id in (1)
2 ks_unsharded/-: commit
1 ks_unsharded/-: commit

----------------------------------------------------------------------
update t1 set floatval = 9.99

1 ks_unsharded/-: begin
1 ks_unsharded/-: select id from t1 limit 10001 for update
1 ks_unsharded/-: update t1 set floatval = 9.99 where id in (1)
2 ks_unsharded/-: commit
1 ks_unsharded/-: commit

----------------------------------------------------------------------
delete from t1 where id = 100

1 ks_unsharded/-: begin
1 ks_unsharded/-: delete from t1 where id in (100)
2 ks_unsharded/-: commit
1 ks_unsharded/-: commit

----------------------------------------------------------------------
insert into t1 (id,intval,floatval) values (1,2,3.14) on duplicate key update intval=3, floatval=3.14

1 ks_unsharded/-: begin
1 ks_unsharded/-: insert into t1(id, intval, floatval) values (1, 2, 3.14) on duplicate key update intval = 3, floatval = 3.14
2 ks_unsharded/-: commit
1 ks_unsharded/-: commit

----------------------------------------------------------------------
4 changes: 2 additions & 2 deletions data/test/vtexplain/multi-output/updatesharded-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ update user set nickname='alice' where id=1

1 ks_sharded/-40: begin
1 ks_sharded/-40: update user set nickname = 'alice' where id in (1) /* vtgate:: keyspace_id:166b40b44aba4bd6 */
2 ks_sharded/-40: commit
1 ks_sharded/-40: commit

----------------------------------------------------------------------
update user set nickname='alice' where name='alice'
Expand All @@ -21,7 +21,7 @@ update user set pet='fido' where id=1

1 ks_sharded/-40: begin
1 ks_sharded/-40: update user set pet = 'fido' where id in (1) /* vtgate:: keyspace_id:166b40b44aba4bd6 */
2 ks_sharded/-40: commit
1 ks_sharded/-40: commit

----------------------------------------------------------------------
update user set name='alicia' where id=1
Expand Down
20 changes: 20 additions & 0 deletions go/vt/vtexplain/vtexplain_vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,26 @@ func (t *explainTablet) ReadTransaction(ctx context.Context, target *querypb.Tar
return t.tsv.ReadTransaction(ctx, target, dtid)
}

// ExecuteBatch is part of the QueryService interface.
func (t *explainTablet) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []*querypb.BoundQuery, asTransaction bool, transactionID int64, options *querypb.ExecuteOptions) ([]sqltypes.Result, error) {
t.mu.Lock()
t.currentTime = batchTime.Wait()

// Since the query is simulated being "sent" over the wire we need to
// copy the bindVars into the executor to avoid a data race.
for _, query := range queries {
bindVariables := sqltypes.CopyBindVariables(query.BindVariables)
t.tabletQueries = append(t.tabletQueries, &TabletQuery{
Time: t.currentTime,
SQL: query.Sql,
BindVars: bindVariables,
})
}
t.mu.Unlock()

return t.tsv.ExecuteBatch(ctx, target, queries, asTransaction, transactionID, options)
}

// BeginExecute is part of the QueryService interface.
func (t *explainTablet) BeginExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, options *querypb.ExecuteOptions) (*sqltypes.Result, int64, error) {
t.mu.Lock()
Expand Down
Loading