MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / AsConstantInt

Method AsConstantInt

pkg/sql/sem/tree/constant.go:245–252  ·  view source on GitHub ↗

AsConstantInt returns the value as an constant.Int if possible, along with a flag indicating whether the conversion was possible. The result contains the proper sign as per expr.negative.

()

Source from the content-addressed store, hash-verified

243// with a flag indicating whether the conversion was possible.
244// The result contains the proper sign as per expr.negative.
245func (expr *NumVal) AsConstantInt() (constant.Value, bool) {
246 v := expr.AsConstantValue()
247 intVal := constant.ToInt(v)
248 if intVal.Kind() == constant.Int {
249 return intVal, true
250 }
251 return nil, false
252}
253
254var (
255 intLikeTypes = []*types.T{types.Int, types.Oid}

Callers 3

AsInt64Method · 0.95
AsInt32Method · 0.95
VisitPostMethod · 0.80

Calls 2

AsConstantValueMethod · 0.95
KindMethod · 0.80

Tested by

no test coverage detected