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

Method AsInt32

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

AsInt32 returns the value as 32-bit integer if possible, or returns an error if not possible. The method will set expr.resInt to the value of this int32 if it is successful, avoiding the need to call the method again.

()

Source from the content-addressed store, hash-verified

214// value of this int32 if it is successful, avoiding the need to call
215// the method again.
216func (expr *NumVal) AsInt32() (int32, error) {
217 intVal, ok := expr.AsConstantInt()
218 if !ok {
219 return 0, errConstNotInt
220 }
221 i, exact := constant.Int64Val(intVal)
222 if !exact {
223 return 0, errConstOutOfRange32
224 }
225 if i > math.MaxInt32 || i < math.MinInt32 {
226 return 0, errConstOutOfRange32
227 }
228 expr.resInt = DInt(i)
229 return int32(i), nil
230}
231
232// AsConstantValue returns the value as a constant numerical value, with the proper sign
233// as given by expr.negative.

Callers 2

ParseMethod · 0.80
EvalShardBucketCountFunction · 0.80

Calls 2

AsConstantIntMethod · 0.95
DIntTypeAlias · 0.85

Tested by

no test coverage detected