Skip to content

Conversation

andrewmbenton
Copy link
Collaborator

This is kind of a lazy quick-and-dirty implementation that doesn't attempt to consolidate some duplicate line parsing that we do during migration removal and just sticks a func right in the package that handles file parsing for all engines, even though this line filter only applies to postgresql.

Happy to revise if there's a better place to put this.

Resolves #4065

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🔧 golang labels Aug 29, 2025
@atombender
Copy link

Can this please be merged? It's a blocking issue with Postgres 17. @kyleconroy

var lines []string
for s.Scan() {
line := s.Text()
if strings.HasPrefix(line, `\`) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little aggressive to remove all lines that begin with \. The following is valid SQL, but would be broken by this fix

SELECT E'
\x61 b c
';

I don't think pg_dump would create such a statement but hand written SQL could.

I would suggest that the fix only exclude lines starting with \restrict and \unrestrict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files. 🔧 golang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLC fails for psql meta-commands like \restrict
3 participants