зеркало из https://github.com/github/vitess-gh.git
handle cache key types (#11369)
Signed-off-by: Harshit Gangal <harshit@planetscale.com> Signed-off-by: Harshit Gangal <harshit@planetscale.com>
This commit is contained in:
Родитель
c3f414b687
Коммит
8b1cce4701
|
@ -421,3 +421,26 @@ func TestInfiniteSessions(t *testing.T) {
|
|||
client.Commit())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetQueriesMultipleWays(t *testing.T) {
|
||||
client := framework.NewClient()
|
||||
defer client.Release()
|
||||
_, err := client.ReserveExecute("select 1", []string{"set sql_safe_updates = 1"}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = client.Execute("set sql_safe_updates = 1", nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
framework.Server.Config().EnableSettingsPool = true
|
||||
defer func() {
|
||||
framework.Server.Config().EnableSettingsPool = false
|
||||
}()
|
||||
|
||||
client2 := framework.NewClient()
|
||||
_, err = client2.ReserveExecute("select 1", []string{"set sql_safe_updates = 1"}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
// this should not panic.
|
||||
_, err = client.Execute("set sql_safe_updates = 1", nil)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
|
|
@ -436,15 +436,25 @@ func (qe *QueryEngine) schemaChanged(tables map[string]*schema.Table, created, a
|
|||
|
||||
// getQuery fetches the plan and makes it the most recent.
|
||||
func (qe *QueryEngine) getQuery(sql string) *TabletPlan {
|
||||
if cacheResult, ok := qe.plans.Get(sql); ok {
|
||||
return cacheResult.(*TabletPlan)
|
||||
cacheResult, ok := qe.plans.Get(sql)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
plan, ok := cacheResult.(*TabletPlan)
|
||||
if ok {
|
||||
return plan
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (qe *QueryEngine) getConnSetting(key string) *pools.Setting {
|
||||
if cacheResult, ok := qe.plans.Get(key); ok {
|
||||
return cacheResult.(*pools.Setting)
|
||||
cacheResult, ok := qe.plans.Get(key)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
plan, ok := cacheResult.(*pools.Setting)
|
||||
if ok {
|
||||
return plan
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче