Skip to content

Commit

Permalink
Simplify the generatedSystemTables const
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 committed Feb 18, 2025
1 parent f9a5d44 commit 726782e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 86 deletions.
86 changes: 12 additions & 74 deletions go/libraries/doltcore/doltdb/system_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func GetPersistedSystemTables(ctx context.Context, root RootValue) ([]string, er

// GetGeneratedSystemTables returns table names of all generated system tables.
func GetGeneratedSystemTables(ctx context.Context, root RootValue) ([]string, error) {
s := set.NewStrSet(getGeneratedSystemTables())
s := set.NewStrSet(generatedSystemTables)

tn, err := root.GetTableNames(ctx, DefaultSchemaName)
if err != nil {
Expand Down Expand Up @@ -206,19 +206,17 @@ var getWriteableSystemTables = func() []string {
}
}

var getGeneratedSystemTables = func() []string {
return []string{
GetBranchesTableName(),
GetRemoteBranchesTableName(),
GetLogTableName(),
GetTableOfTablesInConflictName(),
GetTableOfTablesWithViolationsName(),
GetCommitsTableName(),
GetCommitAncestorsTableName(),
GetStatusTableName(),
GetRemotesTableName(),
GetHelpTableName(),
}
var generatedSystemTables = []string{
BranchesTableName,
RemoteBranchesTableName,
LogTableName,
TableOfTablesInConflictName,
TableOfTablesWithViolationsName,
CommitsTableName,
CommitAncestorsTableName,
StatusTableName,
RemotesTableName,
HelpTableName,
}

var generatedSystemTablePrefixes = []string{
Expand Down Expand Up @@ -306,46 +304,6 @@ const (
DoltWorkspaceTablePrefix = "dolt_workspace_"
)

// GetBranchesTableName returns the branches system table name
var GetBranchesTableName = func() string {
return BranchesTableName
}

// GetColumnDiffTableName returns the column diff system table name
var GetColumnDiffTableName = func() string {
return ColumnDiffTableName
}

// GetCommitAncestorsTableName returns the commit_ancestors system table name
var GetCommitAncestorsTableName = func() string {
return CommitAncestorsTableName
}

// GetCommitsTableName returns the commits system table name
var GetCommitsTableName = func() string {
return CommitsTableName
}

// GetTableOfTablesWithViolationsName returns the conflicts system table name
var GetTableOfTablesInConflictName = func() string {
return TableOfTablesInConflictName
}

// GetTableOfTablesWithViolationsName returns the constraint violations system table name
var GetTableOfTablesWithViolationsName = func() string {
return TableOfTablesWithViolationsName
}

// GetDiffTableName returns the diff system table name
var GetDiffTableName = func() string {
return DiffTableName
}

// GetLogTableName returns the log system table name
var GetLogTableName = func() string {
return LogTableName
}

// GetMergeStatusTableName returns the merge status system table name
var GetMergeStatusTableName = func() string {
return MergeStatusTableName
Expand All @@ -356,36 +314,16 @@ var GetRebaseTableName = func() string {
return RebaseTableName
}

// GetRemoteBranchesTableName returns the all-branches system table name
var GetRemoteBranchesTableName = func() string {
return RemoteBranchesTableName
}

// GetRemotesTableName returns the remotes system table name
var GetRemotesTableName = func() string {
return RemotesTableName
}

// GetSchemaConflictsTableName returns the schema conflicts system table name
var GetSchemaConflictsTableName = func() string {
return SchemaConflictsTableName
}

// GetStatusTableName returns the status system table name.
var GetStatusTableName = func() string {
return StatusTableName
}

// GetTagsTableName returns the tags table name
var GetTagsTableName = func() string {
return TagsTableName
}

// GetHelpTableName returns the help table name
var GetHelpTableName = func() string {
return HelpTableName
}

const (
// LogTableName is the log system table name
LogTableName = "dolt_log"
Expand Down
24 changes: 12 additions & 12 deletions go/libraries/doltcore/sqle/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
found := false
tname := doltdb.TableName{Name: lwrName, Schema: db.schemaName}
switch lwrName {
case doltdb.GetLogTableName(), doltdb.LogTableName:
case doltdb.LogTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
Expand All @@ -490,7 +490,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds

dt, found = dtables.NewLogTable(ctx, db.Name(), lwrName, db.ddb, head), true
}
case doltdb.DiffTableName, doltdb.GetDiffTableName():
case doltdb.DiffTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
Expand All @@ -506,7 +506,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds

dt, found = dtables.NewUnscopedDiffTable(ctx, db.Name(), lwrName, db.ddb, head), true
}
case doltdb.ColumnDiffTableName, doltdb.GetColumnDiffTableName():
case doltdb.ColumnDiffTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
Expand All @@ -522,15 +522,15 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds

dt, found = dtables.NewColumnDiffTable(ctx, db.Name(), lwrName, db.ddb, head), true
}
case doltdb.TableOfTablesInConflictName, doltdb.GetTableOfTablesInConflictName():
case doltdb.TableOfTablesInConflictName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
}
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewTableOfTablesInConflict(ctx, db.RevisionQualifiedName(), lwrName, db.ddb), true
}
case doltdb.TableOfTablesWithViolationsName, doltdb.GetTableOfTablesWithViolationsName():
case doltdb.TableOfTablesWithViolationsName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
Expand All @@ -546,47 +546,47 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewSchemaConflictsTable(ctx, db.RevisionQualifiedName(), lwrName, db.ddb), true
}
case doltdb.GetBranchesTableName(), doltdb.BranchesTableName:
case doltdb.BranchesTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
}
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewBranchesTable(ctx, db, lwrName), true
}
case doltdb.RemoteBranchesTableName, doltdb.GetRemoteBranchesTableName():
case doltdb.RemoteBranchesTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
}
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewRemoteBranchesTable(ctx, db, lwrName), true
}
case doltdb.RemotesTableName, doltdb.GetRemotesTableName():
case doltdb.RemotesTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
}
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewRemotesTable(ctx, db.ddb, lwrName), true
}
case doltdb.CommitsTableName, doltdb.GetCommitsTableName():
case doltdb.CommitsTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
}
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewCommitsTable(ctx, db.Name(), lwrName, db.ddb), true
}
case doltdb.CommitAncestorsTableName, doltdb.GetCommitAncestorsTableName():
case doltdb.CommitAncestorsTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
}
if !resolve.UseSearchPath || isDoltgresSystemTable {
dt, found = dtables.NewCommitAncestorsTable(ctx, db.Name(), lwrName, db.ddb), true
}
case doltdb.GetStatusTableName(), doltdb.StatusTableName:
case doltdb.StatusTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
Expand Down Expand Up @@ -714,7 +714,7 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
return nil, false, err
}
dt = NewSchemaTable(backingTable)
case doltdb.GetHelpTableName(), doltdb.HelpTableName:
case doltdb.HelpTableName:
isDoltgresSystemTable, err := resolve.IsDoltgresSystemTable(ctx, tname, root)
if err != nil {
return nil, false, err
Expand Down

0 comments on commit 726782e

Please sign in to comment.