Skip to content

Commit

Permalink
Added additional function to RootValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydrocharged committed May 14, 2024
1 parent 0f70ca7 commit 59d2f64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions go/libraries/doltcore/doltdb/root_val.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ type RootValue interface {
GetTableHash(ctx context.Context, tName string) (hash.Hash, bool, error)
// GetTableNames retrieves the lists of all tables for a RootValue
GetTableNames(ctx context.Context, schemaName string) ([]string, error)
// HandlePostMerge handles merging for any root elements that are not handled by the standard merge workflow. This
// is called at the end of the standard merge workflow. The calling root is the merged root, so it is valid to
// return it if no further merge work needs to be done. This is primarily used by Doltgres.
HandlePostMerge(ctx context.Context, ourRoot, theirRoot, ancRoot RootValue) (RootValue, error)
// HasTable returns whether the root has a table with the given case-sensitive name.
HasTable(ctx context.Context, tName string) (bool, error)
// IterTables calls the callback function cb on each table in this RootValue.
Expand Down Expand Up @@ -277,6 +281,10 @@ func (root *rootValue) SetCollation(ctx context.Context, collation schema.Collat
return root.withStorage(newStorage), nil
}

func (root *rootValue) HandlePostMerge(ctx context.Context, ourRoot, theirRoot, ancRoot RootValue) (RootValue, error) {
return root, nil
}

func (root *rootValue) HasTable(ctx context.Context, tName string) (bool, error) {
tableMap, err := root.st.GetTablesMap(ctx, root.vrw, root.ns, DefaultSchemaName)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions go/libraries/doltcore/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ func MergeRoots(
return nil, err
}

mergedRoot, err = mergedRoot.HandlePostMerge(ctx, ourRoot, theirRoot, ancRoot)
if err != nil {
return nil, err
}

h, err := merger.rightSrc.HashOf()
if err != nil {
return nil, err
Expand Down

0 comments on commit 59d2f64

Please sign in to comment.