MCPcopy Create free account
hub / github.com/pingcap/tidb / TestScanQueryGenerator

Function TestScanQueryGenerator

pkg/ttl/sqlbuilder/sql_test.go:581–863  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

579}
580
581func TestScanQueryGenerator(t *testing.T) {
582 t1 := &cache.PhysicalTable{
583 Schema: pmodel.NewCIStr("test"),
584 TableInfo: &model.TableInfo{
585 Name: pmodel.NewCIStr("t1"),
586 },
587 KeyColumns: []*model.ColumnInfo{
588 {Name: pmodel.NewCIStr("id"), FieldType: *types.NewFieldType(mysql.TypeInt24)},
589 },
590 TimeColumn: &model.ColumnInfo{
591 Name: pmodel.NewCIStr("time"),
592 FieldType: *types.NewFieldType(mysql.TypeDatetime),
593 },
594 }
595
596 t2 := &cache.PhysicalTable{
597 Schema: pmodel.NewCIStr("test2"),
598 TableInfo: &model.TableInfo{
599 Name: pmodel.NewCIStr("t2"),
600 },
601 KeyColumns: []*model.ColumnInfo{
602 {Name: pmodel.NewCIStr("a"), FieldType: *types.NewFieldType(mysql.TypeInt24)},
603 {Name: pmodel.NewCIStr("b"), FieldType: *types.NewFieldType(mysql.TypeVarchar)},
604 {Name: pmodel.NewCIStr("c"), FieldType: types.NewFieldTypeBuilder().SetType(mysql.TypeString).SetFlag(mysql.BinaryFlag).Build()},
605 },
606 TimeColumn: &model.ColumnInfo{
607 Name: pmodel.NewCIStr("time"),
608 FieldType: *types.NewFieldType(mysql.TypeDatetime),
609 },
610 }
611
612 result := func(last []types.Datum, n int) [][]types.Datum {
613 ds := make([][]types.Datum, n)
614 ds[n-1] = last
615 return ds
616 }
617
618 cases := []struct {
619 tbl *cache.PhysicalTable
620 expire time.Time
621 rangeStart []types.Datum
622 rangeEnd []types.Datum
623 path [][]any
624 }{
625 {
626 tbl: t1,
627 expire: time.UnixMilli(0).In(time.UTC),
628 path: [][]any{
629 {
630 nil, 3,
631 "SELECT LOW_PRIORITY SQL_NO_CACHE `id` FROM `test`.`t1` WHERE `time` < FROM_UNIXTIME(0) ORDER BY `id` ASC LIMIT 3",
632 },
633 {
634 nil, 5, "",
635 },
636 },
637 },
638 {

Callers

nothing calls this directly

Calls 12

NextSQLMethod · 0.95
IsExhaustedMethod · 0.95
NewFieldTypeFunction · 0.92
NewFieldTypeBuilderFunction · 0.92
NewScanQueryGeneratorFunction · 0.92
dFunction · 0.85
SetFlagMethod · 0.65
SetTypeMethod · 0.65
InMethod · 0.65
EqualMethod · 0.65
resultStruct · 0.50
BuildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…