@@ -6404,6 +6404,34 @@ func TestDMLCheckSelectRows(t *testing.T) {
64046404 WillReturnRows (sqlmock .NewRows ([]string {"count(*)" }).AddRow ("10" ))
64056405 runSingleRuleInspectCase (rule , t , "" , inspect10 , "select id, v1 as id from exist_tb_2 group by id, v1" , newTestResult ())
64066406
6407+ inspect11 := NewMockInspect (e )
6408+ handler .ExpectQuery (regexp .QuoteMeta ("select max(v1) from exist_tb_2 group by id" )).
6409+ WillReturnRows (sqlmock .NewRows ([]string {"type" }).AddRow (executor .ExplainRecordAccessTypeIndex ).AddRow ("range" ))
6410+ handler .ExpectQuery (regexp .QuoteMeta ("select count(*) from (SELECT 1 FROM `exist_tb_2` GROUP BY `id`) as t" )).
6411+ WillReturnRows (sqlmock .NewRows ([]string {"count(*)" }).AddRow ("10" ))
6412+ runSingleRuleInspectCase (rule , t , "" , inspect11 , "select max(v1) from exist_tb_2 group by id" , newTestResult ())
6413+
6414+ inspect12 := NewMockInspect (e )
6415+ handler .ExpectQuery (regexp .QuoteMeta ("select max(v1) from exist_tb_2 group by id" )).
6416+ WillReturnRows (sqlmock .NewRows ([]string {"type" }).AddRow (executor .ExplainRecordAccessTypeIndex ).AddRow ("range" ))
6417+ handler .ExpectQuery (regexp .QuoteMeta ("select count(*) from (SELECT 1 FROM `exist_tb_2` GROUP BY `id`) as t" )).
6418+ WillReturnRows (sqlmock .NewRows ([]string {"count(*)" }).AddRow ("10000000" ))
6419+ runSingleRuleInspectCase (rule , t , "" , inspect12 , "select max(v1) from exist_tb_2 group by id" , newTestResult ().addResult (rulepkg .DMLCheckSelectRows ))
6420+
6421+ inspect13 := NewMockInspect (e )
6422+ handler .ExpectQuery (regexp .QuoteMeta ("select max(v1) as id, id from exist_tb_2 group by id" )).
6423+ WillReturnRows (sqlmock .NewRows ([]string {"type" }).AddRow (executor .ExplainRecordAccessTypeIndex ).AddRow ("range" ))
6424+ handler .ExpectQuery (regexp .QuoteMeta ("select count(*) from (SELECT 1 FROM `exist_tb_2` GROUP BY `id`) as t" )).
6425+ WillReturnRows (sqlmock .NewRows ([]string {"count(*)" }).AddRow ("10" ))
6426+ runSingleRuleInspectCase (rule , t , "" , inspect13 , "select max(v1) as id, id from exist_tb_2 group by id" , newTestResult ())
6427+
6428+ inspect14 := NewMockInspect (e )
6429+ handler .ExpectQuery (regexp .QuoteMeta ("select max(v1) as id, id from exist_tb_2 group by id" )).
6430+ WillReturnRows (sqlmock .NewRows ([]string {"type" }).AddRow (executor .ExplainRecordAccessTypeIndex ).AddRow ("range" ))
6431+ handler .ExpectQuery (regexp .QuoteMeta ("select count(*) from (SELECT 1 FROM `exist_tb_2` GROUP BY `id`) as t" )).
6432+ WillReturnRows (sqlmock .NewRows ([]string {"count(*)" }).AddRow ("10000000" ))
6433+ runSingleRuleInspectCase (rule , t , "" , inspect14 , "select max(v1) as id, id from exist_tb_2 group by id" , newTestResult ())
6434+
64076435}
64086436
64096437func TestDMLCheckScanRows (t * testing.T ) {
0 commit comments