@@ -314,28 +314,6 @@ func (db Database) GetTableInsensitiveAsOf(ctx *sql.Context, tableName string, a
314314 }
315315}
316316
317- // isDoltSystemTable checks if the current table is a dolt system table. If
318- // using the search path, also checks that dolt is the current schema or exists
319- // on the search path.
320- func (db Database ) isDoltSystemTable (ctx * sql.Context , tableName string ) bool {
321- if doltdb .HasDoltPrefix (tableName ) || ! resolve .UseSearchPath || db .schemaName == "dolt" {
322- return true
323- }
324-
325- if db .schemaName == "" {
326- schemasToSearch , err := resolve .SearchPath (ctx )
327- if err != nil {
328- return false
329- }
330- for _ , schemaName := range schemasToSearch {
331- if schemaName == "dolt" {
332- return true
333- }
334- }
335- }
336- return false
337- }
338-
339317func (db Database ) getTableInsensitive (ctx * sql.Context , head * doltdb.Commit , ds * dsess.DoltSession , root doltdb.RootValue , tblName string , asOf interface {}) (sql.Table , bool , error ) {
340318 lwrName := strings .ToLower (tblName )
341319
@@ -441,10 +419,14 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
441419
442420 var dt sql.Table
443421 found := false
422+ tname := doltdb.TableName {Name : lwrName , Schema : db .schemaName }
444423 switch lwrName {
445424 case doltdb .GetLogTableName (), doltdb .LogTableName :
446- // TODO: This should be moved once all the system tables are moved to the dolt schema
447- if db .isDoltSystemTable (ctx , lwrName ) {
425+ systemTable , err := resolve .SystemTable (ctx , tname , root )
426+ if err != nil {
427+ return nil , false , err
428+ }
429+ if systemTable {
448430 if head == nil {
449431 var err error
450432 head , err = ds .GetHeadCommit (ctx , db .RevisionQualifiedName ())
@@ -482,8 +464,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
482464 case doltdb .SchemaConflictsTableName :
483465 dt , found = dtables .NewSchemaConflictsTable (ctx , db .RevisionQualifiedName (), db .ddb ), true
484466 case doltdb .GetBranchesTableName (), doltdb .BranchesTableName :
485- // TODO: This should be moved once all the system tables are moved to the dolt schema
486- if db .isDoltSystemTable (ctx , lwrName ) {
467+ systemTable , err := resolve .SystemTable (ctx , tname , root )
468+ if err != nil {
469+ return nil , false , err
470+ }
471+ if systemTable {
487472 dt , found = dtables .NewBranchesTable (ctx , db ), true
488473 }
489474 case doltdb .RemoteBranchesTableName :
@@ -495,8 +480,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
495480 case doltdb .CommitAncestorsTableName :
496481 dt , found = dtables .NewCommitAncestorsTable (ctx , db .Name (), db .ddb ), true
497482 case doltdb .GetStatusTableName (), doltdb .StatusTableName :
498- // TODO: This should be moved once all the system tables are moved to the dolt schema
499- if db .isDoltSystemTable (ctx , lwrName ) {
483+ systemTable , err := resolve .SystemTable (ctx , tname , root )
484+ if err != nil {
485+ return nil , false , err
486+ }
487+ if systemTable {
500488 sess := dsess .DSessFromSess (ctx .Session )
501489 adapter := dsess .NewSessionStateAdapter (
502490 sess , db .RevisionQualifiedName (),
@@ -513,8 +501,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
513501 case doltdb .MergeStatusTableName :
514502 dt , found = dtables .NewMergeStatusTable (db .RevisionQualifiedName ()), true
515503 case doltdb .GetTagsTableName (), doltdb .TagsTableName :
516- // TODO: This should be moved once all the system tables are moved to the dolt schema
517- if db .isDoltSystemTable (ctx , lwrName ) {
504+ systemTable , err := resolve .SystemTable (ctx , tname , root )
505+ if err != nil {
506+ return nil , false , err
507+ }
508+ if systemTable {
518509 dt , found = dtables .NewTagsTable (ctx , db .ddb ), true
519510 }
520511 case dtables .AccessTableName :
@@ -543,8 +534,11 @@ func (db Database) getTableInsensitive(ctx *sql.Context, head *doltdb.Commit, ds
543534 dt , found = dtables .NewIgnoreTable (ctx , versionableTable ), true
544535 }
545536 case doltdb .GetDocTableName (), doltdb .DocTableName :
546- // TODO: This should be moved once all the system tables are moved to the dolt schema
547- if db .isDoltSystemTable (ctx , lwrName ) {
537+ systemTable , err := resolve .SystemTable (ctx , tname , root )
538+ if err != nil {
539+ return nil , false , err
540+ }
541+ if systemTable {
548542 if resolve .UseSearchPath && lwrName == doltdb .DocTableName {
549543 db .schemaName = "dolt"
550544 }
0 commit comments