Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Mar 11, 2024
1 parent 59f4112 commit e7b7b99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions pkg/bindinfo/capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ func TestBindingSource(t *testing.T) {
bindHandle := dom.BindHandle()
stmt, _, _ := internal.UtilNormalizeWithDefaultDB(t, "select * from t where a > ?")
_, fuzzyDigest := norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
binding, matched, isMissed := bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
binding, matched, warn := bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.True(t, matched)
require.False(t, isMissed)
require.NoError(t, warn)
require.Equal(t, "select * from `test` . `t` where `a` > ?", binding.OriginalSQL)
require.Equal(t, bindinfo.Manual, binding.Source)

Expand All @@ -351,9 +351,9 @@ func TestBindingSource(t *testing.T) {
bindHandle.CaptureBaselines()
stmt, _, _ = internal.UtilNormalizeWithDefaultDB(t, "select * from t where a < ?")
_, fuzzyDigest = norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
binding, matched, isMissed = bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
binding, matched, warn = bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.True(t, matched)
require.False(t, isMissed)
require.NoError(t, warn)
require.Equal(t, "select * from `test` . `t` where `a` < ?", binding.OriginalSQL)
require.Equal(t, bindinfo.Capture, binding.Source)
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/bindinfo/global_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func TestBindingLastUpdateTime(t *testing.T) {
require.NoError(t, err)

_, fuzzyDigest := norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
binding, matched, isMissed := bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
binding, matched, warn := bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.True(t, matched)
require.False(t, isMissed)
require.NoError(t, warn)
updateTime := binding.UpdateTime.String()

rows1 := tk.MustQuery("show status like 'last_plan_binding_update_time';").Rows()
Expand Down Expand Up @@ -140,9 +140,9 @@ func TestBindParse(t *testing.T) {
stmt, err := parser.New().ParseOneStmt("select * from test . t", "", "")
require.NoError(t, err)
_, fuzzyDigest := norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
binding, matched, isMissed := bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
binding, matched, warn := bindHandle.MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.True(t, matched)
require.False(t, isMissed)
require.NoError(t, warn)
require.Equal(t, "select * from `test` . `t`", binding.OriginalSQL)
require.Equal(t, "select * from `test` . `t` use index(index_t)", binding.BindSQL)
require.Equal(t, "test", binding.Db)
Expand Down Expand Up @@ -441,9 +441,9 @@ func TestGlobalBinding(t *testing.T) {
stmt, _, _ := internal.UtilNormalizeWithDefaultDB(t, testSQL.querySQL)

_, fuzzyDigest := norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
binding, matched, isMissed := dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
binding, matched, warn := dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.True(t, matched)
require.False(t, isMissed)
require.NoError(t, warn)
require.Equal(t, testSQL.originSQL, binding.OriginalSQL)
require.Equal(t, testSQL.bindSQL, binding.BindSQL)
require.Equal(t, "test", binding.Db)
Expand Down Expand Up @@ -475,9 +475,9 @@ func TestGlobalBinding(t *testing.T) {
require.Equal(t, 1, bindHandle.Size())

_, fuzzyDigest = norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
binding, matched, isMissed = dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
binding, matched, warn = dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.True(t, matched)
require.False(t, isMissed)
require.NoError(t, warn)
require.Equal(t, testSQL.originSQL, binding.OriginalSQL)
require.Equal(t, testSQL.bindSQL, binding.BindSQL)
require.Equal(t, "test", binding.Db)
Expand All @@ -491,18 +491,18 @@ func TestGlobalBinding(t *testing.T) {
require.Equal(t, uint64(1), tk.Session().AffectedRows())
require.NoError(t, err)
_, fuzzyDigest = norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
_, matched, isMissed = dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
_, matched, warn = dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.False(t, matched) // dropped
require.False(t, isMissed)
require.NoError(t, warn)
bindHandle = bindinfo.NewGlobalBindingHandle(&mockSessionPool{tk.Session()})
err = bindHandle.LoadFromStorageToCache(true)
require.NoError(t, err)
require.Equal(t, 0, bindHandle.Size())

_, fuzzyDigest = norm.NormalizeStmtForBinding(stmt, norm.WithFuzz(true))
_, matched, isMissed = dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
_, matched, warn = dom.BindHandle().MatchGlobalBinding(tk.Session(), fuzzyDigest, bindinfo.CollectTableNames(stmt))
require.False(t, matched) // dropped
require.False(t, isMissed)
require.NoError(t, warn)

rs, err = tk.Exec("show global bindings")
require.NoError(t, err)
Expand Down

0 comments on commit e7b7b99

Please sign in to comment.