pgparser

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 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

Overview

Package pgparser is an optional sqlguard Parser backed by a real PostgreSQL grammar (github.com/auxten/postgresql-parser, pure Go, no cgo).

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 — dynamic fragments, dialect extensions, driver placeholders it can't handle — transparently degrades to sqlguard's zero-dependency FallbackParser, so analysis never breaks the caller's query path.

Usage:

sqlguard.Register("sqlguard-pg", "pgx", middleware.WithParser(pgparser.New()))
db, _ := sql.Open("sqlguard-pg", 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 PostgreSQL grammar.

func New

func New() *Parser

New returns a Postgres-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