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

Function commonConstantType

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

commonConstantType returns the most constrained type which is mutually resolvable between a set of provided constants. The function takes a slice of Exprs and indexes, but expects all the indexed Exprs to wrap a Constant. The reason it does no take a slice of Constants instead is to avoid forcing c

(vals []Expr, idxs []int)

Source from the content-addressed store, hash-verified

377// Exprs to wrap a Constant. The reason it does no take a slice of Constants
378// instead is to avoid forcing callers to allocate separate slices of Constant.
379func commonConstantType(vals []Expr, idxs []int) (*types.T, bool) {
380 var candidates []*types.T
381
382 for _, i := range idxs {
383 availableTypes := vals[i].(Constant).DesirableTypes()
384 if candidates == nil {
385 candidates = availableTypes
386 } else {
387 candidates = intersectTypeSlices(candidates, availableTypes)
388 }
389 }
390
391 if len(candidates) > 0 {
392 return candidates[0], true
393 }
394 return nil, false
395}
396
397// StrVal represents a constant string value.
398type StrVal struct {

Callers 2

typeCheckSameTypedConstsFunction · 0.85
typeCheckOverloadedExprsFunction · 0.85

Calls 2

intersectTypeSlicesFunction · 0.85
DesirableTypesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…