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

Method Build

pkg/ttl/sqlbuilder/sql.go:95–110  ·  view source on GitHub ↗

Build builds the final sql

()

Source from the content-addressed store, hash-verified

93
94// Build builds the final sql
95func (b *SQLBuilder) Build() (string, error) {
96 if b.state == writeBegin {
97 return "", errors.Errorf("invalid state: %v", b.state)
98 }
99
100 if !b.isReadOnly && !b.hasWriteExpireCond {
101 // check whether the `timeRow < expire_time` condition has been written to make sure this SQL is safe.
102 return "", errors.New("expire condition not write")
103 }
104
105 if b.state != writeDone {
106 b.state = writeDone
107 }
108
109 return b.sb.String(), nil
110}
111
112// WriteSelect writes a select statement to select key columns without any condition
113func (b *SQLBuilder) WriteSelect() error {

Callers 6

buildSQLMethod · 0.95
BuildDeleteSQLFunction · 0.95
TestEscapeFunction · 0.95
TestSQLBuilderFunction · 0.95
TestScanQueryGeneratorFunction · 0.45
ResumeMethod · 0.45

Calls 3

ErrorfMethod · 0.65
NewMethod · 0.65
StringMethod · 0.65

Tested by 3

TestEscapeFunction · 0.76
TestSQLBuilderFunction · 0.76
TestScanQueryGeneratorFunction · 0.36