Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(parser): initialize sourceColumnsInFunction in subquery extractor (#17047)

h3n4lfb86e94f8f45
diff --git a/backend/plugin/parser/pg/query_span_extractor.go b/backend/plugin/parser/pg/query_span_extractor.go
index c2f02ba0b5..f5671fa303 100644
--- a/backend/plugin/parser/pg/query_span_extractor.go
+++ b/backend/plugin/parser/pg/query_span_extractor.go
@@ -1618,14 +1618,15 @@ func (q *querySpanExtractor) extractSourceColumnSetFromExpressionNode(node *pgqu
// So that the subquery can access the outer schema.
// The reason for new extractor is that we still need the current fromFieldList, overriding it is not expected.
subqueryExtractor := &querySpanExtractor{
- ctx: q.ctx,
- defaultDatabase: q.defaultDatabase,
- searchPath: q.searchPath,
- metaCache: q.metaCache,
- gCtx: q.gCtx,
- ctes: q.ctes,
- outerTableSources: append(q.outerTableSources, q.tableSourcesFrom...),
- tableSourcesFrom: []base.TableSource{},
+ ctx: q.ctx,
+ defaultDatabase: q.defaultDatabase,
+ searchPath: q.searchPath,
+ metaCache: q.metaCache,
+ gCtx: q.gCtx,
+ ctes: q.ctes,
+ outerTableSources: append(q.outerTableSources, q.tableSourcesFrom...),
+ tableSourcesFrom: []base.TableSource{},
+ sourceColumnsInFunction: make(base.SourceColumnSet),
}
tableSource, err := subqueryExtractor.extractTableSourceFromNode(node.SubLink.Subselect)
if err != nil {