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

Method WriteExpireCondition

pkg/ttl/sqlbuilder/sql.go:171–189  ·  view source on GitHub ↗

WriteExpireCondition writes a condition with the time column

(expire time.Time)

Source from the content-addressed store, hash-verified

169
170// WriteExpireCondition writes a condition with the time column
171func (b *SQLBuilder) WriteExpireCondition(expire time.Time) error {
172 switch b.state {
173 case writeSelOrDel:
174 b.restoreCtx.WritePlain(" WHERE ")
175 b.state = writeWhere
176 case writeWhere:
177 b.restoreCtx.WritePlain(" AND ")
178 default:
179 return errors.Errorf("invalid state: %v", b.state)
180 }
181
182 b.writeColNames([]*model.ColumnInfo{b.tbl.TimeColumn}, false)
183 b.restoreCtx.WritePlain(" < ")
184 b.restoreCtx.WritePlain("FROM_UNIXTIME(")
185 b.restoreCtx.WritePlain(strconv.FormatInt(expire.Unix(), 10))
186 b.restoreCtx.WritePlain(")")
187 b.hasWriteExpireCond = true
188 return nil
189}
190
191// WriteInCondition writes an IN condition
192func (b *SQLBuilder) WriteInCondition(cols []*model.ColumnInfo, dps ...[]types.Datum) error {

Callers 4

buildSQLMethod · 0.95
BuildDeleteSQLFunction · 0.95
TestEscapeFunction · 0.95
TestSQLBuilderFunction · 0.95

Calls 3

writeColNamesMethod · 0.95
WritePlainMethod · 0.80
ErrorfMethod · 0.65

Tested by 2

TestEscapeFunction · 0.76
TestSQLBuilderFunction · 0.76