Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: use UI-selected schema in PostgreSQL query span extraction (#18581)
Vincent Huang9ac8fd6409d9
diff --git a/backend/plugin/parser/pg/query_span_extractor.go b/backend/plugin/parser/pg/query_span_extractor.goindex efa194ca0b..cba8fdd5c8 100644--- a/backend/plugin/parser/pg/query_span_extractor.go+++ b/backend/plugin/parser/pg/query_span_extractor.go@@ -1219,7 +1219,7 @@ func (q *querySpanExtractor) findTableSchema(schemaName string, tableName stringDatabase: &q.defaultDatabase,}}- searcher := dbMetadata.NewSearcher(schemaName)+ searcher := dbMetadata.NewSearcher(schemaName, q.searchPath)tableSchemaName, table := searcher.SearchTable(tableName)viewSchemaName, view := searcher.SearchView(tableName)materializedViewSchemaName, materializedView := searcher.SearchMaterializedView(tableName)diff --git a/backend/store/model/pg_searcher.go b/backend/store/model/pg_searcher.goindex 2f192ee21f..3112fbef48 100644--- a/backend/store/model/pg_searcher.go+++ b/backend/store/model/pg_searcher.go@@ -15,11 +15,12 @@ type DatabaseSearcher struct {}// NewSearcher creates a searcher for database objects.-// If schemaName is provided (non-empty), it searches only in that schema; otherwise uses the database's search path.-// If the database's search path is empty, defaults to ["public"] for PostgreSQL.+// If schemaName is provided (non-empty), it searches only in that schema.+// Otherwise, it uses the provided fallbackSearchPath (e.g., from UI-selected schema).+// If fallbackSearchPath is also empty, defaults to ["public"] for PostgreSQL.// NOTE: This is primarily designed for PostgreSQL's search_path concept.-func (d *DatabaseMetadata) NewSearcher(schemaName string) *DatabaseSearcher {- searchPath := d.GetSearchPath()+func (d *DatabaseMetadata) NewSearcher(schemaName string, fallbackSearchPath []string) *DatabaseSearcher {+ searchPath := fallbackSearchPathif schemaName != "" {searchPath = []string{schemaName}} else if len(searchPath) == 0 {