(t *testing.T)
| 863 | } |
| 864 | |
| 865 | func TestBuildDeleteSQL(t *testing.T) { |
| 866 | t1 := &cache.PhysicalTable{ |
| 867 | Schema: pmodel.NewCIStr("test"), |
| 868 | TableInfo: &model.TableInfo{ |
| 869 | Name: pmodel.NewCIStr("t1"), |
| 870 | }, |
| 871 | KeyColumns: []*model.ColumnInfo{ |
| 872 | {Name: pmodel.NewCIStr("id"), FieldType: *types.NewFieldType(mysql.TypeInt24)}, |
| 873 | }, |
| 874 | TimeColumn: &model.ColumnInfo{ |
| 875 | Name: pmodel.NewCIStr("time"), |
| 876 | FieldType: *types.NewFieldType(mysql.TypeDatetime), |
| 877 | }, |
| 878 | } |
| 879 | |
| 880 | t2 := &cache.PhysicalTable{ |
| 881 | Schema: pmodel.NewCIStr("test2"), |
| 882 | TableInfo: &model.TableInfo{ |
| 883 | Name: pmodel.NewCIStr("t2"), |
| 884 | }, |
| 885 | KeyColumns: []*model.ColumnInfo{ |
| 886 | {Name: pmodel.NewCIStr("a"), FieldType: *types.NewFieldType(mysql.TypeInt24)}, |
| 887 | {Name: pmodel.NewCIStr("b"), FieldType: *types.NewFieldType(mysql.TypeVarchar)}, |
| 888 | }, |
| 889 | TimeColumn: &model.ColumnInfo{ |
| 890 | Name: pmodel.NewCIStr("time"), |
| 891 | FieldType: *types.NewFieldType(mysql.TypeDatetime), |
| 892 | }, |
| 893 | } |
| 894 | |
| 895 | cases := []struct { |
| 896 | tbl *cache.PhysicalTable |
| 897 | expire time.Time |
| 898 | rows [][]types.Datum |
| 899 | sql string |
| 900 | }{ |
| 901 | { |
| 902 | tbl: t1, |
| 903 | expire: time.UnixMilli(0).In(time.UTC), |
| 904 | rows: [][]types.Datum{d(1)}, |
| 905 | sql: "DELETE LOW_PRIORITY FROM `test`.`t1` WHERE `id` IN (1) AND `time` < FROM_UNIXTIME(0) LIMIT 1", |
| 906 | }, |
| 907 | { |
| 908 | tbl: t1, |
| 909 | expire: time.UnixMilli(0).In(time.UTC), |
| 910 | rows: [][]types.Datum{d(2), d(3), d(4)}, |
| 911 | sql: "DELETE LOW_PRIORITY FROM `test`.`t1` WHERE `id` IN (2, 3, 4) AND `time` < FROM_UNIXTIME(0) LIMIT 3", |
| 912 | }, |
| 913 | { |
| 914 | tbl: t2, |
| 915 | expire: time.UnixMilli(0).In(time.UTC), |
| 916 | rows: [][]types.Datum{d(1, "a")}, |
| 917 | sql: "DELETE LOW_PRIORITY FROM `test2`.`t2` WHERE (`a`, `b`) IN ((1, 'a')) AND `time` < FROM_UNIXTIME(0) LIMIT 1", |
| 918 | }, |
| 919 | { |
| 920 | tbl: t2, |
| 921 | expire: time.UnixMilli(0).In(time.UTC), |
| 922 | rows: [][]types.Datum{d(1, "a"), d(2, "b")}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…