Documentation ¶
Index ¶
- Constants
- Variables
- func AddConstraintViolations(ctx context.Context, newRoot, baseRoot *doltdb.RootValue, tables *set.StrSet) (*doltdb.RootValue, *set.StrSet, error)
- func AutoResolveAll(ctx context.Context, dEnv *env.DoltEnv, autoResolver AutoResolver) error
- func AutoResolveTables(ctx context.Context, dEnv *env.DoltEnv, autoResolver AutoResolver, ...) error
- func ExecNoFFMerge(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)
- func ExecuteFFMerge(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) error
- func ExecuteMerge(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)
- func GetDocsInConflict(ctx context.Context, workingRoot *doltdb.RootValue, docs doltdocs.Docs) (*diff.DocDiffs, error)
- func GetTablesInConflict(ctx context.Context, roots doltdb.Roots) (workingInConflict, stagedInConflict, headInConflict []string, err error)
- func GetTablesWithConstraintViolations(ctx context.Context, roots doltdb.Roots) (workingViolations, stagedViolations, headViolations []string, err error)
- func MayHaveConstraintViolations(ctx context.Context, ancestor, merged *doltdb.RootValue) (bool, error)
- func MergeBase(ctx context.Context, left, right *doltdb.Commit) (base hash.Hash, err error)
- func MergeCommitSpec(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)
- func MergeCommits(ctx context.Context, commit, mergeCommit *doltdb.Commit, opts editor.Options) (*doltdb.RootValue, map[string]*MergeStats, error)
- func MergeRoots(ctx context.Context, ourRoot, theirRoot, ancRoot *doltdb.RootValue, ...) (*doltdb.RootValue, map[string]*MergeStats, error)
- func MergeWouldStompChanges(ctx context.Context, roots doltdb.Roots, mergeCommit *doltdb.Commit) ([]string, map[string]hash.Hash, error)
- func Ours(key types.Value, cnf conflict.Conflict) (types.Value, error)
- func ResolveTable(ctx context.Context, vrw types.ValueReadWriter, tblName string, ...) (*doltdb.RootValue, error)
- func Revert(ctx context.Context, ddb *doltdb.DoltDB, root *doltdb.RootValue, ...) (*doltdb.RootValue, string, error)
- func Theirs(key types.Value, cnf conflict.Conflict) (types.Value, error)
- type AutoResolveStats
- type AutoResolver
- type ChkConflict
- type ColConflict
- type ConflictReader
- func (cr *ConflictReader) Close() error
- func (cr *ConflictReader) GetJoiner() *rowconv.Joiner
- func (cr *ConflictReader) GetKeyForConflict(ctx context.Context, r row.Row) (types.Value, error)
- func (cr *ConflictReader) GetSchema() schema.Schema
- func (cr *ConflictReader) NextConflict(ctx context.Context) (row.Row, pipeline.ImmutableProperties, error)
- type ConflictSink
- type ConflictSplitter
- type FKConflict
- type IdxConflict
- type MergeSpec
- type MergeStats
- type MergeVersion
- type Merger
- type MutableSecondaryIdx
- func (m MutableSecondaryIdx) DeleteEntry(ctx context.Context, key val.Tuple, value val.Tuple) error
- func (m MutableSecondaryIdx) InsertEntry(ctx context.Context, key, newValue val.Tuple) error
- func (m MutableSecondaryIdx) Map(ctx context.Context) (prolly.Map, error)
- func (m MutableSecondaryIdx) UpdateEntry(ctx context.Context, key, currValue, newValue val.Tuple) error
- type SchemaConflict
- type TableMergeOp
Constants ¶
const ( TagCollision conflictKind = iota NameCollision ColumnCollision InvalidCheckCollision DeletedCheckCollision )
Variables ¶
var EmptySchConflicts = SchemaConflict{}
var ErrFailedToDetermineMergeability = errors.New("failed to determine mergeability")
var ErrFailedToDetermineUnstagedDocs = errors.New("failed to determine unstaged docs")
var ErrFailedToReadDatabase = errors.New("failed to read database")
var ErrFastForward = errors.New("fast forward")
var ErrMergeFailedToUpdateDocs = errors.New("failed to update docs to the new working root")
var ErrMergeFailedToUpdateRepoState = errors.New("unable to execute repo state update")
var ErrMergeWithDifferentPkSets = errors.New("error: cannot merge two tables with different primary key sets")
var ErrSameTblAddedTwice = errors.New("table with same name added in 2 commits can't be merged")
var ErrTableDeletedAndModified = errors.New("conflict: table with same name deleted and modified ")
var WriteBufSize = 256 * 1024
Functions ¶
func AddConstraintViolations ¶
func AddConstraintViolations(ctx context.Context, newRoot, baseRoot *doltdb.RootValue, tables *set.StrSet) (*doltdb.RootValue, *set.StrSet, error)
AddConstraintViolations adds all constraint violations to each table.
func AutoResolveAll ¶
func AutoResolveTables ¶
func ExecNoFFMerge ¶
func ExecuteFFMerge ¶
func ExecuteMerge ¶
func GetDocsInConflict ¶
func GetTablesInConflict ¶
func MayHaveConstraintViolations ¶
func MayHaveConstraintViolations(ctx context.Context, ancestor, merged *doltdb.RootValue) (bool, error)
MayHaveConstraintViolations returns whether the given roots may have constraint violations. For example, a fast forward merge that does not involve any tables with foreign key constraints or check constraints will not be able to generate constraint violations. Unique key constraint violations would be caught during the generation of the merged root, therefore it is not a factor for this function.
func MergeCommitSpec ¶
func MergeCommitSpec(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)
TODO forcing a commit with a constrain violation should warn users that subsequest
FF merges will not surface constraint violations on their own; constraint verify --all is required to reify violations.
func MergeCommits ¶
func MergeRoots ¶
func MergeWouldStompChanges ¶
func ResolveTable ¶
func Revert ¶
func Revert(ctx context.Context, ddb *doltdb.DoltDB, root *doltdb.RootValue, commits []*doltdb.Commit, opts editor.Options) (*doltdb.RootValue, string, error)
Revert is a convenience function for a three-way merge. In particular, given some root and a collection of commits that are all parents of the root value, this applies a three-way merge with the following characteristics (assuming a commit is HEAD~1):
Base: HEAD~1 Ours: root Theirs: HEAD~2
The root is updated with the merged result, and this process is repeated for each commit given, in the order given. Currently, we error on conflicts or constraint violations generated by the merge.
Types ¶
type AutoResolveStats ¶
type AutoResolveStats struct { }
type AutoResolver ¶
type ChkConflict ¶
func (ChkConflict) String ¶
func (c ChkConflict) String() string
type ColConflict ¶
func (ColConflict) String ¶
func (c ColConflict) String() string
type ConflictReader ¶
type ConflictReader struct {
// contains filtered or unexported fields
}
ConflictReader is a class providing a NextConflict function which can be used in a pipeline as a pipeline.SourceFunc, or it can be used to read each conflict
func NewConflictReader ¶
NewConflictReader returns a new conflict reader for a given table
func (*ConflictReader) Close ¶
func (cr *ConflictReader) Close() error
Close should release resources being held
func (*ConflictReader) GetJoiner ¶
func (cr *ConflictReader) GetJoiner() *rowconv.Joiner
GetJoiner returns the joiner used to join a row with its base, and merge versions
func (*ConflictReader) GetKeyForConflict ¶
GetKeyForConflicts returns the pk for a conflict row
func (*ConflictReader) GetSchema ¶
func (cr *ConflictReader) GetSchema() schema.Schema
GetSchema gets the schema of the rows that this reader will return
func (*ConflictReader) NextConflict ¶
func (cr *ConflictReader) NextConflict(ctx context.Context) (row.Row, pipeline.ImmutableProperties, error)
NextConflict can be called successively to retrieve the conflicts in a table. Once all conflicts have been returned io.EOF will be returned in the error field. This can be used in a pipeline, or to iterate through all the conflicts in a table.
type ConflictSink ¶
type ConflictSink struct {
// contains filtered or unexported fields
}
func NewConflictSink ¶
func NewConflictSink(wr io.WriteCloser, sch schema.Schema, colSep string) (*ConflictSink, error)
func (*ConflictSink) Close ¶
func (cs *ConflictSink) Close() error
Close should release resources being held
func (*ConflictSink) GetSchema ¶
func (cs *ConflictSink) GetSchema() schema.Schema
GetSchema gets the schema of the rows that this writer writes
func (*ConflictSink) ProcRowWithProps ¶
func (cs *ConflictSink) ProcRowWithProps(r row.Row, props pipeline.ReadableMap) error
type ConflictSplitter ¶
type ConflictSplitter struct {
// contains filtered or unexported fields
}
ConflictsSplitter splits a conflict into base, ours, and their version of a row
func NewConflictSplitter ¶
func NewConflictSplitter(ctx context.Context, vrw types.ValueReadWriter, joiner *rowconv.Joiner) (ConflictSplitter, error)
NewConflictSplitter creates a new ConflictSplitter
func (ConflictSplitter) GetSchema ¶
func (ds ConflictSplitter) GetSchema() schema.Schema
GetSchema returns the common schema which all rows will share
func (ConflictSplitter) SplitConflicts ¶
func (ds ConflictSplitter) SplitConflicts(inRow row.Row, _ pipeline.ReadableMap) (rowData []*pipeline.TransformedRowResult, badRowDetails string)
SplitConflicts takes a conflict row and splits it into ours, theirs, and base versions and provides pipeline properties which can be used to distinguished which is which and what type of conflict occurred.
type FKConflict ¶
type FKConflict struct { Kind conflictKind Ours, Theirs doltdb.ForeignKey }
func ForeignKeysMerge ¶
func ForeignKeysMerge(ctx context.Context, mergedRoot, ourRoot, theirRoot, ancRoot *doltdb.RootValue) (*doltdb.ForeignKeyCollection, []FKConflict, error)
ForeignKeysMerge performs a three-way merge of (ourRoot, theirRoot, ancRoot) and using mergeRoot to validate FKs.
type IdxConflict ¶
func (IdxConflict) String ¶
func (c IdxConflict) String() string
type MergeSpec ¶
type MergeStats ¶
type MergeVersion ¶
type MergeVersion int
MergeVersion defines which version a value of a row corresponds to
const ( // BaseVersion represents the state of a row at the most recent ancestor BaseVersion MergeVersion = iota // OurVersion represents the state of a row on our branch that is being merged into OurVersion // TheirVersion represents the state of a row on their branch which we are merging TheirVersion // Blank is used for displaying a row without a version label Blank )
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
type MutableSecondaryIdx ¶
type MutableSecondaryIdx struct { Name string // contains filtered or unexported fields }
MutableSecondaryIdx wraps a prolly.MutableMap of a secondary table index. It provides the InsertEntry, UpdateEntry, and DeleteEntry functions which can be used to modify the index based on a modification to corresponding primary row.
func NewMutableSecondaryIdx ¶
func NewMutableSecondaryIdx(m prolly.Map, sch schema.Schema, index schema.Index, syncPool pool.BuffPool) MutableSecondaryIdx
NewMutableSecondaryIdx returns a MutableSecondaryIdx. |m| is the secondary idx data.
func (MutableSecondaryIdx) DeleteEntry ¶
DeleteEntry deletes a secondary index entry given they key and value of the primary row.
func (MutableSecondaryIdx) InsertEntry ¶
InsertEntry inserts a secondary index entry given the key and new value of the primary row.
func (MutableSecondaryIdx) Map ¶
Map returns the finalized prolly.Map of the underlying prolly.MutableMap.
func (MutableSecondaryIdx) UpdateEntry ¶
func (m MutableSecondaryIdx) UpdateEntry(ctx context.Context, key, currValue, newValue val.Tuple) error
UpdateEntry modifies the corresponding secondary index entry given the key and curr/new values of the primary row.
type SchemaConflict ¶
type SchemaConflict struct { TableName string ColConflicts []ColConflict IdxConflicts []IdxConflict ChkConflicts []ChkConflict }
func SchemaMerge ¶
func SchemaMerge(ourSch, theirSch, ancSch schema.Schema, tblName string) (sch schema.Schema, sc SchemaConflict, err error)
SchemaMerge performs a three-way merge of ourSch, theirSch, and ancSch.
func (SchemaConflict) AsError ¶
func (sc SchemaConflict) AsError() error
func (SchemaConflict) Count ¶
func (sc SchemaConflict) Count() int
type TableMergeOp ¶
type TableMergeOp int
const ( TableUnmodified TableMergeOp = iota TableAdded TableRemoved TableModified )