Skip to content

Commit 462e9b0

Browse files
committed
fix a crash
1 parent 5dcdd2f commit 462e9b0

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

internal/compiler/resolve.go

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,28 @@ func (comp *Compiler) resolveCatalogRefs(qc *QueryCatalog, rvs []*ast.RangeVar,
8080
aliasMap[*rv.Alias.Aliasname] = fqn
8181
}
8282
}
83-
for _, f := range qc.fromClauses {
84-
catCols := make([]*catalog.Column, 0, len(f.Columns))
85-
for _, col := range f.Columns {
86-
catCols = append(catCols, &catalog.Column{
87-
Name: col.Name,
88-
Type: ast.TypeName{Name: col.DataType},
89-
IsNotNull: col.NotNull,
90-
IsUnsigned: col.Unsigned,
91-
IsArray: col.IsArray,
92-
ArrayDims: col.ArrayDims,
93-
Comment: col.Comment,
94-
Length: col.Length,
95-
})
96-
}
83+
if qc != nil {
84+
for _, f := range qc.fromClauses {
85+
catCols := make([]*catalog.Column, 0, len(f.Columns))
86+
for _, col := range f.Columns {
87+
catCols = append(catCols, &catalog.Column{
88+
Name: col.Name,
89+
Type: ast.TypeName{Name: col.DataType},
90+
IsNotNull: col.NotNull,
91+
IsUnsigned: col.Unsigned,
92+
IsArray: col.IsArray,
93+
ArrayDims: col.ArrayDims,
94+
Comment: col.Comment,
95+
Length: col.Length,
96+
})
97+
}
9798

98-
if err := indexTable(catalog.Table{
99-
Rel: f.Rel,
100-
Columns: catCols,
101-
}); err != nil {
102-
return nil, err
99+
if err := indexTable(catalog.Table{
100+
Rel: f.Rel,
101+
Columns: catCols,
102+
}); err != nil {
103+
return nil, err
104+
}
103105
}
104106
}
105107

0 commit comments

Comments
 (0)