MCPcopy
hub / github.com/pingcap/tidb / TestBuildTableSampleQueries

Function TestBuildTableSampleQueries

dumpling/export/sql_test.go:525–842  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

523}
524
525func TestBuildTableSampleQueries(t *testing.T) {
526 db, mock, err := sqlmock.New()
527 require.NoError(t, err)
528 defer func() {
529 require.NoError(t, db.Close())
530 }()
531
532 conn, err := db.Conn(context.Background())
533 require.NoError(t, err)
534 baseConn := newBaseConn(conn, true, nil)
535 tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel()
536 metrics := newMetrics(promutil.NewDefaultFactory(), nil)
537
538 d := &Dumper{
539 tctx: tctx,
540 conf: DefaultConfig(),
541 cancelCtx: cancel,
542 metrics: metrics,
543 selectTiDBTableRegionFunc: selectTiDBTableRegion,
544 }
545 d.conf.ServerInfo = version.ServerInfo{
546 HasTiKV: true,
547 ServerType: version.ServerTypeTiDB,
548 ServerVersion: tableSampleVersion,
549 }
550
551 testCases := []struct {
552 handleColNames []string
553 handleColTypes []string
554 handleVals [][]driver.Value
555 expectedWhereClauses []string
556 hasTiDBRowID bool
557 }{
558 {
559 []string{},
560 []string{},
561 [][]driver.Value{},
562 nil,
563 false,
564 },
565 {
566 []string{"a"},
567 []string{"BIGINT"},
568 [][]driver.Value{{1}},
569 []string{"`a`<1", "`a`>=1"},
570 false,
571 },
572 // check whether dumpling can turn to dump whole table
573 {
574 []string{"a"},
575 []string{"BIGINT"},
576 [][]driver.Value{},
577 nil,
578 false,
579 },
580 // check whether dumpling can turn to dump whole table
581 {
582 []string{"_tidb_rowid"},

Callers

nothing calls this directly

Calls 15

concurrentDumpTableMethod · 0.95
BackgroundFunction · 0.92
NewDefaultFactoryFunction · 0.92
newBaseConnFunction · 0.85
newMetricsFunction · 0.85
buildWhereClausesFunction · 0.85
wrapBackTicksFunction · 0.85
buildOrderByClauseStringFunction · 0.85
buildSelectQueryFunction · 0.85
buildWhereConditionFunction · 0.85
WithCancelMethod · 0.80
WithLoggerMethod · 0.80

Tested by

no test coverage detected