Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions server/tables/pgcatalog/pg_catalog_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/dolthub/doltgresql/core/id"
"github.com/dolthub/doltgresql/core/sequences"
"github.com/dolthub/doltgresql/server/functions"
pgtypes "github.com/dolthub/doltgresql/server/types"
)

// pgNamespace represents a row in the pg_namespace table.
Expand All @@ -48,6 +47,9 @@ type pgCatalogCache struct {
// pg_classes
pgClasses *pgClassCache

// pg_type
pgTypes *pgTypeCache

// pg_constraints
pgConstraints *pgConstraintCache

Expand All @@ -72,10 +74,6 @@ type pgCatalogCache struct {
views []sql.ViewDefinition
viewSchemas []string

// pg_types
types []*pgtypes.DoltgresType
schemasToOid map[string]id.Namespace

// pg_tables
tables []sql.Table
systemTables []doltdb.TableName
Expand Down Expand Up @@ -103,6 +101,28 @@ func (p pgClassCache) getIndex(name string) *inMemIndexStorage[*pgClass] {

var _ BTreeStorageAccess[*pgClass] = &pgClassCache{}

// pgTypeCache holds cached data for the pg_type table, including two btree indexes for fast lookups by OID and
// by typname
type pgTypeCache struct {
types []*pgType
nameIdx *inMemIndexStorage[*pgType]
oidIdx *inMemIndexStorage[*pgType]
}

// getIndex implements BTreeStorageAccess.
func (p pgTypeCache) getIndex(name string) *inMemIndexStorage[*pgType] {
switch name {
case PgTypeOidIndex:
return p.oidIdx
case PgTypnameIndex:
return p.nameIdx
default:
panic("unknown pg_type index: " + name)
}
}

var _ BTreeStorageAccess[*pgType] = &pgTypeCache{}

// pgIndexCache holds cached data for the pg_index table, including two btree indexes for fast lookups by index OID
type pgIndexCache struct {
indexes []*pgIndex
Expand Down
Loading
Loading