stmtclass

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stmtclass provides lightweight runtime SQL statement classification used to decide transactional vs non-transactional execution and idempotency hints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyTokens

func ClassifyTokens(d Dialect, majorVersion int, ts sqltoken.Tokens) (stmts []StatementFlags, aggregate Flag)

ClassifyTokens classifies a tokenized script. For Postgres, majorVersion supplies version gating (pass 0 if unknown). Returns per-statement flags and aggregate mask.

func FlagNames

func FlagNames(agg Flag) (names []string)

Types

type Dialect

type Dialect int

Dialect enumerates supported SQL dialects.

const (
	DialectMySQL Dialect = iota
	DialectPostgres
)

type Flag

type Flag uint32

Flag is a bitmask describing statement / script properties.

const (
	IsDDL Flag = 1 << iota
	IsDML
	IsNonIdempotent
	IsMultipleStatements
	IsEasilyIdempotentFix
	IsMustNonTx // Statement must run outside a transaction (e.g. PG CREATE INDEX CONCURRENTLY)
)

Individual flag bits.

type StatementFlags

type StatementFlags struct {
	Flags Flag
	Text  string
}

StatementFlags associates a statement's original text with its flags.

type Summary

type Summary map[Flag]string

Summary maps each flag to the first statement text that exhibited it. Flags that are synthetic (e.g. IsMultipleStatements) will map to "" unless explicitly derived from a concrete statement.

func Summarize

func Summarize(stmts []StatementFlags, aggregate Flag) Summary

Summarize builds a Summary. For each flag it records the first statement whose Flags include it.

Jump to

Keyboard shortcuts

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