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

Function ShowCreateTable

dumpling/export/sql.go:89–102  ·  view source on GitHub ↗

ShowCreateTable constructs the create table SQL for a specified table returns (createTableSQL, error)

(tctx *tcontext.Context, db *BaseConn, database, table string)

Source from the content-addressed store, hash-verified

87// ShowCreateTable constructs the create table SQL for a specified table
88// returns (createTableSQL, error)
89func ShowCreateTable(tctx *tcontext.Context, db *BaseConn, database, table string) (string, error) {
90 var oneRow [2]string
91 handleOneRow := func(rows *sql.Rows) error {
92 return rows.Scan(&oneRow[0], &oneRow[1])
93 }
94 query := fmt.Sprintf("SHOW CREATE TABLE `%s`.`%s`", escapeString(database), escapeString(table))
95 err := db.QuerySQL(tctx, handleOneRow, func() {
96 oneRow[0], oneRow[1] = "", ""
97 }, query)
98 if err != nil {
99 return "", err
100 }
101 return oneRow[1], nil
102}
103
104// ShowCreatePlacementPolicy constructs the create policy SQL for a specified table
105// returns (createPolicySQL, error)

Callers 1

dumpTableMetaFunction · 0.85

Calls 3

QuerySQLMethod · 0.80
escapeStringFunction · 0.70
ScanMethod · 0.65

Tested by

no test coverage detected