IterTables implements the interface doltdb.RootValue.
(ctx context.Context, cb func(name doltdb.TableName, table *doltdb.Table, sch schema.Schema) (stop bool, err error))
| 532 | |
| 533 | // IterTables implements the interface doltdb.RootValue. |
| 534 | func (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 |
| 574 | func schemaNames(ctx context.Context, root doltdb.RootValue) ([]string, error) { |
no test coverage detected