Skip to content

PostgreSQL "DO" statement support #2614

@Knyntsje

Description

@Knyntsje

Describe the bug
The PostgreSQL "DO" statement is not supported: https://www.postgresql.org/docs/current/sql-do.html.
Parsing the SQL below gives the following error: Expected "#", "--", "/*", ":=", "=", or [ \\t\\n\\r] but "$" found.

Database Engine
PostgreSQL

To Reproduce
Reproduction code (https://playcode.io/empty-typescript-playground--019ac65c-53cf-741c-a307-87d71bda1d4b):

import { Parser } from "node-sql-parser/build/postgresql";

const parser = new Parser();
const ast = parser.astify(`
    DO $$
    DECLARE
        test INTEGER;
    BEGIN
        SELECT 1 INTO test;
    END
    $$;
`);

console.log(ast);

node-sql-parser version: 5.3.13
node version: 25.2.1

Expected behavior
Support for "DO" statements.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions