MCPcopy Create free account
hub / github.com/dolthub/doltgresql / NewPlaceholder

Function NewPlaceholder

postgres/parser/sem/tree/expr.go:876–890  ·  view source on GitHub ↗

NewPlaceholder allocates a Placeholder.

(name string)

Source from the content-addressed store, hash-verified

874
875// NewPlaceholder allocates a Placeholder.
876func NewPlaceholder(name string) (*Placeholder, error) {
877 uval, err := strconv.ParseUint(name, 10, 64)
878 if err != nil {
879 return nil, err
880 }
881 // The string is the number that follows $ which is a 1-based index ($1, $2,
882 // etc), while PlaceholderIdx is 0-based.
883 if uval == 0 || uval > MaxPlaceholderIdx+1 {
884 return nil, pgerror.Newf(
885 pgcode.NumericValueOutOfRange,
886 "placeholder index must be between 1 and %d", MaxPlaceholderIdx+1,
887 )
888 }
889 return &Placeholder{Idx: PlaceholderIdx(uval - 1)}, nil
890}
891
892// Format implements the NodeFormatter interface.
893func (node *Placeholder) Format(ctx *FmtCtx) {

Callers 1

scanPlaceholderMethod · 0.92

Calls 2

NewfFunction · 0.92
PlaceholderIdxTypeAlias · 0.85

Tested by

no test coverage detected