MCPcopy Create free account
hub / github.com/dolthub/doltgresql / IterTables

Method IterTables

core/rootvalue.go:534–571  ·  view source on GitHub ↗

IterTables implements the interface doltdb.RootValue.

(ctx context.Context, cb func(name doltdb.TableName, table *doltdb.Table, sch schema.Schema) (stop bool, err error))

Source from the content-addressed store, hash-verified

532
533// IterTables implements the interface doltdb.RootValue.
534func (root *RootValue) IterTables(ctx context.Context, cb func(name doltdb.TableName, table *doltdb.Table, sch schema.Schema) (stop bool, err error)) error {
535 schemaNames, err := schemaNames(ctx, root)
536 if err != nil {
537 return err
538 }
539
540 for _, schemaName := range schemaNames {
541 tm, err := root.getTableMap(ctx, schemaName)
542 if err != nil {
543 return err
544 }
545
546 err = tm.Iter(ctx, func(name string, addr hash.Hash) (bool, error) {
547 tbl, exists, err := doltdb.GetTable(ctx, root, addr)
548 if !exists {
549 return false, errors.Errorf("cannot find table %s from addr", name)
550 }
551 if err != nil {
552 return true, err
553 }
554
555 sch, err := tbl.GetSchema(ctx)
556 if err != nil {
557 return true, err
558 }
559
560 return cb(doltdb.TableName{
561 Name: name,
562 Schema: schemaName,
563 }, tbl, sch)
564 })
565 if err != nil {
566 return err
567 }
568 }
569
570 return nil
571}
572
573// schemaNames returns all names of all schemas which may have tables
574func schemaNames(ctx context.Context, root doltdb.RootValue) ([]string, error) {

Callers 1

DebugStringMethod · 0.95

Calls 6

getTableMapMethod · 0.95
schemaNamesFunction · 0.85
GetTableMethod · 0.80
ErrorfMethod · 0.65
IterMethod · 0.45
GetSchemaMethod · 0.45

Tested by

no test coverage detected