@@ -73,7 +73,7 @@ func TestBindingLastUpdateTime(t *testing.T) {
73
73
stmt , err := parser .New ().ParseOneStmt ("select * from test . t0" , "" , "" )
74
74
require .NoError (t , err )
75
75
76
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
76
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
77
77
binding , matched := bindHandle .MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
78
78
require .True (t , matched )
79
79
updateTime := binding .UpdateTime .String ()
@@ -139,7 +139,7 @@ func TestBindParse(t *testing.T) {
139
139
140
140
stmt , err := parser .New ().ParseOneStmt ("select * from test . t" , "" , "" )
141
141
require .NoError (t , err )
142
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
142
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
143
143
binding , matched := bindHandle .MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
144
144
require .True (t , matched )
145
145
require .Equal (t , "select * from `test` . `t`" , binding .OriginalSQL )
@@ -435,7 +435,7 @@ func TestGlobalBinding(t *testing.T) {
435
435
436
436
stmt , _ , _ := utilNormalizeWithDefaultDB (t , testSQL .querySQL )
437
437
438
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
438
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
439
439
binding , matched := dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
440
440
require .True (t , matched )
441
441
require .Equal (t , testSQL .originSQL , binding .OriginalSQL )
@@ -468,7 +468,7 @@ func TestGlobalBinding(t *testing.T) {
468
468
require .NoError (t , err )
469
469
require .Equal (t , 1 , len (bindHandle .GetAllGlobalBindings ()))
470
470
471
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
471
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
472
472
binding , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
473
473
require .True (t , matched )
474
474
require .Equal (t , testSQL .originSQL , binding .OriginalSQL )
@@ -483,15 +483,15 @@ func TestGlobalBinding(t *testing.T) {
483
483
_ , err = tk .Exec ("drop global " + testSQL .dropSQL )
484
484
require .Equal (t , uint64 (1 ), tk .Session ().AffectedRows ())
485
485
require .NoError (t , err )
486
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
486
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
487
487
_ , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
488
488
require .False (t , matched ) // dropped
489
489
bindHandle = bindinfo .NewGlobalBindingHandle (& mockSessionPool {tk .Session ()})
490
490
err = bindHandle .LoadFromStorageToCache (true )
491
491
require .NoError (t , err )
492
492
require .Equal (t , 0 , len (bindHandle .GetAllGlobalBindings ()))
493
493
494
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
494
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
495
495
_ , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
496
496
require .False (t , matched ) // dropped
497
497
@@ -679,7 +679,7 @@ func TestNormalizeStmtForBinding(t *testing.T) {
679
679
}
680
680
for _ , test := range tests {
681
681
stmt , _ , _ := utilNormalizeWithDefaultDB (t , test .sql )
682
- n , digest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
682
+ n , digest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
683
683
require .Equal (t , test .normalized , n )
684
684
require .Equal (t , test .digest , digest )
685
685
}
@@ -696,39 +696,39 @@ func TestHintsSetID(t *testing.T) {
696
696
// Verify the added Binding contains ID with restored query block.
697
697
stmt , err := parser .New ().ParseOneStmt ("select * from t where a > ?" , "" , "" )
698
698
require .NoError (t , err )
699
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
699
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
700
700
binding , matched := dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
701
701
require .True (t , matched )
702
702
require .Equal (t , "select * from `test` . `t` where `a` > ?" , binding .OriginalSQL )
703
703
require .Equal (t , "use_index(@`sel_1` `test`.`t` `idx_a`)" , binding .ID )
704
704
705
705
utilCleanBindingEnv (tk )
706
706
tk .MustExec ("create global binding for select * from t where a > 10 using select /*+ use_index(t, idx_a) */ * from t where a > 10" )
707
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
707
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
708
708
binding , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
709
709
require .True (t , matched )
710
710
require .Equal (t , "select * from `test` . `t` where `a` > ?" , binding .OriginalSQL )
711
711
require .Equal (t , "use_index(@`sel_1` `test`.`t` `idx_a`)" , binding .ID )
712
712
713
713
utilCleanBindingEnv (tk )
714
714
tk .MustExec ("create global binding for select * from t where a > 10 using select /*+ use_index(@sel_1 t, idx_a) */ * from t where a > 10" )
715
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
715
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
716
716
binding , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
717
717
require .True (t , matched )
718
718
require .Equal (t , "select * from `test` . `t` where `a` > ?" , binding .OriginalSQL )
719
719
require .Equal (t , "use_index(@`sel_1` `test`.`t` `idx_a`)" , binding .ID )
720
720
721
721
utilCleanBindingEnv (tk )
722
722
tk .MustExec ("create global binding for select * from t where a > 10 using select /*+ use_index(@qb1 t, idx_a) qb_name(qb1) */ * from t where a > 10" )
723
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
723
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
724
724
binding , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
725
725
require .True (t , matched )
726
726
require .Equal (t , "select * from `test` . `t` where `a` > ?" , binding .OriginalSQL )
727
727
require .Equal (t , "use_index(@`sel_1` `test`.`t` `idx_a`)" , binding .ID )
728
728
729
729
utilCleanBindingEnv (tk )
730
730
tk .MustExec ("create global binding for select * from t where a > 10 using select /*+ use_index(T, IDX_A) */ * from t where a > 10" )
731
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
731
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
732
732
binding , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
733
733
require .True (t , matched )
734
734
require .Equal (t , "select * from `test` . `t` where `a` > ?" , binding .OriginalSQL )
@@ -738,7 +738,7 @@ func TestHintsSetID(t *testing.T) {
738
738
err = tk .ExecToErr ("create global binding for select * from t using select /*+ non_exist_hint() */ * from t" )
739
739
require .True (t , terror .ErrorEqual (err , parser .ErrParse ))
740
740
tk .MustExec ("create global binding for select * from t where a > 10 using select * from t where a > 10" )
741
- _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
741
+ _ , noDBDigest = bindinfo .NormalizeStmtForBinding (stmt , "" , true )
742
742
binding , matched = dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
743
743
require .True (t , matched )
744
744
require .Equal (t , "select * from `test` . `t` where `a` > ?" , binding .OriginalSQL )
@@ -761,7 +761,7 @@ func TestErrorBind(t *testing.T) {
761
761
762
762
stmt , err := parser .New ().ParseOneStmt ("select * from test . t where i > ?" , "" , "" )
763
763
require .NoError (t , err )
764
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
764
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
765
765
binding , matched := dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
766
766
require .True (t , matched )
767
767
require .Equal (t , "select * from `test` . `t` where `i` > ?" , binding .OriginalSQL )
@@ -801,7 +801,7 @@ func TestBestPlanInBaselines(t *testing.T) {
801
801
802
802
stmt , _ , _ := utilNormalizeWithDefaultDB (t , "select a, b from t where a = 1 limit 0, 1" )
803
803
804
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
804
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
805
805
binding , matched := dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
806
806
require .True (t , matched )
807
807
require .Equal (t , "select `a` , `b` from `test` . `t` where `a` = ? limit ..." , binding .OriginalSQL )
@@ -844,7 +844,7 @@ func TestBindingSymbolList(t *testing.T) {
844
844
stmt , err := parser .New ().ParseOneStmt ("select a, b from test . t where a = 1 limit 0, 1" , "" , "" )
845
845
require .NoError (t , err )
846
846
847
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
847
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
848
848
binding , matched := dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
849
849
require .True (t , matched )
850
850
require .Equal (t , "select `a` , `b` from `test` . `t` where `a` = ? limit ..." , binding .OriginalSQL )
@@ -889,7 +889,7 @@ func TestBindingInListWithSingleLiteral(t *testing.T) {
889
889
stmt , err := parser .New ().ParseOneStmt ("select a, b from test . t where a in (1)" , "" , "" )
890
890
require .NoError (t , err )
891
891
892
- _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , bindinfo . WithoutDB ( true ) )
892
+ _ , noDBDigest := bindinfo .NormalizeStmtForBinding (stmt , "" , true )
893
893
binding , matched := dom .BindHandle ().MatchGlobalBinding (tk .Session (), noDBDigest , bindinfo .CollectTableNames (stmt ))
894
894
require .True (t , matched )
895
895
require .Equal (t , "select `a` , `b` from `test` . `t` where `a` in ( ... )" , binding .OriginalSQL )
0 commit comments