sqlutil

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sqlutil exposes stable SQL analysis helpers for tools that need to classify statements without depending on tinySQL's internal engine package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsReadOnly

func IsReadOnly(sql string) bool

IsReadOnly returns true when sql parses as a read-only statement.

func IsResultProducing

func IsResultProducing(sql string) bool

IsResultProducing returns true for statements expected to return rows.

Types

type Analysis

type Analysis struct {
	Kind            StatementKind
	ObjectName      string
	ReadOnly        bool
	ResultProducing bool
	Mutation        bool
	DDL             bool
	Job             bool
}

Analysis describes a parsed SQL statement at a level suitable for UI guards, auto-run checks, and audit labels.

func Analyze

func Analyze(sql string) (Analysis, error)

Analyze parses sql and returns a coarse statement classification.

func AnalyzeStatement

func AnalyzeStatement(stmt engine.Statement) Analysis

AnalyzeStatement classifies an already parsed statement.

type StatementKind

type StatementKind string

StatementKind is a coarse statement classification.

const (
	// StatementKind values classify SQL statements at a coarse, stable level.
	KindUnknown                StatementKind = "unknown"
	KindSelect                 StatementKind = "select"
	KindExplain                StatementKind = "explain"
	KindAnalyze                StatementKind = "analyze"
	KindPragma                 StatementKind = "pragma"
	KindInsert                 StatementKind = "insert"
	KindUpdate                 StatementKind = "update"
	KindDelete                 StatementKind = "delete"
	KindCreateTable            StatementKind = "create_table"
	KindDropTable              StatementKind = "drop_table"
	KindCreateIndex            StatementKind = "create_index"
	KindDropIndex              StatementKind = "drop_index"
	KindCreateView             StatementKind = "create_view"
	KindDropView               StatementKind = "drop_view"
	KindCreateMaterializedView StatementKind = "create_materialized_view"
	KindDropMaterializedView   StatementKind = "drop_materialized_view"
	KindRefreshMaterialized    StatementKind = "refresh_materialized_view"
	KindAlter                  StatementKind = "alter"
	KindCreateTrigger          StatementKind = "create_trigger"
	KindDropTrigger            StatementKind = "drop_trigger"
	KindCreateJob              StatementKind = "create_job"
	KindAlterJob               StatementKind = "alter_job"
	KindDropJob                StatementKind = "drop_job"
)

Jump to

Keyboard shortcuts

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