Repository: dolthub/dolt
File: go/libraries/doltcore/sqle/database.go (Go)

Code before:
		return tblNames, nil
	}

	// TODO: Figure out way to remove filterDoltInternalTables
	return filterDoltInternalTables(tblNames, db.schemaName, showSystemTables), nil
}

func (db Database) SchemaName() string {
	return db.schemaName
}

// GetAllTableNames returns all user-space tables, including system tables in user space
// (e.g. dolt_docs, dolt_query_catalog).
func (db Database) GetAllTableNames(ctx *sql.Context, showSystemTables bool) ([]string, error) {
	root, err := db.GetRoot(ctx)
	if err != nil {
		return nil, err
	}

	return db.getAllTableNames(ctx, root, showSystemTables, true, doReadNonlocalTables)
}

func (db Database) getAllTableNames(ctx *sql.Context, root doltdb.RootValue, includeGeneratedSystemTables bool, includeRootObjects bool, includeNonlocalTables readNonlocalTablesFlag) ([]string, error) {
	var err error
	var result []string
	localNameSet := map[string]any{}
	// If we are in a schema-enabled session and the schema name is not set, we need to union all table names in all
	// schemas in the search_path
	if resolve.UseSearchPath && db.schemaName == "" {
		names, err := resolve.TablesOnSearchPath(ctx, root)
		if err != nil {
			return nil, err
		}
		// TODO: this method should probably return TableNames, but need to iron out the effective schema for system
		//  tables first
		result = doltdb.FlattenTableNames(names)
	} else {
		result, err = root.GetTableNames(ctx, db.schemaName, includeRootObjects)
		if err != nil {
			return nil, err
		}
		for _, nameStr := range result {
			localNameSet[nameStr] = nil
		}
	}

	if includeGeneratedSystemTables {
		// TODO: this should work on the current schema only, if there is one
		// TODO: this is getting called with showSystemTables = true, which seems wrong in most cases
		systemTables, err := resolve.GetGeneratedSystemTables(ctx, root)
		if err != nil {

Review comment (suggestion):
```suggestion
	localNameSet := map[string]struct{}
```

Code after:
		return tblNames, nil
	}

	// TODO: Figure out way to remove filterDoltInternalTables
	return filterDoltInternalTables(tblNames, db.schemaName, showSystemTables), nil
}

func (db Database) SchemaName() string {
	return db.schemaName
}

// GetAllTableNames returns all user-space tables, including system tables in user space
// (e.g. dolt_docs, dolt_query_catalog).
func (db Database) GetAllTableNames(ctx *sql.Context, showSystemTables bool) ([]string, error) {
	root, err := db.GetRoot(ctx)
	if err != nil {
		return nil, err
	}

	return db.getAllTableNames(ctx, root, showSystemTables, true, doReadNonlocalTables)
}

func (db Database) getAllTableNames(ctx *sql.Context, root doltdb.RootValue, includeGeneratedSystemTables bool, includeRootObjects bool, includeNonlocalTables readNonlocalTablesFlag) ([]string, error) {
	var err error
	var result []string
	localNameSet := map[string]struct{}{}
	// If we are in a schema-enabled session and the schema name is not set, we need to union all table names in all
	// schemas in the search_path
	if resolve.UseSearchPath && db.schemaName == "" {
		names, err := resolve.TablesOnSearchPath(ctx, root)
		if err != nil {
			return nil, err
		}
		// TODO: this method should probably return TableNames, but need to iron out the effective schema for system
		//  tables first
		result = doltdb.FlattenTableNames(names)
	} else {
		result, err = root.GetTableNames(ctx, db.schemaName, includeRootObjects)
		if err != nil {
			return nil, err
		}
		for _, nameStr := range result {
			localNameSet[nameStr] = struct{}{}
		}
	}

	if includeGeneratedSystemTables {
		// TODO: this should work on the current schema only, if there is one
		// TODO: this is getting called with showSystemTables = true, which seems wrong in most cases
		systemTables, err := resolve.GetGeneratedSystemTables(ctx, root)
		if err != nil {