diff --git a/go/libraries/doltcore/doltdb/system_table.go b/go/libraries/doltcore/doltdb/system_table.go index e42a1ec061..1a6af4a256 100644 --- a/go/libraries/doltcore/doltdb/system_table.go +++ b/go/libraries/doltcore/doltdb/system_table.go @@ -120,7 +120,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(generatedSystemTables) + s := set.NewStrSet(getGeneratedSystemTables()) tn, err := root.GetTableNames(ctx, DefaultSchemaName) if err != nil { @@ -148,16 +148,18 @@ var getWriteableSystemTables = func() []string { } } -var generatedSystemTables = []string{ - BranchesTableName, - RemoteBranchesTableName, - LogTableName, - TableOfTablesInConflictName, - TableOfTablesWithViolationsName, - CommitsTableName, - CommitAncestorsTableName, - StatusTableName, - RemotesTableName, +var getGeneratedSystemTables = func() []string { + return []string{ + GetBranchesTableName(), + RemoteBranchesTableName, + GetLogTableName(), + TableOfTablesInConflictName, + TableOfTablesWithViolationsName, + CommitsTableName, + CommitAncestorsTableName, + StatusTableName, + RemotesTableName, + } } var generatedSystemTablePrefixes = []string{ @@ -176,7 +178,7 @@ const ( ReadmeDoc = "README.md" ) -// DocTableName is the name of the dolt table containing documents such as the license and readme +// GetDocTableName returns the name of the dolt table containing documents such as the license and readme var GetDocTableName = func() string { return "dolt_docs" } @@ -243,10 +245,17 @@ const ( DoltWorkspaceTablePrefix = "dolt_workspace_" ) -const ( - // LogTableName is the log system table name - LogTableName = "dolt_log" +// GetBranchesTableName returns the branches system table name +var GetBranchesTableName = func() string { + return "dolt_branches" +} +// GetLogTableName returns the log system table name +var GetLogTableName = func() string { + return "dolt_log" +} + +const ( // DiffTableName is the name of the table with a map of commits to tables changed DiffTableName = "dolt_diff" @@ -262,9 +271,6 @@ const ( // SchemaConflictsTableName is the schema conflicts system table name SchemaConflictsTableName = "dolt_schema_conflicts" - // BranchesTableName is the branches system table name - BranchesTableName = "dolt_branches" - // RemoteBranchesTableName is the all-branches system table name RemoteBranchesTableName = "dolt_remote_branches" diff --git a/go/libraries/doltcore/sqle/database.go b/go/libraries/doltcore/sqle/database.go index 27391a6ce1..085b41ac5b 100644 --- a/go/libraries/doltcore/sqle/database.go +++ b/go/libraries/doltcore/sqle/database.go @@ -420,7 +420,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds var dt sql.Table found := false switch lwrName { - case doltdb.LogTableName: + case doltdb.GetLogTableName(): + // TODO: This should be moved once all the system tables are moved to the dolt schema + if resolve.UseSearchPath && db.schemaName != "dolt" { + return nil, false, nil + } if head == nil { var err error head, err = ds.GetHeadCommit(ctx, db.RevisionQualifiedName()) @@ -456,7 +460,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds dt, found = dtables.NewTableOfTablesConstraintViolations(ctx, root), true case doltdb.SchemaConflictsTableName: dt, found = dtables.NewSchemaConflictsTable(ctx, db.RevisionQualifiedName(), db.ddb), true - case doltdb.BranchesTableName: + case doltdb.GetBranchesTableName(): + // TODO: This should be moved once all the system tables are moved to the dolt schema + if resolve.UseSearchPath && db.schemaName != "dolt" { + return nil, false, nil + } dt, found = dtables.NewBranchesTable(ctx, db), true case doltdb.RemoteBranchesTableName: dt, found = dtables.NewRemoteBranchesTable(ctx, db), true @@ -509,6 +517,10 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds dt, found = dtables.NewIgnoreTable(ctx, versionableTable), true } case doltdb.GetDocTableName(): + // TODO: This should be moved once all the system tables are moved to the dolt schema + if resolve.UseSearchPath && db.schemaName != "dolt" { + return nil, false, nil + } backingTable, _, err := db.getTable(ctx, root, doltdb.GetDocTableName()) if err != nil { return nil, false, err @@ -952,7 +964,8 @@ func (db Database) getAllTableNames(ctx *sql.Context, root doltdb.RootValue) ([] func filterDoltInternalTables(tblNames []string) []string { result := []string{} for _, tbl := range tblNames { - if !doltdb.HasDoltPrefix(tbl) { + // TODO: Need to consider dolt schema + if !doltdb.HasDoltPrefix(tbl) && tbl != doltdb.GetBranchesTableName() && tbl != doltdb.GetLogTableName() { result = append(result, tbl) } } diff --git a/go/libraries/doltcore/sqle/dtables/branches_table.go b/go/libraries/doltcore/sqle/dtables/branches_table.go index 371345af39..d74fb8c078 100644 --- a/go/libraries/doltcore/sqle/dtables/branches_table.go +++ b/go/libraries/doltcore/sqle/dtables/branches_table.go @@ -66,27 +66,27 @@ func (bt *BranchesTable) RowCount(_ *sql.Context) (uint64, bool, error) { return branchesDefaultRowCount, false, nil } -// Name is a sql.Table interface function which returns the name of the table which is defined by the constant -// BranchesTableName +// Name is a sql.Table interface function which returns the name of the table +// which is defined by the function GetBranchesTableName() func (bt *BranchesTable) Name() string { if bt.remote { return doltdb.RemoteBranchesTableName } - return doltdb.BranchesTableName + return doltdb.GetBranchesTableName() } -// String is a sql.Table interface function which returns the name of the table which is defined by the constant -// BranchesTableName +// String is a sql.Table interface function which returns the name of the table +// which is defined by the function GetBranchesTableName() func (bt *BranchesTable) String() string { if bt.remote { return doltdb.RemoteBranchesTableName } - return doltdb.BranchesTableName + return doltdb.GetBranchesTableName() } // Schema is a sql.Table interface function that gets the sql.Schema of the branches system table func (bt *BranchesTable) Schema() sql.Schema { - tableName := doltdb.BranchesTableName + tableName := doltdb.GetBranchesTableName() if bt.remote { tableName = doltdb.RemoteBranchesTableName } diff --git a/go/libraries/doltcore/sqle/dtables/log_table.go b/go/libraries/doltcore/sqle/dtables/log_table.go index 01be17ad4e..bfdd08d284 100644 --- a/go/libraries/doltcore/sqle/dtables/log_table.go +++ b/go/libraries/doltcore/sqle/dtables/log_table.go @@ -74,25 +74,25 @@ func (dt *LogTable) RowCount(ctx *sql.Context) (uint64, bool, error) { } // Name is a sql.Table interface function which returns the name of the table which is defined by the constant -// LogTableName +// GetLogTableName() func (dt *LogTable) Name() string { - return doltdb.LogTableName + return doltdb.GetLogTableName() } // String is a sql.Table interface function which returns the name of the table which is defined by the constant -// LogTableName +// GetLogTableName() func (dt *LogTable) String() string { - return doltdb.LogTableName + return doltdb.GetLogTableName() } // Schema is a sql.Table interface function that gets the sql.Schema of the log system table. func (dt *LogTable) Schema() sql.Schema { return []*sql.Column{ - {Name: "commit_hash", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: true, DatabaseSource: dt.dbName}, - {Name: "committer", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, - {Name: "email", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, - {Name: "date", Type: types.Datetime, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, - {Name: "message", Type: types.Text, Source: doltdb.LogTableName, PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "commit_hash", Type: types.Text, Source: doltdb.GetLogTableName(), PrimaryKey: true, DatabaseSource: dt.dbName}, + {Name: "committer", Type: types.Text, Source: doltdb.GetLogTableName(), PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "email", Type: types.Text, Source: doltdb.GetLogTableName(), PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "date", Type: types.Datetime, Source: doltdb.GetLogTableName(), PrimaryKey: false, DatabaseSource: dt.dbName}, + {Name: "message", Type: types.Text, Source: doltdb.GetLogTableName(), PrimaryKey: false, DatabaseSource: dt.dbName}, } }