internal/postgres: update upsertSymbolSearchDocuments
upsertSymbolSearchDocuments is updated to insert data into the new
columns.
For golang/go#44142
Trust: Julie Qiu
Run-TryBot: Julie Qiu
@@ -41,7 +41,10 @@ func upsertSymbolSearchDocuments(ctx context.Context, tx *database.DB,
unit_id,
package_symbol_id,
goos,
- goarch
+ goarch,
+ package_name,
+ package_path,
+ imported_by_count
)
SELECT DISTINCT ON (sd.package_path_id, ps.symbol_name_id)
sd.package_path_id,
@@ -49,19 +52,19 @@ func upsertSymbolSearchDocuments(ctx context.Context, tx *database.DB,
sd.unit_id,
ps.id AS package_symbol_id,
d.goos,
- d.goarch
+ d.goarch,
+ sd.name,
+ sd.package_path,
+ sd.imported_by_count
FROM search_documents sd
- INNER JOIN units u
- ON sd.unit_id = u.id
- INNER JOIN documentation d
- ON d.unit_id = sd.unit_id
- INNER JOIN documentation_symbols ds
- ON d.id = ds.documentation_id
- INNER JOIN package_symbols ps
- ON ps.id = ds.package_symbol_id
+ INNER JOIN units u ON sd.unit_id = u.id
+ INNER JOIN documentation d ON d.unit_id = sd.unit_id
+ INNER JOIN documentation_symbols ds ON d.id = ds.documentation_id
+ INNER JOIN package_symbols ps ON ps.id = ds.package_symbol_id
WHERE
sd.module_path = $1 AND sd.version = $2
AND u.name != 'main' -- do not insert data for commands
+ AND sd.redistributable
ORDER BY
sd.package_path_id,
ps.symbol_name_id,
@@ -77,7 +80,10 @@ func upsertSymbolSearchDocuments(ctx context.Context, tx *database.DB,
unit_id = excluded.unit_id,
package_symbol_id = excluded.package_symbol_id,
goos = excluded.goos,
- goarch = excluded.goarch;`
+ goarch = excluded.goarch,
+ package_name = excluded.package_name,
+ package_path = excluded.package_path,
+ imported_by_count = excluded.imported_by_count;`
_, err = tx.Exec(ctx, q, modulePath, v)
return err
}
