Skip to content

Commit 2307462

Browse files
authored
postgresql: Fix panic walking CreateTableAsStmt (#475)
1 parent bb98910 commit 2307462

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

internal/endtoend/testdata/materialized_views/go/db.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/materialized_views/go/models.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE TABLE authors (
2+
id BIGSERIAL PRIMARY KEY,
3+
name TEXT NOT NULL,
4+
bio TEXT
5+
);
6+
7+
ALTER TABLE authors ADD COLUMN gender INTEGER NULL;
8+
9+
CREATE MATERIALIZED VIEW authors_names as SELECT name from authors;
10+
11+
SELECT * FROM authors;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": "1",
3+
"packages": [{
4+
"path": "go",
5+
"name": "querytest",
6+
"schema": "query.sql",
7+
"queries": "query.sql"
8+
}]
9+
}

internal/postgresql/ast/soup.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ func Walk(f Visitor, node nodes.Node) {
496496

497497
case nodes.CreateTableAsStmt:
498498
walkn(f, n.Query)
499-
walkn(f, n.Into)
499+
if n.Into != nil {
500+
walkn(f, *n.Into)
501+
}
500502

501503
case nodes.CreateTableSpaceStmt:
502504
if n.Owner != nil {

0 commit comments

Comments
 (0)