mysqlparser

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mysqlparser is an optional sqlguard Parser backed by a real MySQL grammar (github.com/xwb1989/sqlparser — a pure-Go, no-cgo, lightweight Vitess-derived MySQL parser).

It produces exact, structural answers for the false-positive-prone facts (statement kind, WHERE/LIMIT/ORDER BY/FROM presence, SELECT *, explicit INSERT columns) instead of regex guesses. SQL the grammar rejects — CTEs it doesn't support, dynamic fragments, dialect extensions — transparently degrades to sqlguard's zero-dependency FallbackParser, so analysis never breaks the caller's query path.

Usage:

sqlguard.Register("sqlguard-mysql", "mysql", middleware.WithParser(mysqlparser.New()))
db, _ := sql.Open("sqlguard-mysql", dsn)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements analyzer.Parser using a MySQL grammar.

func New

func New() *Parser

New returns a MySQL-dialect Parser that falls back to the zero-dependency FallbackParser on parse failure.

func (*Parser) Parse

func (p *Parser) Parse(sql string) (*analyzer.Statement, error)

Parse implements analyzer.Parser. It never returns an error: unparseable SQL yields the fallback parser's best-effort Statement (Exact=false).

Jump to

Keyboard shortcuts

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