SQLC fails for psql meta-commands like \restrict
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
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.
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.
This is critical, as its breaking many CI setups out of the blue.
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
Taking a look at this now. Should be easy enough to ignore lines like this.
Added https://github.com/sqlc-dev/sqlc/pull/4177 which builds on top of https://github.com/sqlc-dev/sqlc/pull/4082