Skip to content

SQLC fails for psql meta-commands like \restrict #4065

Closed

Description

@anshum-heap

What do you want to change?

With latest postgresql versions, they have added --restrict-key= and other meta-commands here

When running pg_dump command, it adds a new line \restrict <token> at the top of .sql file, which sqlc fails to parse.

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Activity

  1. james-johnston-thumbtack commented on Aug 15, 2025

    @james-johnston-thumbtack

    This should be high priority. sqlc is no longer able to parse any output from pg_dump because they are now adding this new \restrict meta-command to all dump outputs.

  2. james-johnston-thumbtack commented on Aug 15, 2025

    @james-johnston-thumbtack

    Here is the upstream commit that introduced this new behavior: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=575f54d4c

    Release notes that discuss it: https://www.postgresql.org/docs/release/17.6/ (see "Prevent pg_dump scripts from being used to attack the user running the restore (Nathan Bossart)")

    They have cherry-picked this onto all PostgreSQL versions going back as far as at least PostgreSQL 13 due to the fact it's a security issue.

  3. dessalines commented on Aug 18, 2025

    @dessalines

    This is critical, as its breaking many CI setups out of the blue.

  4. jrmullins commented on Aug 21, 2025

    @jrmullins

    Perhaps not the prettiest solution but I got around before sqlc generate wtih this one liner

    sed '/^\\restrict /d;/^\\unrestrict /d' dump.sql > dump.sql.tmp && mv dump.sql.tmp dump.sql
    
  5. andrewmbenton commented on Aug 29, 2025

    @andrewmbenton
    Collaborator

    Taking a look at this now. Should be easy enough to ignore lines like this.

  6. added a commit that references this issue on Nov 4, 2025
  7. ignatremizov commented on Nov 10, 2025

    @ignatremizov

    Added #4177 which builds on top of #4082

  8. added a commit that references this issue on Apr 19, 2026
    418b576
  9. added a commit that references this issue on Apr 19, 2026
    394bdc7
  10. added 3 commits that reference this issue on May 8, 2026
    f92c8af
    6510f70
    08df6fc
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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions