Documentation
¶
Overview ¶
Package parser mirrors pg_query_go's parser subpackage: the Error type and the byte-level (protobuf-encoded) entry points.
Upstream these exist because cgo speaks bytes; here they are thin conveniences over the native Go implementations. The signatures are kept identical so code importing pg_query_go/v6/parser migrates with an import swap.
Index ¶
- func DeparseFromProtobuf(input []byte) (result string, err error)
- func FingerprintToHexStr(input string) (result string, err error)
- func FingerprintToUInt64(input string) (result uint64, err error)
- func HashXXH3_64(input []byte, seed uint64) (result uint64)
- func IsUtilityStmt(input string) (result []bool, err error)
- func Normalize(input string) (result string, err error)
- func NormalizeUtility(input string) (result string, err error)
- func ParsePlPgSqlToJSON(input string) (result string, err error)
- func ParseToJSON(input string) (result string, err error)
- func ParseToProtobuf(input string) ([]byte, error)
- func ScanToProtobuf(input string) (result []byte, err error)
- func SplitWithParser(input string, trimSpace bool) (result []string, err error)
- func SplitWithScanner(input string, trimSpace bool) (result []string, err error)
- func SummaryToProtobuf(input string, truncateLimit int) ([]byte, error)
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeparseFromProtobuf ¶
DeparseFromProtobuf is pg_query_deparse_protobuf: decode the tree and render it back to SQL, statements joined with "; ".
func FingerprintToHexStr ¶
FingerprintToHexStr renders the fingerprint the way the C implementation prints XXH64_canonical_t: big-endian, zero-padded hex.
func FingerprintToUInt64 ¶
FingerprintToUInt64 is pg_query_fingerprint: parse, then hash the raw tree (version-3 fingerprint).
func HashXXH3_64 ¶
HashXXH3_64 runs the XXH3 hash function (64-bit variant) on the given bytes, with the specified seed.
func IsUtilityStmt ¶
IsUtilityStmt reports, per statement, whether it is a utility statement (pg_query_is_utility_stmt.c: everything except SELECT/INSERT/UPDATE/ DELETE/MERGE).
func NormalizeUtility ¶
NormalizeUtility is pg_query_normalize_utility: only utility statements are normalized.
func ParsePlPgSqlToJSON ¶
ParsePlPgSqlToJSON is pg_query_parse_plpgsql: compile every CREATE FUNCTION/PROCEDURE and DO statement with the PL/pgSQL parser and render the JSON array of function dumps.
func ParseToJSON ¶
func ParseToProtobuf ¶
func ScanToProtobuf ¶
ScanToProtobuf lexes the input with the core scanner exactly as pg_query_scan.c does: raw core_yylex tokens (comments included, no base_yylex filtering), start/end byte offsets, and the keyword kind.
func SplitWithParser ¶
SplitWithParser splits on the RawStmt boundaries of a real parse (pg_query_split.c: pg_query_split_with_parser); a zero stmt_len runs to the end of the input.
func SplitWithScanner ¶
SplitWithScanner is pg_query_split.c's pg_query_split_with_scanner: a lexer-level statement splitter. A statement ends at a top-level ";" (or EOF) and is only emitted if it contained at least one keyword.
Types ¶
type Error ¶
type Error struct {
Message string // exception message
Funcname string // source function of exception (e.g. SearchSysCache)
Filename string // source of exception (e.g. parse.l)
Lineno int // source of exception (e.g. 104)
Cursorpos int // char in query at which exception occurred
Context string // additional context (optional, can be NULL)
}
Error mirrors pg_query_go's parser.Error field-for-field.