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

Function buildTiDBTableSampleQuery

dumpling/export/dump.go:1015–1023  ·  view source on GitHub ↗
(pkFields []string, dbName, tblName string)

Source from the content-addressed store, hash-verified

1013}
1014
1015func buildTiDBTableSampleQuery(pkFields []string, dbName, tblName string) string {
1016 template := "SELECT %s FROM `%s`.`%s` TABLESAMPLE REGIONS() ORDER BY %s"
1017 quotaPk := make([]string, len(pkFields))
1018 for i, s := range pkFields {
1019 quotaPk[i] = fmt.Sprintf("`%s`", escapeString(s))
1020 }
1021 pks := strings.Join(quotaPk, ",")
1022 return fmt.Sprintf(template, pks, escapeString(dbName), escapeString(tblName), pks)
1023}
1024
1025func selectTiDBRowKeyFields(tctx *tcontext.Context, conn *BaseConn, meta TableMeta, checkPkFields func([]string, []string) error) (pkFields, pkColTypes []string, err error) {
1026 if meta.HasImplicitRowID() {

Callers 1

selectTiDBTableSampleFunction · 0.85

Calls 2

escapeStringFunction · 0.70
JoinMethod · 0.65

Tested by

no test coverage detected