statements

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 4 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 JsonpathStatement added in v0.25.2

type JsonpathStatement Statement[*jsonpath.Jsonpath]

func (JsonpathStatement) String added in v0.25.2

func (stmt JsonpathStatement) String() string

func (JsonpathStatement) StringWithFlags added in v0.25.2

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

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

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