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

Mask database name #6791

Merged
merged 12 commits into from
Oct 5, 2020
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletserver/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func init() {
}

func BenchmarkExecuteVarBinary(b *testing.B) {
db, tsv := setupTabletServerTest(nil)
db, tsv := setupTabletServerTest(nil, "")
defer db.Close()
defer tsv.StopService()

Expand All @@ -77,7 +77,7 @@ func BenchmarkExecuteVarBinary(b *testing.B) {
}

func BenchmarkExecuteExpression(b *testing.B) {
db, tsv := setupTabletServerTest(nil)
db, tsv := setupTabletServerTest(nil, "")
defer db.Close()
defer tsv.StopService()

Expand Down
22 changes: 21 additions & 1 deletion go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,15 @@ func (tsv *TabletServer) Execute(ctx context.Context, target *querypb.Target, sq
return err
}
result = result.StripMetadata(sqltypes.IncludeFieldsOrDefault(options))

// Change database name in mysql output to the keyspace name
if sqltypes.IncludeFieldsOrDefault(options) == querypb.ExecuteOptions_ALL {
for _, f := range result.Fields {
if f.Database != "" {
f.Database = tsv.sm.target.Keyspace
}
}
}
return nil
},
)
Expand Down Expand Up @@ -678,7 +687,18 @@ func (tsv *TabletServer) StreamExecute(ctx context.Context, target *querypb.Targ
logStats: logStats,
tsv: tsv,
}
return qre.Stream(callback)
newCallback := func(result *sqltypes.Result) error {
if sqltypes.IncludeFieldsOrDefault(options) == querypb.ExecuteOptions_ALL {
// Change database name in mysql output to the keyspace name
for _, f := range result.Fields {
if f.Database != "" {
f.Database = tsv.sm.target.Keyspace
}
}
}
return callback(result)
}
return qre.Stream(newCallback)
},
)
}
Expand Down
Loading