Skip to content

[FORMATTING] Fails for psql meta-commands like \restrict #935

Closed

Description

@fedorkanin

Similar to sqlc-dev/sqlc#4065. When formatting a schema generated by pgdump, I receive the following error:

/node_modules/sql-formatter/dist/cjs/lexer/TokenizerEngine.js:42
        return new Error(`Parse error: Unexpected "${text}" at line ${line} column ${col}.\n${this.dialectInfo()}`);
               ^

Error: Parse error: Unexpected "\restrict " at line 1 column 1.
SQL dialect used: "postgresql".

Usage

I use sql-formatter in a Makefile:

SQL_FORMATTER := npx --yes -- [email protected]

.PHONY: format-sql
format-sql:
	for f in $(SQL_SOURCES); do $(SQL_FORMATTER) --fix $$f; done

Activity

  1. nene commented on Feb 20, 2026

    @nene
    Collaborator

    Thanks for reporting.

    If the new PostgreSQL versions indeed add this \restrict <token> at the top of all dumps, then that'll indeed effect quite a lot of people (myself included).

    Until now I've been ignoring requests to support these meta-commands, as they're not really part of the SQL, but I might need to finally do something about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions