MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / NewPlaceholder

Function NewPlaceholder

pkg/sql/sem/tree/expr.go:783–797  ·  view source on GitHub ↗

NewPlaceholder allocates a Placeholder.

(name string)

Source from the content-addressed store, hash-verified

781
782// NewPlaceholder allocates a Placeholder.
783func NewPlaceholder(name string) (*Placeholder, error) {
784 uval, err := strconv.ParseUint(name, 10, 64)
785 if err != nil {
786 return nil, err
787 }
788 // The string is the number that follows $ which is a 1-based index ($1, $2,
789 // etc), while PlaceholderIdx is 0-based.
790 if uval == 0 || uval > MaxPlaceholderIdx+1 {
791 return nil, pgerror.Newf(
792 pgcode.NumericValueOutOfRange,
793 "placeholder index must be between 1 and %d", MaxPlaceholderIdx+1,
794 )
795 }
796 return &Placeholder{Idx: PlaceholderIdx(uval - 1)}, nil
797}
798
799// Format implements the NodeFormatter interface.
800func (node *Placeholder) Format(ctx *FmtCtx) {

Callers 2

initFunction · 0.92
initFunction · 0.92

Calls 2

NewfFunction · 0.92
PlaceholderIdxTypeAlias · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…