Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/compiler/compile.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package compiler

import (
"bufio"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -38,6 +39,7 @@ func (c *Compiler) parseCatalog(schemas []string) error {
continue
}
contents := migrations.RemoveRollbackStatements(string(blob))
contents = removePsqlMetaCommands(contents)
c.schema = append(c.schema, contents)
stmts, err := c.parser.Parse(strings.NewReader(contents))
if err != nil {
Expand All @@ -57,6 +59,19 @@ func (c *Compiler) parseCatalog(schemas []string) error {
return nil
}

func removePsqlMetaCommands(contents string) string {
s := bufio.NewScanner(strings.NewReader(contents))
var lines []string
for s.Scan() {
line := s.Text()
if strings.HasPrefix(line, `\`) {
continue
}
lines = append(lines, line)
}
return strings.Join(lines, "\n")
}

func (c *Compiler) parseQueries(o opts.Parser) (*Result, error) {
var q []*Query
merr := multierr.New()
Expand Down
2 changes: 2 additions & 0 deletions internal/endtoend/testdata/pg_dump/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
-- Dumped from database version 15.3 (Debian 15.3-1.pgdg120+1)
-- Dumped by pg_dump version 15.3

\restrict auwherpfqaiuwrhgp

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
Expand Down
Loading