You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/plpgsql-deparser/README.md
+28-7Lines changed: 28 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,9 +16,11 @@ PL/pgSQL AST Deparser - Converts PL/pgSQL function ASTs back to SQL strings.
16
16
17
17
> **⚠️ Experimental:** This package is currently experimental. If you're looking for SQL deparsing (not PL/pgSQL), see [`pgsql-deparser`](https://www.npmjs.com/package/pgsql-deparser).
18
18
19
+
> **For full SQL + PL/pgSQL deparsing:** If you need to deparse complete `CREATE FUNCTION` statements (not just function bodies), use [`plpgsql-parser`](https://www.npmjs.com/package/plpgsql-parser) instead. It handles the full heterogeneous parsing/deparsing pipeline automatically.
20
+
19
21
## Overview
20
22
21
-
This package provides a deparser for PL/pgSQL (PostgreSQL's procedural language) AST structures. It works with the AST output from `parsePlPgSQL` function in `@libpg-query/parser`.
23
+
This package provides a **body-only**deparser for PL/pgSQL (PostgreSQL's procedural language) AST structures. It converts PL/pgSQL function bodies (the `BEGIN...END` part) back to strings. It works with the AST output from `parsePlPgSQL` function in `@libpg-query/parser`.
22
24
23
25
The PL/pgSQL AST is different from the regular SQL AST - it represents the internal structure of PL/pgSQL function bodies, including:
The PL/pgSQL AST returned by `parsePlPgSQL` represents the internal structure of function bodies, not the `CREATE FUNCTION` statement itself. To get a complete function definition, you would need to:
182
+
This package deparses **only the function body** (the `BEGIN...END` part), not the full `CREATE FUNCTION` statement.
183
+
184
+
For full SQL + PL/pgSQL deparsing, use [`plpgsql-parser`](https://www.npmjs.com/package/plpgsql-parser):
Copy file name to clipboardExpand all lines: packages/plpgsql-parser/README.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,16 +14,22 @@
14
14
15
15
Combined SQL + PL/pgSQL parser with hydrated ASTs and transform API.
16
16
17
-
> **⚠️ Experimental:** This package is currently experimental. If you're looking for just SQL parsing, see [`pgsql-parser`](https://www.npmjs.com/package/pgsql-parser). For just PL/pgSQL deparsing, see [`plpgsql-deparser`](https://www.npmjs.com/package/plpgsql-deparser).
17
+
> **⚠️ Experimental:** This package is currently experimental. If you're looking for just SQL parsing, see [`pgsql-parser`](https://www.npmjs.com/package/pgsql-parser). For body-only PL/pgSQL deparsing, see [`plpgsql-deparser`](https://www.npmjs.com/package/plpgsql-deparser).
18
18
19
19
## Overview
20
20
21
-
This package provides a unified API for parsing SQL scripts containing PL/pgSQL functions. It combines the SQL parser and PL/pgSQL parser, automatically detecting and hydrating PL/pgSQL function bodies.
21
+
This package provides a unified API for **heterogeneous parsing and deparsing** of SQL scripts containing PL/pgSQL functions. It handles the full pipeline: parsing SQL + PL/pgSQL together, transforming ASTs, and deparsing back to complete SQL.
22
+
23
+
**Use this package when you need to:**
24
+
- Parse and deparse complete `CREATE FUNCTION` statements with PL/pgSQL bodies
25
+
- Transform both SQL and embedded PL/pgSQL expressions (e.g., rename schemas)
26
+
- Round-trip SQL through parse → modify → deparse
22
27
23
28
Key features:
24
29
25
30
- Auto-detects `CREATE FUNCTION` statements with `LANGUAGE plpgsql`
26
31
- Hydrates PL/pgSQL function bodies into structured ASTs
32
+
- Automatic `RETURN` statement handling based on function return type
27
33
- Transform API for parse → modify → deparse workflows
28
34
- Re-exports underlying primitives for power users
0 commit comments