statements

package
v0.23.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsANSIDML

func IsANSIDML(stmt tree.Statement) bool

IsANSIDML returns true if the AST is one of the 4 DML statements, SELECT, UPDATE, INSERT, DELETE, or an EXPLAIN of one of these statements.

Types

type AST

type AST interface {
}

type PLpgStatement

type PLpgStatement Statement[*plpgsqltree.Block]

func (PLpgStatement) String

func (stmt PLpgStatement) String() string

func (PLpgStatement) StringWithFlags

func (stmt PLpgStatement) StringWithFlags(flags tree.FmtFlags) string

StringWithFlags returns the AST formatted as a string (with the given flags).

type ParsedStmts

type ParsedStmts interface {
	String() string
	StringWithFlags(flags tree.FmtFlags) string
}

type Statement

type Statement[T any] struct {
	// AST is the root of the AST tree for the parsed statement.
	// Note that it is NOT SAFE to access this currently with statement execution,
	// as unfortunately the AST is not immutable.
	// See issue https://github.com/cockroachdb/cockroachdb-parser/issues/22847 for more
	// details on this problem.
	AST T

	// Comments is the list of parsed SQL comments.
	Comments []string

	// SQL is the original SQL from which the statement was parsed. Note that this
	// is not appropriate for use in logging, as it may contain passwords and
	// other sensitive data.
	SQL string

	// NumPlaceholders indicates the number of arguments to the statement (which
	// are referenced through placeholders). This corresponds to the highest
	// argument position (i.e. the x in "$x") that appears in the query.
	//
	// Note: where there are "gaps" in the placeholder positions, this number is
	// based on the highest position encountered. For example, for `SELECT $3`,
	// NumPlaceholders is 3. These cases are malformed and will result in a
	// type-check error.
	NumPlaceholders int

	// NumAnnotations indicates the number of annotations in the tree. It is equal
	// to the maximum annotation index.
	NumAnnotations tree.AnnotationIdx
}

Statement is the result of parsing a single statement. It contains the AST node along with other information.

type Statements

type Statements []Statement[tree.Statement]

Statements is a list of parsed statements.

func (Statements) String

func (stmts Statements) String() string

String returns the AST formatted as a string.

func (Statements) StringWithFlags

func (stmts Statements) StringWithFlags(flags tree.FmtFlags) string

StringWithFlags returns the AST formatted as a string (with the given flags).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL