Documentation
¶
Overview ¶
Package seqexpr provides functionality to find usages of sequences in expressions.
The logic here would fit nicely into schemaexpr if it weren't for the dependency on builtins, which itself depends on schemaexpr.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceSequenceNamesWithIDs ¶
func ReplaceSequenceNamesWithIDs( defaultExpr tree.Expr, nameToID map[string]int64, ) (tree.Expr, error)
ReplaceSequenceNamesWithIDs walks the given expression, and replaces any sequence names in the expression by their IDs instead. e.g. nextval('foo') => nextval(123::regclass)
Types ¶
type SeqIdentifier ¶
SeqIdentifier wraps together different ways of identifying a sequence. The sequence can either be identified via either its name, or its ID.
func GetSequenceFromFunc ¶
func GetSequenceFromFunc(funcExpr *tree.FuncExpr) (*SeqIdentifier, error)
GetSequenceFromFunc extracts a sequence identifier from a FuncExpr if the function takes a sequence identifier as an arg (a sequence identifier can either be a sequence name or an ID), wrapped in the SeqIdentifier type. Returns the identifier of the sequence or nil if no sequence was found.
func GetUsedSequences ¶
func GetUsedSequences(defaultExpr tree.Expr) ([]SeqIdentifier, error)
GetUsedSequences returns the identifier of the sequence passed to a call to sequence function in the given expression or nil if no sequence identifiers are found. The identifier is wrapped in a SeqIdentifier. e.g. nextval('foo') => "foo"; nextval(123::regclass) => 123; <some other expression> => nil
func (*SeqIdentifier) IsByID ¶
func (si *SeqIdentifier) IsByID() bool
IsByID indicates whether the SeqIdentifier is identifying the sequence by its ID or by its name.