diff options
| author | Julie Qiu <julie@golang.org> | 2021-05-05 17:54:40 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2021-05-06 15:49:40 +0000 |
| commit | 671ddf2fc13d76cb6adae5f1f7988577acba70a3 (patch) | |
| tree | 01c0e9b91b08d924432e46c74464b9a24bac3d95 /internal/postgres | |
| parent | ab4eaf3df70292d1ae00eb8df3230e60fbd41879 (diff) | |
| download | go-x-pkgsite-671ddf2fc13d76cb6adae5f1f7988577acba70a3.tar.xz | |
internal/postgres: delete Legacy functions
For golang/go#37102
Change-Id: Icda2856dd6af29267affd075a95974a3c65c0adc
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317429
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/postgres')
| -rw-r--r-- | internal/postgres/insert_symbol_history.go | 13 | ||||
| -rw-r--r-- | internal/postgres/package_symbol.go | 101 | ||||
| -rw-r--r-- | internal/postgres/symbol_history.go | 100 | ||||
| -rw-r--r-- | internal/postgres/symbol_test.go | 156 | ||||
| -rw-r--r-- | internal/postgres/unit.go | 5 |
5 files changed, 68 insertions, 307 deletions
diff --git a/internal/postgres/insert_symbol_history.go b/internal/postgres/insert_symbol_history.go index 19b41e2d..ba55bc4b 100644 --- a/internal/postgres/insert_symbol_history.go +++ b/internal/postgres/insert_symbol_history.go @@ -37,7 +37,7 @@ func upsertSymbolHistory(ctx context.Context, ddb *database.DB, return err } for packagePath, docIDToDoc := range pathToDocIDToDoc { - dbVersionToNameToUnitSymbol, err := LegacyGetSymbolHistoryFromTable(ctx, ddb, packagePath, modulePath) + sh, err := GetSymbolHistoryFromTable(ctx, ddb, packagePath, modulePath) if err != nil { return err } @@ -49,10 +49,13 @@ func upsertSymbolHistory(ctx context.Context, ddb *database.DB, } for _, b := range builds { dbNameToVersion := map[string]string{} - for v, nameToUS := range dbVersionToNameToUnitSymbol { - for name, us := range nameToUS { - if us.SupportsBuild(b) { - dbNameToVersion[name] = v + for _, v := range sh.Versions() { + nts := sh.SymbolsAtVersion(v) + for name, stu := range nts { + for _, us := range stu { + if us.SupportsBuild(b) { + dbNameToVersion[name] = v + } } } } diff --git a/internal/postgres/package_symbol.go b/internal/postgres/package_symbol.go index 6cb34777..fcebeb3d 100644 --- a/internal/postgres/package_symbol.go +++ b/internal/postgres/package_symbol.go @@ -50,7 +50,10 @@ func getPackageSymbols(ctx context.Context, ddb *database.DB, packagePath, modul sh, collect := collectSymbolHistory(func(sh *internal.SymbolHistory, sm internal.SymbolMeta, v string, build internal.BuildContext) error { if sm.Section == internal.SymbolSectionTypes && sm.Kind != internal.SymbolKindType { _, err := sh.GetSymbol(sm.ParentName, v, build) - return err + if err != nil { + return fmt.Errorf("could not find parent for %q: %v", sm.Name, err) + } + return nil } return nil }) @@ -88,99 +91,3 @@ func collectSymbolHistory(check func(sh *internal.SymbolHistory, sm internal.Sym return nil } } - -// legacyGetPackageSymbols returns all of the symbols for a given package path and module path. -func legacyGetPackageSymbols(ctx context.Context, ddb *database.DB, packagePath, modulePath string, -) (_ map[string]map[string]*internal.UnitSymbol, err error) { - defer derrors.Wrap(&err, "legacyGetPackageSymbols(ctx, ddb, %q, %q)", packagePath, modulePath) - defer middleware.ElapsedStat(ctx, "getPackageSymbols")() - query := ` - SELECT - s1.name AS symbol_name, - s2.name AS parent_symbol_name, - ps.section, - ps.type, - ps.synopsis, - m.version, - d.goos, - d.goarch - FROM modules m - INNER JOIN units u ON u.module_id = m.id - INNER JOIN documentation d ON d.unit_id = u.id - INNER JOIN documentation_symbols ds ON ds.documentation_id = d.id - INNER JOIN package_symbols ps ON ps.id = ds.package_symbol_id - INNER JOIN paths p1 ON u.path_id = p1.id - INNER JOIN symbol_names s1 ON ps.symbol_name_id = s1.id - INNER JOIN symbol_names s2 ON ps.parent_symbol_name_id = s2.id - WHERE - p1.path = $1 - AND m.module_path = $2 - AND NOT m.incompatible - AND m.version_type = 'release' - ORDER BY - CASE WHEN ps.type='Type' THEN 0 ELSE 1 END, - symbol_name;` - - // versionToNameToUnitSymbol contains all of the types for this unit, - // grouped by name and build context. This is used to keep track of the - // parent types, so that we can map the children to those symbols. - versionToNameToUnitSymbol := map[string]map[string]*internal.UnitSymbol{} - collect := func(rows *sql.Rows) error { - var ( - newUS internal.UnitSymbol - build internal.BuildContext - v string - ) - if err := rows.Scan( - &newUS.Name, - &newUS.ParentName, - &newUS.Section, - &newUS.Kind, - &newUS.Synopsis, - &v, - &build.GOOS, - &build.GOARCH, - ); err != nil { - return fmt.Errorf("row.Scan(): %v", err) - } - if newUS.Section == internal.SymbolSectionTypes && newUS.Kind != internal.SymbolKindType { - if err := validateChildSymbol(&newUS, v, build, versionToNameToUnitSymbol); err != nil { - return err - } - } - nts, ok := versionToNameToUnitSymbol[v] - if !ok { - nts = map[string]*internal.UnitSymbol{} - versionToNameToUnitSymbol[v] = nts - } - us, ok := nts[newUS.Name] - if !ok { - us = &newUS - nts[newUS.Name] = us - } - us.AddBuildContext(build) - return nil - } - if err := ddb.RunQuery(ctx, query, collect, packagePath, modulePath); err != nil { - return nil, err - } - return versionToNameToUnitSymbol, nil -} - -func validateChildSymbol(us *internal.UnitSymbol, v string, build internal.BuildContext, - versionToNameToUnitSymbol map[string]map[string]*internal.UnitSymbol) error { - nameToUnitSymbol, ok := versionToNameToUnitSymbol[v] - if !ok { - return fmt.Errorf("version %q could not be found: %q", v, us.Name) - } - parent, ok := nameToUnitSymbol[us.ParentName] - if !ok { - return fmt.Errorf("parent %q could not be found at version %q: %q", - us.ParentName, v, us.Name) - } - if !parent.SupportsBuild(build) { - return fmt.Errorf("parent %q does not have build %v at version %q: %q", - us.ParentName, build, v, us.Name) - } - return nil -} diff --git a/internal/postgres/symbol_history.go b/internal/postgres/symbol_history.go index 81d0bc0e..252bceeb 100644 --- a/internal/postgres/symbol_history.go +++ b/internal/postgres/symbol_history.go @@ -87,106 +87,6 @@ func GetSymbolHistoryWithPackageSymbols(ctx context.Context, ddb *database.DB, return symbol.IntroducedHistory(sh) } -// LegacyGetSymbolHistory returns a map of the first version when a symbol name is -// added to the API, to the symbol name, to the UnitSymbol struct. The -// UnitSymbol.Children field will always be empty, as children names are also -// tracked. -func (db *DB) LegacyGetSymbolHistory(ctx context.Context, packagePath, modulePath string, -) (_ map[string]map[string]*internal.UnitSymbol, err error) { - defer derrors.Wrap(&err, "LegacyGetSymbolHistory(ctx, %q, %q)", packagePath, modulePath) - defer middleware.ElapsedStat(ctx, "LegacyGetSymbolHistory")() - - if experiment.IsActive(ctx, internal.ExperimentReadSymbolHistory) { - return LegacyGetSymbolHistoryFromTable(ctx, db.db, packagePath, modulePath) - } - return LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, packagePath, modulePath) -} - -// LegacyGetSymbolHistoryFromTable fetches symbol history data from the symbol_history table. -// -// LegacyGetSymbolHistoryFromTable is exported for use in tests. -func LegacyGetSymbolHistoryFromTable(ctx context.Context, ddb *database.DB, - packagePath, modulePath string) (_ map[string]map[string]*internal.UnitSymbol, err error) { - defer derrors.WrapStack(&err, "LegacyGetSymbolHistoryFromTable(ctx, ddb, %q, %q)", packagePath, modulePath) - - q := squirrel.Select( - "s1.name AS symbol_name", - "s2.name AS parent_symbol_name", - "ps.section", - "ps.type", - "ps.synopsis", - "sh.since_version", - "sh.goos", - "sh.goarch", - ).From("symbol_history sh"). - Join("package_symbols ps ON ps.id = sh.package_symbol_id"). - Join("symbol_names s1 ON ps.symbol_name_id = s1.id"). - Join("symbol_names s2 ON ps.parent_symbol_name_id = s2.id"). - Join("paths p1 ON sh.package_path_id = p1.id"). - Join("paths p2 ON sh.module_path_id = p2.id"). - Where(squirrel.Eq{"p1.path": packagePath}). - Where(squirrel.Eq{"p2.path": modulePath}) - query, args, err := q.PlaceholderFormat(squirrel.Dollar).ToSql() - if err != nil { - return nil, err - } - - // versionToNameToUnitSymbol is a map of the version a symbol was - // introduced, to the name and unit symbol. - versionToNameToUnitSymbol := map[string]map[string]*internal.UnitSymbol{} - collect := func(rows *sql.Rows) error { - var ( - newUS internal.UnitSymbol - build internal.BuildContext - v string - ) - if err := rows.Scan( - &newUS.Name, - &newUS.ParentName, - &newUS.Section, - &newUS.Kind, - &newUS.Synopsis, - &v, - &build.GOOS, - &build.GOARCH, - ); err != nil { - return fmt.Errorf("row.Scan(): %v", err) - } - nts, ok := versionToNameToUnitSymbol[v] - if !ok { - nts = map[string]*internal.UnitSymbol{} - versionToNameToUnitSymbol[v] = nts - } - us, ok := nts[newUS.Name] - if !ok { - us = &newUS - nts[newUS.Name] = us - } - us.AddBuildContext(build) - return nil - } - if err := ddb.RunQuery(ctx, query, collect, args...); err != nil { - return nil, err - } - return versionToNameToUnitSymbol, nil -} - -// LegacyGetSymbolHistoryWithPackageSymbols fetches symbol history data by using data -// from package_symbols and documentation_symbols, and computed using -// symbol.IntroducedHistory. -// -// LegacyGetSymbolHistoryWithPackageSymbols is exported for use in tests. -func LegacyGetSymbolHistoryWithPackageSymbols(ctx context.Context, ddb *database.DB, - packagePath, modulePath string) (_ map[string]map[string]*internal.UnitSymbol, err error) { - defer derrors.WrapStack(&err, "GetSymbolHistoryWithPackageSymbols(ctx, ddb, %q, %q)", packagePath, modulePath) - defer middleware.ElapsedStat(ctx, "GetSymbolHistoryWithPackageSymbols")() - versionToNameToUnitSymbols, err := legacyGetPackageSymbols(ctx, ddb, packagePath, modulePath) - if err != nil { - return nil, err - } - return symbol.LegacyIntroducedHistory(versionToNameToUnitSymbols), nil -} - // GetSymbolHistoryForBuildContext returns a map of the first version when a symbol name is // added to the API for the specified build context, to the symbol name, to the // UnitSymbol struct. The UnitSymbol.Children field will always be empty, as diff --git a/internal/postgres/symbol_test.go b/internal/postgres/symbol_test.go index 84cba912..4193b6f2 100644 --- a/internal/postgres/symbol_test.go +++ b/internal/postgres/symbol_test.go @@ -63,27 +63,23 @@ func TestInsertSymbolNamesAndHistory(t *testing.T) { } compareUnitSymbols(ctx, t, testDB, mod.Packages()[0].Path, mod.ModulePath, mod.Version, map[internal.BuildContext][]*internal.Symbol{internal.BuildContextAll: api}) - want2 := map[string]map[string]*internal.UnitSymbol{} - want2[mod.Version] = unitSymbolsFromAPI(api, mod.Version) + want2 := symbolHistoryFromAPI(api, mod.Version) comparePackageSymbols(ctx, t, testDB, mod.Packages()[0].Path, mod.ModulePath, mod.Version, want2) - gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod.Packages()[0].Path, mod.ModulePath) + gotHist, err := testDB.GetSymbolHistory(ctx, mod.Packages()[0].Path, mod.ModulePath) if err != nil { t.Fatal(err) } - wantHist := map[string]map[string]*internal.UnitSymbol{ - "v1.0.0": map[string]*internal.UnitSymbol{ - "Constant": unitSymbolFromSymbol(sample.Constant, "v1.0.0"), - "Variable": unitSymbolFromSymbol(sample.Variable, "v1.0.0"), - "Function": unitSymbolFromSymbol(sample.Function, "v1.0.0"), - "Type": unitSymbolFromSymbol(sample.Type, "v1.0.0"), - "Type.Field": unitSymbolFromSymbolMeta(sample.Type.Children[0], "v1.0.0", internal.BuildContextAll), - "New": unitSymbolFromSymbolMeta(sample.Type.Children[1], "v1.0.0", internal.BuildContextAll), - "Type.Method": unitSymbolFromSymbolMeta(sample.Type.Children[2], "v1.0.0", internal.BuildContextAll), - }, - } + wantHist := internal.NewSymbolHistory() + wantHist.AddSymbol(sample.Constant.SymbolMeta, "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(sample.Variable.SymbolMeta, "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(sample.Function.SymbolMeta, "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(sample.Type.SymbolMeta, "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(*sample.Type.Children[0], "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(*sample.Type.Children[1], "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(*sample.Type.Children[2], "v1.0.0", internal.BuildContextAll) if diff := cmp.Diff(wantHist, gotHist, - cmp.AllowUnexported(internal.UnitSymbol{})); diff != "" { + cmp.AllowUnexported(internal.UnitSymbol{}, internal.SymbolHistory{})); diff != "" { t.Fatalf("mismatch on symbol history(-want +got):\n%s", diff) } } @@ -116,8 +112,7 @@ func TestInsertSymbolHistory_Basic(t *testing.T) { compareUnitSymbols(ctx, t, testDB, mod.Packages()[0].Path, mod.ModulePath, mod.Version, map[internal.BuildContext][]*internal.Symbol{internal.BuildContextAll: api}) - want2 := map[string]map[string]*internal.UnitSymbol{} - want2[mod.Version] = unitSymbolsFromAPI(api, mod.Version) + want2 := symbolHistoryFromAPI(api, mod.Version) comparePackageSymbols(ctx, t, testDB, mod.Packages()[0].Path, mod.ModulePath, mod.Version, want2) } @@ -187,7 +182,7 @@ func TestInsertSymbolHistory_MultiVersions(t *testing.T) { compareUnitSymbols(ctx, t, testDB, mod11.Packages()[0].Path, mod11.ModulePath, mod11.Version, want11) compareUnitSymbols(ctx, t, testDB, mod12.Packages()[0].Path, mod12.ModulePath, mod12.Version, want12) - want2 := map[string]map[string]*internal.UnitSymbol{} + want2 := internal.NewSymbolHistory() for _, want := range []struct { version string buildToSymbols map[internal.BuildContext][]*internal.Symbol @@ -196,13 +191,16 @@ func TestInsertSymbolHistory_MultiVersions(t *testing.T) { {mod11.Version, want11}, {mod12.Version, want12}, } { - for _, api := range want.buildToSymbols { - want2[want.version] = unitSymbolsFromAPI(api, want.version) + for build, api := range want.buildToSymbols { + updateSymbols(api, func(s *internal.SymbolMeta) error { + want2.AddSymbol(*s, want.version, build) + return nil + }) } } comparePackageSymbols(ctx, t, testDB, mod10.Packages()[0].Path, mod10.ModulePath, mod10.Version, want2) - gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath) + gotHist, err := testDB.GetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath) if err != nil { t.Fatal(err) } @@ -212,19 +210,12 @@ func TestInsertSymbolHistory_MultiVersions(t *testing.T) { typA.GOARCH = internal.All methodA.GOARCH = internal.All methodB.GOARCH = internal.All - wantHist := map[string]map[string]*internal.UnitSymbol{ - "v1.0.0": map[string]*internal.UnitSymbol{ - "Foo": unitSymbolFromSymbol(&typA, "v1.0.0"), - }, - "v1.1.0": { - "Foo.A": unitSymbolFromSymbol(&methodA, "v1.1.0"), - }, - "v1.2.0": { - "Foo.B": unitSymbolFromSymbol(&methodB, "v1.2.0"), - }, - } + wantHist := internal.NewSymbolHistory() + wantHist.AddSymbol(typA.SymbolMeta, "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(methodA.SymbolMeta, "v1.1.0", internal.BuildContextAll) + wantHist.AddSymbol(methodB.SymbolMeta, "v1.2.0", internal.BuildContextAll) if diff := cmp.Diff(wantHist, gotHist, - cmp.AllowUnexported(internal.UnitSymbol{})); diff != "" { + cmp.AllowUnexported(internal.UnitSymbol{}, internal.SymbolHistory{})); diff != "" { t.Fatalf("mismatch on symbol history(-want +got):\n%s", diff) } } @@ -339,15 +330,19 @@ func TestInsertSymbolHistory_MultiGOOS(t *testing.T) { compareUnitSymbols(ctx, t, testDB, mod11.Packages()[0].Path, mod11.ModulePath, mod11.Version, want11) compareUnitSymbols(ctx, t, testDB, mod12.Packages()[0].Path, mod12.ModulePath, mod12.Version, want12) - want2 := map[string]map[string]*internal.UnitSymbol{} + want2 := internal.NewSymbolHistory() for _, mod := range []*internal.Module{mod10, mod11, mod12} { - want2[mod.Version] = map[string]*internal.UnitSymbol{} for _, pkg := range mod.Packages() { for _, doc := range pkg.Documentation { - nameToUnitSym := unitSymbolsFromAPI(doc.API, mod.Version) - for name, unitSym := range nameToUnitSym { - if _, ok := want2[mod.Version][name]; !ok { - want2[mod.Version][name] = unitSym + sh := symbolHistoryFromAPI(doc.API, mod.Version) + for _, v := range sh.Versions() { + nts := sh.SymbolsAtVersion(v) + for _, stu := range nts { + for sm, us := range stu { + for _, b := range us.BuildContexts() { + want2.AddSymbol(sm, mod.Version, b) + } + } } } } @@ -355,52 +350,25 @@ func TestInsertSymbolHistory_MultiGOOS(t *testing.T) { } comparePackageSymbols(ctx, t, testDB, mod10.Packages()[0].Path, mod10.ModulePath, mod10.Version, want2) - gotHist, err := testDB.LegacyGetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath) + gotHist, err := testDB.GetSymbolHistory(ctx, mod10.Packages()[0].Path, mod10.ModulePath) if err != nil { t.Fatal(err) } typ.GOOS = internal.All typ.GOARCH = internal.All - wantHist := map[string]map[string]*internal.UnitSymbol{ - "v1.0.0": map[string]*internal.UnitSymbol{ - "Foo": unitSymbolFromSymbol(&typ, "v1.0.0"), - }, - "v1.1.0": map[string]*internal.UnitSymbol{ - "Foo.A": func() *internal.UnitSymbol { - us := unitSymbolFromSymbol(&methodA, "v1.1.0") - us.RemoveBuildContexts() - us.AddBuildContext(internal.BuildContextLinux) - us.AddBuildContext(internal.BuildContextWindows) - return us - }(), - "Foo.B": func() *internal.UnitSymbol { - us := unitSymbolFromSymbol(&methodB, "v1.1.0") - us.RemoveBuildContexts() - us.AddBuildContext(internal.BuildContextJS) - us.AddBuildContext(internal.BuildContextDarwin) - return us - }(), - }, - "v1.2.0": map[string]*internal.UnitSymbol{ - "Foo.A": func() *internal.UnitSymbol { - us := unitSymbolFromSymbol(&methodA, "v1.2.0") - us.RemoveBuildContexts() - us.AddBuildContext(internal.BuildContextJS) - us.AddBuildContext(internal.BuildContextDarwin) - return us - }(), - "Foo.B": func() *internal.UnitSymbol { - us := unitSymbolFromSymbol(&methodB, "v1.2.0") - us.RemoveBuildContexts() - us.AddBuildContext(internal.BuildContextLinux) - us.AddBuildContext(internal.BuildContextWindows) - return us - }(), - }, - } + wantHist := internal.NewSymbolHistory() + wantHist.AddSymbol(typ.SymbolMeta, "v1.0.0", internal.BuildContextAll) + wantHist.AddSymbol(methodA.SymbolMeta, "v1.1.0", internal.BuildContextLinux) + wantHist.AddSymbol(methodA.SymbolMeta, "v1.1.0", internal.BuildContextWindows) + wantHist.AddSymbol(methodB.SymbolMeta, "v1.1.0", internal.BuildContextJS) + wantHist.AddSymbol(methodB.SymbolMeta, "v1.1.0", internal.BuildContextDarwin) + wantHist.AddSymbol(methodA.SymbolMeta, "v1.2.0", internal.BuildContextJS) + wantHist.AddSymbol(methodA.SymbolMeta, "v1.2.0", internal.BuildContextDarwin) + wantHist.AddSymbol(methodB.SymbolMeta, "v1.2.0", internal.BuildContextLinux) + wantHist.AddSymbol(methodB.SymbolMeta, "v1.2.0", internal.BuildContextWindows) if diff := cmp.Diff(wantHist, gotHist, - cmp.AllowUnexported(internal.UnitSymbol{})); diff != "" { + cmp.AllowUnexported(internal.UnitSymbol{}, internal.SymbolHistory{})); diff != "" { t.Fatalf("mismatch on symbol history(-want +got):\n%s", diff) } @@ -473,42 +441,24 @@ func compareUnitSymbols(ctx context.Context, t *testing.T, testDB *DB, } func comparePackageSymbols(ctx context.Context, t *testing.T, testDB *DB, - path, modulePath, version string, want map[string]map[string]*internal.UnitSymbol) { + path, modulePath, version string, want *internal.SymbolHistory) { t.Helper() - got, err := legacyGetPackageSymbols(ctx, testDB.db, path, modulePath) + got, err := getPackageSymbols(ctx, testDB.db, path, modulePath) if err != nil { t.Fatal(err) } if diff := cmp.Diff(want, got, + cmp.AllowUnexported(internal.UnitSymbol{}, internal.SymbolHistory{}), cmpopts.IgnoreFields(internal.UnitSymbol{}, "builds")); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) } } -func unitSymbolsFromAPI(api []*internal.Symbol, version string) map[string]*internal.UnitSymbol { - nameToUnitSymbols := map[string]*internal.UnitSymbol{} +func symbolHistoryFromAPI(api []*internal.Symbol, version string) *internal.SymbolHistory { + sh := internal.NewSymbolHistory() updateSymbols(api, func(s *internal.SymbolMeta) error { - if _, ok := nameToUnitSymbols[s.Name]; !ok { - us := unitSymbolFromSymbolMeta(s, version, internal.BuildContextAll) - nameToUnitSymbols[s.Name] = us - } + sh.AddSymbol(*s, version, internal.BuildContextAll) return nil }) - return nameToUnitSymbols -} - -func unitSymbolFromSymbol(s *internal.Symbol, version string) *internal.UnitSymbol { - us := &internal.UnitSymbol{ - SymbolMeta: s.SymbolMeta, - } - us.AddBuildContext(internal.BuildContext{GOOS: s.GOOS, GOARCH: s.GOARCH}) - return us -} - -func unitSymbolFromSymbolMeta(sm *internal.SymbolMeta, version string, b internal.BuildContext) *internal.UnitSymbol { - us := &internal.UnitSymbol{ - SymbolMeta: *sm, - } - us.AddBuildContext(b) - return us + return sh } diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go index 33da003a..72efd278 100644 --- a/internal/postgres/unit.go +++ b/internal/postgres/unit.go @@ -540,13 +540,14 @@ func (db *DB) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, b } return &u, nil } - versionToNameToUnitSymbol, err := LegacyGetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path, + sh, err := GetSymbolHistoryWithPackageSymbols(ctx, db.db, um.Path, um.ModulePath) if err != nil { return nil, err } nameToVersion := map[string]string{} - for v, nts := range versionToNameToUnitSymbol { + for _, v := range sh.Versions() { + nts := sh.SymbolsAtVersion(v) for n := range nts { nameToVersion[n] = v } |
