Help us shape the future of Go! Take the 2026 Go Developer Survey

deparse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Ported from postgres_deparse.c (libpg_query 18.0.0). Clause helpers: any_name, expression lists, target lists, from lists.

Ported from postgres_deparse.c (libpg_query 18.0.0). FROM/WHERE clauses, SELECT, function calls, window definitions, A_Expr.

Ported from postgres_deparse.c (libpg_query 18.0.0). Expressions: BoolExpr, CaseExpr, TypeCast/TypeName, constants; first DDL statements.

Ported from postgres_deparse.c (libpg_query 18.0.0). DDL: operator families, CREATE TABLE, constraints, indexes, DROP.

Ported from postgres_deparse.c (libpg_query 18.0.0). Grouping sets, DML statements (INSERT/UPDATE/DELETE/MERGE), ALTER TABLE, COPY.

Ported from postgres_deparse.c (libpg_query 18.0.0). DO, functions/procedures, roles, GRANT, transactions, views, policies.

Ported from postgres_deparse.c (libpg_query 18.0.0). ALTER statement long tail, publications/subscriptions, triggers, JSON aggregates.

Ported from postgres_deparse.c (libpg_query 18.0.0). JSON constructors, JSON_TABLE, value nodes, statement dispatch.

Package deparse ports libpg_query's postgres_deparse.c at the pinned 18.0.0, targeting the protobuf structs directly.

This file is the deparser state machinery: nesting levels, part groups and parts (postgres_deparse.c's DeparseState). The machinery exists for the optional pretty-print mode, which pg_query_go's API never enables, but it still shapes the plain output — parts are joined with single spaces, with no space after "(" or before a part starting with ")" or ";", and part groups fold their major keyword into their first part — so it is ported exactly rather than approximated. Comment placement is dropped entirely: comments can only arrive through deparse options the Go API does not expose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deparse

func Deparse(tree *ast.ParseResult) (result string, err error)

Deparse is pg_query_deparse_protobuf: statements joined with "; ".

func DeparseWithEmpties

func DeparseWithEmpties(tree *ast.ParseResult, empties map[any]bool) (result string, err error)

DeparseWithEmpties is Deparse with the parser's present-but-empty string set: the C deparser distinguishes COMMENT/SECURITY LABEL ... IS ” (a non-NULL empty string) from IS NULL, which proto3 collapses. Only callers that re-parsed the input themselves (the summary truncation) can supply the set; trees received over the API deparse as the protobuf round-trip does upstream (both forms print IS NULL).

func QuoteIdentifier

func QuoteIdentifier(ident string) string

QuoteIdentifier exposes quoteIdentifier to the other internal packages that need ruleutils.c's quote_identifier (the summary walk renders table names with it).

Types

This section is empty.

Jump to

Keyboard shortcuts

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