doltdb

package
v0.40.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 37 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// DocTableName is the name of the dolt table containing documents such as the license and readme
	DocTableName = "dolt_docs"
	// DocPkColumnName is the name of the pk column in the docs table
	DocPkColumnName = "doc_name"
	//DocTextColumnName is the name of the column containing the document contents in the docs table
	DocTextColumnName = "doc_text"
)
View Source
const (
	// DoltQueryCatalogTableName is the name of the query catalog table
	DoltQueryCatalogTableName = "dolt_query_catalog"

	// QueryCatalogIdCol is the name of the primary key column of the query catalog table
	QueryCatalogIdCol = "id"

	// QueryCatalogOrderCol is the column containing the order of the queries in the catalog
	QueryCatalogOrderCol = "display_order"

	// QueryCatalogNameCol is the name of the column containing the name of a query in the catalog
	QueryCatalogNameCol = "name"

	// QueryCatalogQueryCol is the name of the column containing the query of a catalog entry
	QueryCatalogQueryCol = "query"

	// QueryCatalogDescriptionCol is the name of the column containing the description of a query in the catalog
	QueryCatalogDescriptionCol = "description"
)
View Source
const (
	// SchemasTableName is the name of the dolt schema fragment table
	SchemasTableName = "dolt_schemas"
	// SchemasTablesIdCol is an incrementing integer that represents the insertion index.
	SchemasTablesIdCol = "id"
	// Currently: `view` or `trigger`.
	SchemasTablesTypeCol = "type"
	// The name of the database entity.
	SchemasTablesNameCol = "name"
	// The schema fragment associated with the database entity.
	// For example, the SELECT statement for a CREATE VIEW.
	SchemasTablesFragmentCol = "fragment"
	// The extra information for schema; currently contains creation time for triggers and views
	SchemasTablesExtraCol = "extra"
	// The name of the index that is on the table.
	SchemasTablesIndexName = "fragment_name"
)
View Source
const (
	// DoltBlameViewPrefix is the prefix assigned to all the generated blame tables
	DoltBlameViewPrefix = "dolt_blame_"
	// DoltHistoryTablePrefix is the prefix assigned to all the generated history tables
	DoltHistoryTablePrefix = "dolt_history_"
	// DoltDiffTablePrefix is the prefix assigned to all the generated diff tables
	DoltDiffTablePrefix = "dolt_diff_"
	// DoltCommitDiffTablePrefix is the prefix assigned to all the generated commit diff tables
	DoltCommitDiffTablePrefix = "dolt_commit_diff_"
	// DoltConfTablePrefix is the prefix assigned to all the generated conflict tables
	DoltConfTablePrefix = "dolt_conflicts_"
	// DoltConstViolTablePrefix is the prefix assigned to all the generated constraint violation tables
	DoltConstViolTablePrefix = "dolt_constraint_violations_"
)
View Source
const (
	// LogTableName is the log system table name
	LogTableName = "dolt_log"

	// DiffTableName is the name of the table with a map of commits to tables changed
	DiffTableName = "dolt_diff"

	// TableOfTablesInConflictName is the conflicts system table name
	TableOfTablesInConflictName = "dolt_conflicts"

	// TableOfTablesWithViolationsName is the constraint violations system table name
	TableOfTablesWithViolationsName = "dolt_constraint_violations"

	// BranchesTableName is the branches system table name
	BranchesTableName = "dolt_branches"

	// RemotesTableName is the remotes system table name
	RemotesTableName = "dolt_remotes"

	// CommitsTableName is the commits system table name
	CommitsTableName = "dolt_commits"

	// CommitAncestorsTableName is the commit_ancestors system table name
	CommitAncestorsTableName = "dolt_commit_ancestors"

	// StatusTableName is the status system table name.
	StatusTableName = "dolt_status"
)
View Source
const (
	// ProceduresTableName is the name of the dolt stored procedures table.
	ProceduresTableName = "dolt_procedures"
	// ProceduresTableNameCol is the name of the stored procedure. Using CREATE PROCEDURE, will always be lowercase.
	ProceduresTableNameCol = "name"
	// ProceduresTableCreateStmtCol is the CREATE PROCEDURE statement for this stored procedure.
	ProceduresTableCreateStmtCol = "create_stmt"
	// ProceduresTableCreatedAtCol is the time that the stored procedure was created at, in UTC.
	ProceduresTableCreatedAtCol = "created_at"
	// ProceduresTableModifiedAtCol is the time that the stored procedure was last modified, in UTC.
	ProceduresTableModifiedAtCol = "modified_at"
)
View Source
const (
	// TableNameRegexStr is the regular expression that valid tables must match.
	TableNameRegexStr = `^[a-zA-Z]{1}$|^[a-zA-Z_]+[-_0-9a-zA-Z]*[0-9a-zA-Z]+$`
	// ForeignKeyNameRegexStr is the regular expression that valid foreign keys must match.
	// From the unquoted identifiers: https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
	// We also allow the '-' character from quoted identifiers.
	ForeignKeyNameRegexStr = `^[-$_0-9a-zA-Z]+$`
	// IndexNameRegexStr is the regular expression that valid indexes must match.
	// From the unquoted identifiers: https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
	// We also allow the '-' character from quoted identifiers.
	IndexNameRegexStr = `^[-$_0-9a-zA-Z]+$`
)
View Source
const (
	// DoltNamespace is the name prefix of dolt system tables. We reserve all tables that begin with dolt_ for system use.
	DoltNamespace = "dolt"
)

Variables

View Source
var ErrAlreadyOnBranch = errors.New("Already on branch")
View Source
var ErrAlreadyOnWorkspace = errors.New("Already on workspace")
View Source
var ErrBranchNotFound = errors.New("branch not found")
View Source
var ErrCannotDeleteLastBranch = errors.New("cannot delete the last branch")
View Source
var ErrFoundHashNotACommit = errors.New("the value retrieved for this hash is not a commit")
View Source
var ErrHashNotFound = errors.New("could not find a value for this hash")
View Source
var ErrInvBranchName = errors.New("not a valid user branch name")
View Source
var ErrInvHash = errors.New("not a valid hash")
View Source
var ErrInvTableName = errors.New("not a valid table name")
View Source
var ErrInvTagName = errors.New("not a valid user tag name")
View Source
var ErrInvWorkspaceName = errors.New("not a valid user workspace name")
View Source
var ErrInvalidAncestorSpec = errors.New("invalid ancestor spec")
View Source
var ErrInvalidBranchOrHash = errors.New("string is not a valid branch or hash")
View Source
var ErrInvalidHash = errors.New("string is not a valid hash")
View Source
var ErrIsAhead = errors.New("current fast forward from a to b. a is ahead of b already")
View Source
var ErrIsBehind = errors.New("cannot reverse from b to a. b is a is behind a already")
View Source
var ErrMergeActive = errors.New("merging is not possible because you have not committed an active merge")
View Source
var ErrNoCommonAncestor = errors.New("no common ancestor")
View Source
var (
	ErrNoConflictsResolved = errors.New("no conflicts resolved")
)
View Source
var ErrNoRootValAtHash = errors.New("there is no dolt root value at that hash")
View Source
var ErrNomsIO = errors.New("error reading from or writing to noms")
View Source
var ErrSystemTableCannotBeModified = errors.New("system tables cannot be dropped or altered")
View Source
var ErrTableExists = errors.New("table already exists")
View Source
var ErrTableNotFound = errors.New("table not found")
View Source
var ErrTagNotFound = errors.New("tag not found")
View Source
var ErrUnresolvedConflicts = errors.New("merge has unresolved conflicts. please use the dolt_conflicts table to resolve")
View Source
var ErrUnresolvedConstraintViolations = errors.New("merge has unresolved constraint violations. please use the dolt_constraint_violations table to resolve")
View Source
var ErrUpToDate = errors.New("up to date")
View Source
var ErrWorkingSetNotFound = errors.New("working set not found")
View Source
var ErrWorkspaceNotFound = errors.New("workspace not found")
View Source
var InMemDoltDB = "mem://"

InMemDoltDB stores the DoltDB db in memory and is primarily used for testing

View Source
var LocalDirDoltDB = "file://./" + dbfactory.DoltDataDir

LocalDirDoltDB stores the db in the current directory

Functions

func GetAllTableNames

func GetAllTableNames(ctx context.Context, root *RootValue) ([]string, error)

GetAllTableNames returns table names for all persisted and generated tables.

func GetGeneratedSystemTables

func GetGeneratedSystemTables(ctx context.Context, root *RootValue) ([]string, error)

GetGeneratedSystemTables returns table names of all generated system tables.

func GetNonSystemTableNames

func GetNonSystemTableNames(ctx context.Context, root *RootValue) ([]string, error)

GetNonSystemTableNames gets non-system table names

func GetPersistedSystemTables

func GetPersistedSystemTables(ctx context.Context, root *RootValue) ([]string, error)

GetPersistedSystemTables returns table names of all persisted system tables.

func GetRootValueSuperSchema

func GetRootValueSuperSchema(ctx context.Context, root *RootValue) (*schema.SuperSchema, error)

GetRootValueSuperSchema creates a SuperSchema with every column in history of root.

func GetSystemTableNames

func GetSystemTableNames(ctx context.Context, root *RootValue) ([]string, error)

GetSystemTableNames gets system table names

func GetUnreachableRootCause

func GetUnreachableRootCause(err error) error

func HasDoltPrefix

func HasDoltPrefix(s string) bool

HasDoltPrefix returns a boolean whether or not the provided string is prefixed with the DoltNamespace. Users should not be able to create tables in this reserved namespace.

func IsInvalidFormatErr

func IsInvalidFormatErr(err error) bool

func IsNotACommit

func IsNotACommit(err error) bool

func IsNotFoundErr

func IsNotFoundErr(err error) bool

func IsReadOnlySystemTable

func IsReadOnlySystemTable(name string) bool

IsReadOnlySystemTable returns whether the table name given is a system table that should not be included in command line output (e.g. dolt status) by default.

func IsRootValUnreachable

func IsRootValUnreachable(err error) bool

func IsValidBranchRef

func IsValidBranchRef(dref ref.DoltRef) bool

IsValidBranchRef validates that a BranchRef doesn't violate naming constraints.

func IsValidCommitHash

func IsValidCommitHash(s string) bool

func IsValidForeignKeyName

func IsValidForeignKeyName(name string) bool

IsValidForeignKeyName returns true if the name matches the regular expression ForeignKeyNameRegexStr.

func IsValidIndexName

func IsValidIndexName(name string) bool

IsValidIndexName returns true if the name matches the regular expression IndexNameRegexStr.

func IsValidTableName

func IsValidTableName(name string) bool

IsValidTableName returns true if the name matches the regular expression TableNameRegexStr. Table names must be composed of 1 or more letters and non-initial numerals, as well as the characters _ and -

func IsValidTagRef

func IsValidTagRef(dref ref.DoltRef) bool

IsValidTagRef validates that a TagRef doesn't violate naming constraints.

func IsValidUserBranchName

func IsValidUserBranchName(name string) bool

IsValidUserBranchName returns true if name isn't a valid commit hash, it is not named "head" and it matches the regular expression `[0-9a-z]+[-_0-9a-z]*[0-9a-z]+$`

func RunAsyncReplicationThreads

func RunAsyncReplicationThreads(bThreads *sql.BackgroundThreads, ch chan PushArg, destDB *DoltDB, tmpDir string, logger io.Writer) error

func TodoWorkingSetMeta

func TodoWorkingSetMeta() *datas.WorkingSetMeta

TodoWorkingSetMeta returns an incomplete WorkingSetMeta, suitable for methods that don't have the means to construct a real one. These should be considered temporary and cleaned up when possible, similar to Context.TODO

func UnionTableNames

func UnionTableNames(ctx context.Context, roots ...*RootValue) ([]string, error)

UnionTableNames returns an array of all table names in all roots passed as params.

func WriteValAndGetRef

func WriteValAndGetRef(ctx context.Context, vrw types.ValueReadWriter, val types.Value) (types.Ref, error)

Types

type AncestorSpec

type AncestorSpec struct {

	// SpecStr is string representation of the AncestorSpec
	SpecStr string

	// Instructions is a slice of parent indices. As you walk up the ancestor tree the first instruction is the index of
	// the parent that should be used.  The second index is the index of that parents parent that should be used. etc.
	// When you've exhausted the instructions you've reached the referenced commit.
	Instructions []int
}

AncestorSpec supports using ^, ^N, and ~N together to specify an ancestor of a commit.

^ after a commit spec means the first parent of that commit. ^<n> means the <n>th parent (i.e. <rev>^ is equivalent
  to <rev>^1). As a special rule.
~<n> after a commit spec means the commit object that is the <n>th generation grand-parent of the named commit
  object, following only the first parents. I.e. <rev>~3 is equivalent to <rev>^^^ which is equivalent to
  <rev>^1^1^1. See below for an illustration of the usage of this form.

func NewAncestorSpec

func NewAncestorSpec(s string) (*AncestorSpec, error)

NewAncestorSpec takes an input string and validates it and converts it to a set of instructions used in walking up the ancestor tree

func SplitAncestorSpec

func SplitAncestorSpec(s string) (string, *AncestorSpec, error)

SplitAncestorSpec takes a string that is a commit spec suffixed with an ancestor spec, and splits them apart. If there is no ancestor spec then only the commit spec will be returned and the ancestorSpec will have no empty.

type AsyncPushOnWriteHook

type AsyncPushOnWriteHook struct {
	// contains filtered or unexported fields
}

func NewAsyncPushOnWriteHook

func NewAsyncPushOnWriteHook(bThreads *sql.BackgroundThreads, destDB *DoltDB, tmpDir string, logger io.Writer) (*AsyncPushOnWriteHook, error)

NewAsyncPushOnWriteHook creates a AsyncReplicateHook

func (*AsyncPushOnWriteHook) Execute

Execute implements CommitHook, replicates head updates to the destDb field

func (*AsyncPushOnWriteHook) HandleError

func (ah *AsyncPushOnWriteHook) HandleError(ctx context.Context, err error) error

HandleError implements CommitHook

func (*AsyncPushOnWriteHook) SetLogger

func (ah *AsyncPushOnWriteHook) SetLogger(ctx context.Context, wr io.Writer) error

SetLogger implements CommitHook

type BranchWithHash

type BranchWithHash struct {
	Ref  ref.DoltRef
	Hash hash.Hash
}

type Commit

type Commit struct {
	// contains filtered or unexported fields
}

Commit contains information on a commit that was written to noms

func GetCommitAncestor

func GetCommitAncestor(ctx context.Context, cm1, cm2 *Commit) (*Commit, error)

func NewCommit

func NewCommit(ctx context.Context, vrw types.ValueReadWriter, commit *datas.Commit) (*Commit, error)

func (*Commit) CanFastForwardTo

func (c *Commit) CanFastForwardTo(ctx context.Context, new *Commit) (bool, error)

func (*Commit) CanFastReverseTo

func (c *Commit) CanFastReverseTo(ctx context.Context, new *Commit) (bool, error)

func (*Commit) DatasParents

func (c *Commit) DatasParents() []*datas.Commit

DatasParents returns the []*datas.Commit of the commit parents.

func (*Commit) GetAncestor

func (c *Commit) GetAncestor(ctx context.Context, as *AncestorSpec) (*Commit, error)

func (*Commit) GetCommitMeta

func (c *Commit) GetCommitMeta(ctx context.Context) (*datas.CommitMeta, error)

GetCommitMeta gets the metadata associated with the commit

func (*Commit) GetParent

func (c *Commit) GetParent(ctx context.Context, idx int) (*Commit, error)

func (*Commit) GetRootValue

func (c *Commit) GetRootValue(ctx context.Context) (*RootValue, error)

GetRootValue gets the RootValue of the commit.

func (*Commit) HashOf

func (c *Commit) HashOf() (hash.Hash, error)

HashOf returns the hash of the commit

func (*Commit) Height

func (c *Commit) Height() (uint64, error)

func (*Commit) NumParents

func (c *Commit) NumParents() (int, error)

NumParents gets the number of parents a commit has.

func (*Commit) ParentHashes

func (c *Commit) ParentHashes(ctx context.Context) ([]hash.Hash, error)

ParentHashes returns the commit hashes for all parent commits.

type CommitFilter

type CommitFilter func(context.Context, hash.Hash, *Commit) (filterOut bool, err error)

CommitFilter is a function that returns true if a commit should be filtered out, and false if it should be kept

type CommitHook

type CommitHook interface {
	// Execute is arbitrary read-only function whose arguments are new Dataset commit into a specific Database
	Execute(ctx context.Context, ds datas.Dataset, db datas.Database) error
	// HandleError is an bridge function to handle Execute errors
	HandleError(ctx context.Context, err error) error
	// SetLogger lets clients specify an output stream for HandleError
	SetLogger(ctx context.Context, wr io.Writer) error
}

CommitHook is an abstraction for executing arbitrary commands after atomic database commits

type CommitItr

type CommitItr interface {
	// Next returns the hash of the next commit, and a pointer to that commit.  Implementations of Next must handle
	// making sure the list of commits returned are unique.  When complete Next will return hash.Hash{}, nil, io.EOF
	Next(ctx context.Context) (hash.Hash, *Commit, error)

	// Reset the commit iterator back to the start
	Reset(ctx context.Context) error
}

CommitItr is an interface for iterating over a set of unique commits

func CommitItrForAllBranches

func CommitItrForAllBranches(ctx context.Context, ddb *DoltDB) (CommitItr, error)

CommitItrForAllBranches returns a CommitItr which will iterate over all commits in all branches in a DoltDB

func CommitItrForRoots

func CommitItrForRoots(ddb *DoltDB, rootCommits ...*Commit) CommitItr

CommitItrForRoots will return a CommitItr which will iterate over all ancestor commits of the provided rootCommits.

type CommitSpec

type CommitSpec struct {
	// contains filtered or unexported fields
}

CommitSpec handles three different types of string representations of commits. Commits can either be represented by the hash of the commit, a branch name, or using "head" to represent the latest commit of the current branch. An Ancestor spec can be appended to the end of any of these in order to reach commits that are in the ancestor tree of the referenced commit.

func NewCommitSpec

func NewCommitSpec(cSpecStr string) (*CommitSpec, error)

NewCommitSpec parses a string specifying a commit using dolt commit spec syntax and returns a |*CommitSpec|. A commit spec has a base commit and an optional ancestor specification. The syntax admits three types of base commit references: * head -- the literal string HEAD specifies the HEAD reference of the current working set. * a commit hash, like 46m0aqr8c1vuv76ml33cdtr8722hsbhn -- a fully specified commit hash. * a ref -- referring to a branch or tag reference in the current dolt database. Examples of branch refs include `master`, `heads/master`, `refs/heads/master`, `origin/master`, `refs/remotes/origin/master`. Examples of tag refs include `v1.0`, `tags/v1.0`, `refs/tags/v1.0`, `origin/v1.0`, `refs/remotes/origin/v1.0`.

A commit spec has an optional ancestor specification, which describes a traversal of commit parents, starting at the base commit, in order to arrive at the actually specified commit. See |AncestorSpec|. Examples of |CommitSpec|s: * HEAD * master * HEAD~ * remotes/origin/master~~ * refs/heads/my-feature-branch^2~

Constructing a |CommitSpec| does not mean the specified branch or commit exists. This carries a description of how to find the specified commit. See |doltdb.Resolve| for resolving a |CommitSpec| to a |Commit|.

type DoltDB

type DoltDB struct {
	// contains filtered or unexported fields
}

DoltDB wraps access to the underlying noms database and hides some of the details of the underlying storage. Additionally the noms codebase uses panics in a way that is non idiomatic and We've opted to recover and return errors in many cases.

func DoltDBFromCS

func DoltDBFromCS(cs chunks.ChunkStore) *DoltDB

DoltDBFromCS creates a DoltDB from a noms chunks.ChunkStore

func LoadDoltDB

func LoadDoltDB(ctx context.Context, nbf *types.NomsBinFormat, urlStr string, fs filesys.Filesys) (*DoltDB, error)

LoadDoltDB will acquire a reference to the underlying noms db. If the Location is InMemDoltDB then a reference to a newly created in memory database will be used. If the location is LocalDirDoltDB, the directory must exist or this returns nil.

func LoadDoltDBWithParams

func LoadDoltDBWithParams(ctx context.Context, nbf *types.NomsBinFormat, urlStr string, fs filesys.Filesys, params map[string]interface{}) (*DoltDB, error)

func (*DoltDB) CSMetricsSummary

func (ddb *DoltDB) CSMetricsSummary() string

func (*DoltDB) CanFastForward

func (ddb *DoltDB) CanFastForward(ctx context.Context, branch ref.DoltRef, new *Commit) (bool, error)

CanFastForward returns whether the given branch can be fast-forwarded to the commit given.

func (*DoltDB) Clone

func (ddb *DoltDB) Clone(ctx context.Context, destDB *DoltDB, eventCh chan<- pull.TableFileEvent) error

func (*DoltDB) Commit

func (ddb *DoltDB) Commit(ctx context.Context, valHash hash.Hash, dref ref.DoltRef, cm *datas.CommitMeta) (*Commit, error)

Commit will update a branch's head value to be that of a previously committed root value hash

func (*DoltDB) CommitDanglingWithParentCommits

func (ddb *DoltDB) CommitDanglingWithParentCommits(ctx context.Context, valHash hash.Hash, parentCommits []*Commit, cm *datas.CommitMeta) (*Commit, error)

dangling commits are unreferenced by any branch or ref. They are created in the course of programmatic updates such as rebase. You must create a ref to a dangling commit for it to be reachable

func (*DoltDB) CommitRoot

func (ddb *DoltDB) CommitRoot(ctx context.Context, last, current hash.Hash) (bool, error)

CommitRoot executes a chunkStore commit, atomically swapping the root hash of the database manifest

func (*DoltDB) CommitWithParentCommits

func (ddb *DoltDB) CommitWithParentCommits(ctx context.Context, valHash hash.Hash, dref ref.DoltRef, parentCommits []*Commit, cm *datas.CommitMeta) (*Commit, error)

func (*DoltDB) CommitWithParentSpecs

func (ddb *DoltDB) CommitWithParentSpecs(ctx context.Context, valHash hash.Hash, dref ref.DoltRef, parentCmSpecs []*CommitSpec, cm *datas.CommitMeta) (*Commit, error)

CommitWithParentSpecs commits the value hash given to the branch given, using the list of parent hashes given. Returns an error if the value or any parents can't be resolved, or if anything goes wrong accessing the underlying storage.

func (*DoltDB) CommitWithWorkingSet

func (ddb *DoltDB) CommitWithWorkingSet(
	ctx context.Context,
	headRef ref.DoltRef, workingSetRef ref.WorkingSetRef,
	commit *PendingCommit, workingSet *WorkingSet,
	prevHash hash.Hash,
	meta *datas.WorkingSetMeta,
) (*Commit, error)

CommitWithWorkingSet combines the functionality of CommitWithParents with UpdateWorking set, and takes a combination of their parameters. It's a way to update the working set and current HEAD in the same atomic transaction. It commits to disk a pending commit value previously created with NewPendingCommit, asserting that the working set hash given is still current for that HEAD.

func (*DoltDB) CopyWorkingSet

func (ddb *DoltDB) CopyWorkingSet(ctx context.Context, fromWSRef ref.WorkingSetRef, toWSRef ref.WorkingSetRef, force bool) error

CopyWorkingSet copies a WorkingSetRef from one ref to another. If `force` is true, will overwrite any existing value in the destination ref. Otherwise will fail if the destination ref exists.

If fromWSRef does not exist, this method does not return an error, but returns `nil`. In that case, the destination ref is left alone.

func (*DoltDB) DeleteBranch

func (ddb *DoltDB) DeleteBranch(ctx context.Context, branch ref.DoltRef) error

DeleteBranch deletes the branch given, returning an error if it doesn't exist.

func (*DoltDB) DeleteTag

func (ddb *DoltDB) DeleteTag(ctx context.Context, tag ref.DoltRef) error

func (*DoltDB) DeleteWorkingSet

func (ddb *DoltDB) DeleteWorkingSet(ctx context.Context, workingSetRef ref.WorkingSetRef) error

DeleteWorkingSet deletes the working set given

func (*DoltDB) DeleteWorkspace

func (ddb *DoltDB) DeleteWorkspace(ctx context.Context, workRef ref.DoltRef) error

func (*DoltDB) ExecuteCommitHooks

func (ddb *DoltDB) ExecuteCommitHooks(ctx context.Context, datasetId string) error

func (*DoltDB) FastForward

func (ddb *DoltDB) FastForward(ctx context.Context, branch ref.DoltRef, commit *Commit) error

FastForward fast-forwards the branch given to the commit given.

func (*DoltDB) Format

func (ddb *DoltDB) Format() *types.NomsBinFormat

func (*DoltDB) GC

func (ddb *DoltDB) GC(ctx context.Context, uncommitedVals ...hash.Hash) error

GC performs garbage collection on this ddb. Values passed in |uncommitedVals| will be temporarily saved during gc.

func (*DoltDB) GetBranches

func (ddb *DoltDB) GetBranches(ctx context.Context) ([]ref.DoltRef, error)

GetBranches returns a list of all branches in the database.

func (*DoltDB) GetBranchesWithHashes

func (ddb *DoltDB) GetBranchesWithHashes(ctx context.Context) ([]BranchWithHash, error)

func (*DoltDB) GetHeadRefs

func (ddb *DoltDB) GetHeadRefs(ctx context.Context) ([]ref.DoltRef, error)

GetHeadRefs returns a list of all refs that point to a Commit

func (*DoltDB) GetRefsOfType

func (ddb *DoltDB) GetRefsOfType(ctx context.Context, refTypeFilter map[ref.RefType]struct{}) ([]ref.DoltRef, error)

func (*DoltDB) GetRemoteRefs

func (ddb *DoltDB) GetRemoteRefs(ctx context.Context) ([]ref.DoltRef, error)

GetRemoteRefs returns a list of all remotes in the database.

func (*DoltDB) GetRemotesWithHashes

func (ddb *DoltDB) GetRemotesWithHashes(ctx context.Context) ([]RemoteWithHash, error)

func (*DoltDB) GetTags

func (ddb *DoltDB) GetTags(ctx context.Context) ([]ref.DoltRef, error)

GetTags returns a list of all tags in the database.

func (*DoltDB) GetTagsWithHashes

func (ddb *DoltDB) GetTagsWithHashes(ctx context.Context) ([]TagWithHash, error)

GetTagsWithHashes returns a list of objects containing TagRefs with their associated Commit's hash

func (*DoltDB) GetWorkspaces

func (ddb *DoltDB) GetWorkspaces(ctx context.Context) ([]ref.DoltRef, error)

GetWorkspaces returns a list of all workspaces in the database.

func (*DoltDB) Has

func (ddb *DoltDB) Has(ctx context.Context, h hash.Hash) (bool, error)

func (*DoltDB) HasBranch

func (ddb *DoltDB) HasBranch(ctx context.Context, branchName string) (bool, error)

HasBranch returns whether the DB has a branch with the name given

func (*DoltDB) HasRef

func (ddb *DoltDB) HasRef(ctx context.Context, doltRef ref.DoltRef) (bool, error)

HasRef returns whether the branch given exists in this database.

func (*DoltDB) NewBranchAtCommit

func (ddb *DoltDB) NewBranchAtCommit(ctx context.Context, branchRef ref.DoltRef, commit *Commit) error

NewBranchAtCommit creates a new branch with HEAD at the commit given. Branch names must pass IsValidUserBranchName.

func (*DoltDB) NewPendingCommit

func (ddb *DoltDB) NewPendingCommit(
	ctx context.Context,
	roots Roots,
	headRef ref.DoltRef,
	parentCommits []*Commit,
	cm *datas.CommitMeta,
) (*PendingCommit, error)

NewPendingCommit returns a new PendingCommit object to be written with doltdb.CommitWithWorkingSet. |roots| are the current roots to include in the PendingCommit. roots.Staged is used as the new root to package in the commit, once written. |headRef| is the ref of the HEAD the commit will update |parentCommits| are any additional merge parents for this commit. The current HEAD commit is always considered a parent. |cm| is the metadata for the commit

func (*DoltDB) NewTagAtCommit

func (ddb *DoltDB) NewTagAtCommit(ctx context.Context, tagRef ref.DoltRef, c *Commit, meta *datas.TagMeta) error

NewTagAtCommit create a new tag at the commit given.

func (*DoltDB) NewWorkspaceAtCommit

func (ddb *DoltDB) NewWorkspaceAtCommit(ctx context.Context, workRef ref.DoltRef, c *Commit) error

NewWorkspaceAtCommit create a new workspace at the commit given.

func (*DoltDB) NomsRoot

func (ddb *DoltDB) NomsRoot(ctx context.Context) (hash.Hash, error)

NomsRoot returns the hash of the noms dataset map

func (*DoltDB) PullChunks

func (ddb *DoltDB) PullChunks(ctx context.Context, tempDir string, srcDB *DoltDB, targetHash hash.Hash, progChan chan pull.PullProgress, statsCh chan pull.Stats) error

PullChunks initiates a pull into this database from the source database given, pulling all chunks reachable from the given targetHash. Pull progress is communicated over the provided channel.

func (*DoltDB) ReadRootValue

func (ddb *DoltDB) ReadRootValue(ctx context.Context, h hash.Hash) (*RootValue, error)

ReadRootValue reads the RootValue associated with the hash given and returns it. Returns an error if the value cannot be read, or if the hash given doesn't represent a dolt RootValue.

func (*DoltDB) Rebase

func (ddb *DoltDB) Rebase(ctx context.Context) error

Rebase rebases the underlying db from disk, re-loading the manifest. Useful when another process might have made changes to the database we need to read.

func (*DoltDB) Resolve

func (ddb *DoltDB) Resolve(ctx context.Context, cs *CommitSpec, cwb ref.DoltRef) (*Commit, error)

Resolve takes a CommitSpec and returns a Commit, or an error if the commit cannot be found. If the CommitSpec is HEAD, Resolve also needs the DoltRef of the current working branch.

func (*DoltDB) ResolveAllParents

func (ddb *DoltDB) ResolveAllParents(ctx context.Context, commit *Commit) ([]*Commit, error)

func (*DoltDB) ResolveCommitRef

func (ddb *DoltDB) ResolveCommitRef(ctx context.Context, ref ref.DoltRef) (*Commit, error)

ResolveCommitRef takes a DoltRef and returns a Commit, or an error if the commit cannot be found. The ref given must point to a Commit.

func (*DoltDB) ResolveParent

func (ddb *DoltDB) ResolveParent(ctx context.Context, commit *Commit, parentIdx int) (*Commit, error)

ResolveParent returns the n-th ancestor of a given commit (direct parent is index 0). error return value will be non-nil in the case that the commit cannot be resolved, there aren't as many ancestors as requested, or the underlying storage cannot be accessed.

func (*DoltDB) ResolveTag

func (ddb *DoltDB) ResolveTag(ctx context.Context, tagRef ref.TagRef) (*Tag, error)

ResolveTag takes a TagRef and returns the corresponding Tag object.

func (*DoltDB) ResolveWorkingSet

func (ddb *DoltDB) ResolveWorkingSet(ctx context.Context, workingSetRef ref.WorkingSetRef) (*WorkingSet, error)

ResolveWorkingSet takes a WorkingSetRef and returns the corresponding WorkingSet object.

func (*DoltDB) SetCommitHookLogger

func (ddb *DoltDB) SetCommitHookLogger(ctx context.Context, wr io.Writer) *DoltDB

func (*DoltDB) SetCommitHooks

func (ddb *DoltDB) SetCommitHooks(ctx context.Context, postHooks []CommitHook) *DoltDB

func (*DoltDB) SetHead

func (ddb *DoltDB) SetHead(ctx context.Context, ref ref.DoltRef, addr hash.Hash) error

func (*DoltDB) SetHeadToCommit

func (ddb *DoltDB) SetHeadToCommit(ctx context.Context, ref ref.DoltRef, cm *Commit) error

SetHeadToCommit sets the given ref to point at the given commit. It is used in the course of 'force' updates.

func (*DoltDB) ShallowGC

func (ddb *DoltDB) ShallowGC(ctx context.Context) error

func (*DoltDB) UpdateWorkingSet

func (ddb *DoltDB) UpdateWorkingSet(
	ctx context.Context,
	workingSetRef ref.WorkingSetRef,
	workingSet *WorkingSet,
	prevHash hash.Hash,
	meta *datas.WorkingSetMeta,
) error

UpdateWorkingSet updates the working set with the ref given to the root value given |prevHash| is the hash of the expected WorkingSet struct stored in the ref, not the hash of the RootValue there.

func (*DoltDB) ValueReadWriter

func (ddb *DoltDB) ValueReadWriter() types.ValueReadWriter

ValueReadWriter returns the underlying noms database as a types.ValueReadWriter.

func (*DoltDB) VisitRefsOfType

func (ddb *DoltDB) VisitRefsOfType(ctx context.Context, refTypeFilter map[ref.RefType]struct{}, visit func(r ref.DoltRef, addr hash.Hash) error) error

func (*DoltDB) WriteEmptyRepo

func (ddb *DoltDB) WriteEmptyRepo(ctx context.Context, initBranch, name, email string) error

WriteEmptyRepo will create initialize the given db with a master branch which points to a commit which has valid metadata for the creation commit, and an empty RootValue.

func (*DoltDB) WriteEmptyRepoWithCommitTime

func (ddb *DoltDB) WriteEmptyRepoWithCommitTime(ctx context.Context, initBranch, name, email string, t time.Time) error

func (*DoltDB) WriteEmptyRepoWithCommitTimeAndDefaultBranch

func (ddb *DoltDB) WriteEmptyRepoWithCommitTimeAndDefaultBranch(
	ctx context.Context,
	name, email string,
	t time.Time,
	init ref.BranchRef,
) error

func (*DoltDB) WriteRootValue

func (ddb *DoltDB) WriteRootValue(ctx context.Context, rv *RootValue) (*RootValue, hash.Hash, error)

WriteRootValue will write a doltdb.RootValue instance to the database. This value will not be associated with a commit and can be committed by hash at a later time. Returns an updated root value and the hash of the value written. This method is the primary place in doltcore that handles setting the FeatureVersion of root values to the current value, so all writes of RootValues should happen here.

type ErrClientOutOfDate

type ErrClientOutOfDate struct {
	RepoVer   FeatureVersion
	ClientVer FeatureVersion
}

func (ErrClientOutOfDate) Error

func (e ErrClientOutOfDate) Error() string

type FeatureVersion

type FeatureVersion int64
var DoltFeatureVersion FeatureVersion = 3 // last bumped when storing creation time for triggers

DoltFeatureVersion is described in feature_version.md. only variable for testing.

type FilteringCommitItr

type FilteringCommitItr struct {
	// contains filtered or unexported fields
}

FilteringCommitItr is a CommitItr implementation that applies a filtering function to limit the commits returned

func NewFilteringCommitItr

func NewFilteringCommitItr(itr CommitItr, filter CommitFilter) FilteringCommitItr

func (FilteringCommitItr) Next

func (itr FilteringCommitItr) Next(ctx context.Context) (hash.Hash, *Commit, error)

Next returns the hash of the next commit, and a pointer to that commit. Implementations of Next must handle making sure the list of commits returned are unique. When complete Next will return hash.Hash{}, nil, io.EOF

func (FilteringCommitItr) Reset

func (itr FilteringCommitItr) Reset(ctx context.Context) error

Reset the commit iterator back to the

type ForeignKey

type ForeignKey struct {
	Name                   string                      `noms:"name" json:"name"`
	TableName              string                      `noms:"tbl_name" json:"tbl_name"`
	TableIndex             string                      `noms:"tbl_index" json:"tbl_index"`
	TableColumns           []uint64                    `noms:"tbl_cols" json:"tbl_cols"`
	ReferencedTableName    string                      `noms:"ref_tbl_name" json:"ref_tbl_name"`
	ReferencedTableIndex   string                      `noms:"ref_tbl_index" json:"ref_tbl_index"`
	ReferencedTableColumns []uint64                    `noms:"ref_tbl_cols" json:"ref_tbl_cols"`
	OnUpdate               ForeignKeyReferentialAction `noms:"on_update" json:"on_update"`
	OnDelete               ForeignKeyReferentialAction `noms:"on_delete" json:"on_delete"`
	UnresolvedFKDetails    UnresolvedFKDetails         `noms:"unres_fk,omitempty" json:"unres_fk,omitempty"`
}

ForeignKey is the complete, internal representation of a Foreign Key.

func (ForeignKey) DeepEquals

func (fk ForeignKey) DeepEquals(other ForeignKey) bool

DeepEquals compares all attributes of a foreign key to another, including name and table names.

func (ForeignKey) EqualDefs

func (fk ForeignKey) EqualDefs(other ForeignKey) bool

EqualDefs returns whether two foreign keys have the same definition over the same column sets. It does not compare table names or foreign key names.

func (ForeignKey) HashOf

func (fk ForeignKey) HashOf() hash.Hash

HashOf returns the Noms hash of a ForeignKey.

func (ForeignKey) IsResolved

func (fk ForeignKey) IsResolved() bool

IsResolved returns whether the foreign key has been resolved.

func (ForeignKey) IsSelfReferential

func (fk ForeignKey) IsSelfReferential() bool

IsSelfReferential returns whether the table declaring the foreign key is also referenced by the foreign key.

func (ForeignKey) ValidateData

func (fk ForeignKey) ValidateData(
	ctx context.Context,
	childSch schema.Schema,
	childRowData, childIdxData, parentIdxData types.Map,
	childDef, parentDef schema.Index,
	vrw types.ValueReadWriter,
) error

ValidateData ensures that the foreign key is valid by comparing the index data from the given table against the index data from the referenced table. Returns an error for each violation.

func (ForeignKey) ValidateReferencedTableSchema

func (fk ForeignKey) ValidateReferencedTableSchema(sch schema.Schema) error

ValidateReferencedTableSchema verifies that the given schema matches the expectation of the referenced table.

func (ForeignKey) ValidateTableSchema

func (fk ForeignKey) ValidateTableSchema(sch schema.Schema) error

ValidateTableSchema verifies that the given schema matches the expectation of the declaring table.

type ForeignKeyCollection

type ForeignKeyCollection struct {
	// contains filtered or unexported fields
}

ForeignKeyCollection represents the collection of foreign keys for a root value.

func LoadForeignKeyCollection

func LoadForeignKeyCollection(ctx context.Context, fkMap types.Map) (*ForeignKeyCollection, error)

LoadForeignKeyCollection returns a new ForeignKeyCollection using the provided map returned previously by GetMap.

func NewForeignKeyCollection

func NewForeignKeyCollection(keys ...ForeignKey) (*ForeignKeyCollection, error)

func (*ForeignKeyCollection) AddKeys

func (fkc *ForeignKeyCollection) AddKeys(fks ...ForeignKey) error

AddKeys adds the given foreign key to the collection. Checks that the given name is unique in the collection, and that both column counts are equal. All other validation should occur before being added to the collection.

func (*ForeignKeyCollection) AllKeys

func (fkc *ForeignKeyCollection) AllKeys() []ForeignKey

AllKeys returns a slice, sorted by name ascending, containing all of the foreign keys in this collection.

func (*ForeignKeyCollection) ColumnHasFkRelationship

func (fkc *ForeignKeyCollection) ColumnHasFkRelationship(tag uint64) (ForeignKey, bool)

ColumnHasFkRelationship returns a foreign key that uses this tag. Returns n

func (*ForeignKeyCollection) Contains

func (fkc *ForeignKeyCollection) Contains(foreignKeyName string) bool

Contains returns whether the given foreign key name already exists for this collection.

func (*ForeignKeyCollection) Count

func (fkc *ForeignKeyCollection) Count() int

Count returns the number of indexes in this collection.

func (*ForeignKeyCollection) GetByNameCaseInsensitive

func (fkc *ForeignKeyCollection) GetByNameCaseInsensitive(foreignKeyName string) (ForeignKey, bool)

GetByNameCaseInsensitive returns a ForeignKey with a matching case-insensitive name, and whether a match exists.

func (*ForeignKeyCollection) GetByTags

func (fkc *ForeignKeyCollection) GetByTags(childTags, parentTags []uint64) (ForeignKey, bool)

GetByTags gets the ForeignKey defined over the parent and child columns corresponding to their tags.

func (*ForeignKeyCollection) GetMatchingKey

func (fkc *ForeignKeyCollection) GetMatchingKey(fk ForeignKey, allSchemas map[string]schema.Schema) (ForeignKey, bool)

GetMatchingKey gets the ForeignKey defined over the parent and child columns. If the given foreign key is resolved, then both resolved and unresolved keys are checked for a match. If the given foreign key is unresolved, then ONLY unresolved keys may be found.

This discrepancy is due to the primary uses for this function. It is assumed that the ForeignKeyCollection is an ancestor collection compared to the collection that the given key comes from. Therefore, the key found in the ancestor will usually be the unresolved version of the given key, hence the comparison is valid. However, if the given key is unresolved, it is treated as a new key, which cannot be matched to a resolved key that previously existed.

The given schema map is keyed by table name, and is used in the event that the given key is resolved and any keys in the collection are unresolved. A "dirty resolution" is performed, which matches the column names to tags, and then a standard tag comparison is performed. If a table or column is not in the map, then the foreign key is ignored.

func (*ForeignKeyCollection) Iter

func (fkc *ForeignKeyCollection) Iter(cb func(fk ForeignKey) (stop bool, err error)) error

func (*ForeignKeyCollection) KeysForTable

func (fkc *ForeignKeyCollection) KeysForTable(tableName string) (declaredFk, referencedByFk []ForeignKey)

KeysForTable returns all foreign keys that reference the given table in some capacity. The returned array declaredFk contains all foreign keys in which this table declared the foreign key. The array referencedByFk contains all foreign keys in which this table is the referenced table. If the table contains a self-referential foreign key, it will be present in both declaresFk and referencedByFk. Each array is sorted by name ascending.

func (*ForeignKeyCollection) Map

Map returns the collection as a Noms Map for persistence.

func (*ForeignKeyCollection) RemoveAndUnresolveTables

func (fkc *ForeignKeyCollection) RemoveAndUnresolveTables(ctx context.Context, root *RootValue, tables ...string) error

RemoveAndUnresolveTables removes all foreign keys associated with the given tables. If a parent is dropped without its child, then the foreign key goes to an unresolved state. The operation assumes that ALL tables to be removed are in a single call, as splitting tables into different calls may result in unintended errors.

func (*ForeignKeyCollection) RemoveKeyByName

func (fkc *ForeignKeyCollection) RemoveKeyByName(foreignKeyName string) bool

RemoveKeyByName removes a foreign key from the collection. It does not remove the associated indexes from their respective tables. Returns true if the key was successfully removed.

func (*ForeignKeyCollection) RemoveKeys

func (fkc *ForeignKeyCollection) RemoveKeys(fks ...ForeignKey)

RemoveKeys removes any Foreign Keys with matching column set from the collection.

func (*ForeignKeyCollection) RemoveTables

func (fkc *ForeignKeyCollection) RemoveTables(ctx context.Context, tables ...string) error

RemoveTables removes all foreign keys associated with the given tables, if permitted. The operation assumes that ALL tables to be removed are in a single call, as splitting tables into different calls may result in unintended errors.

func (*ForeignKeyCollection) RenameTable

func (fkc *ForeignKeyCollection) RenameTable(oldTableName, newTableName string)

RenameTable updates all foreign key entries in the collection with the updated table name. Does not check for name collisions. Additionally, any unresolved foreign keys will still update their referenced names as this matches MySQL's behavior.

func (*ForeignKeyCollection) Stage

func (fkc *ForeignKeyCollection) Stage(ctx context.Context, fksToAdd []ForeignKey, fksToRemove []ForeignKey)

Stage takes the keys to add and remove and updates the current collection. Does not perform any key validation nor name uniqueness verification, as this is intended for use in commit staging. Adding a foreign key and updating (such as a table rename) an existing one are functionally the same.

func (*ForeignKeyCollection) Tables

func (fkc *ForeignKeyCollection) Tables() map[string]struct{}

Tables returns the set of all tables that either declare a foreign key or are referenced by a foreign key.

type ForeignKeyReferentialAction

type ForeignKeyReferentialAction byte
const (
	ForeignKeyReferentialAction_DefaultAction ForeignKeyReferentialAction = iota
	ForeignKeyReferentialAction_Cascade
	ForeignKeyReferentialAction_NoAction
	ForeignKeyReferentialAction_Restrict
	ForeignKeyReferentialAction_SetNull
)

func (ForeignKeyReferentialAction) ReducedString

func (refOp ForeignKeyReferentialAction) ReducedString() string

ReducedString returns the SQL reference option in uppercase. All reference options are functionally equivalent to either RESTRICT, CASCADE, or SET NULL, therefore only one those three options are returned.

func (ForeignKeyReferentialAction) String

func (refOp ForeignKeyReferentialAction) String() string

String returns the SQL reference option in uppercase.

type ForeignKeyViolationError

type ForeignKeyViolationError struct {
	ForeignKey    ForeignKey
	Schema        schema.Schema
	ViolationRows []row.Row
}

ForeignKeyViolationError represents a set of foreign key violations for a table.

func (*ForeignKeyViolationError) Error

func (f *ForeignKeyViolationError) Error() string

Error implements the interface error.

type LogHook

type LogHook struct {
	// contains filtered or unexported fields
}

func NewLogHook

func NewLogHook(msg []byte) *LogHook

NewLogHook is a noop that logs to a writer when invoked

func (*LogHook) Execute

func (lh *LogHook) Execute(ctx context.Context, ds datas.Dataset, db datas.Database) error

Execute implements CommitHook, writes message to log channel

func (*LogHook) HandleError

func (lh *LogHook) HandleError(ctx context.Context, err error) error

HandleError implements CommitHook

func (*LogHook) SetLogger

func (lh *LogHook) SetLogger(ctx context.Context, wr io.Writer) error

SetLogger implements CommitHook

type MergeState

type MergeState struct {
	// contains filtered or unexported fields
}

func MergeStateFromCommitAndWorking

func MergeStateFromCommitAndWorking(commit *Commit, preMergeWorking *RootValue) *MergeState

MergeStateFromCommitAndWorking returns a new MergeState. Most clients should not construct MergeState objects directly, but instead use WorkingSet.StartMerge

func (MergeState) Commit

func (m MergeState) Commit() *Commit

func (MergeState) PreMergeWorkingRoot

func (m MergeState) PreMergeWorkingRoot() *RootValue

type PendingCommit

type PendingCommit struct {
	Roots         Roots
	Val           types.Value
	CommitOptions datas.CommitOptions
}

PendingCommit represents a commit that hasn't yet been written to storage. It contains a root value and options to use when committing it. Use a PendingCommit when it's important to update the working set and HEAD together atomically, via doltdb.CommitWithWorkingSet

type PushArg

type PushArg struct {
	// contains filtered or unexported fields
}

type PushOnWriteHook

type PushOnWriteHook struct {
	// contains filtered or unexported fields
}

func NewPushOnWriteHook

func NewPushOnWriteHook(destDB *DoltDB, tmpDir string) *PushOnWriteHook

NewPushOnWriteHook creates a ReplicateHook, parameterizaed by the backup database and a local tempfile for pushing

func (*PushOnWriteHook) Execute

func (ph *PushOnWriteHook) Execute(ctx context.Context, ds datas.Dataset, db datas.Database) error

Execute implements CommitHook, replicates head updates to the destDb field

func (*PushOnWriteHook) HandleError

func (ph *PushOnWriteHook) HandleError(ctx context.Context, err error) error

HandleError implements CommitHook

func (*PushOnWriteHook) SetLogger

func (ph *PushOnWriteHook) SetLogger(ctx context.Context, wr io.Writer) error

SetLogger implements CommitHook

type RemoteWithHash

type RemoteWithHash struct {
	Ref  ref.DoltRef
	Hash hash.Hash
}

type RootType

type RootType int
const (
	WorkingRoot RootType = iota
	StagedRoot
	CommitRoot
	HeadRoot
	InvalidRoot
)

func GetUnreachableRootType

func GetUnreachableRootType(err error) RootType

func (RootType) String

func (rt RootType) String() string

type RootTypeSet

type RootTypeSet map[RootType]struct{}

func NewRootTypeSet

func NewRootTypeSet(rts ...RootType) RootTypeSet

func (RootTypeSet) Contains

func (rts RootTypeSet) Contains(rt RootType) bool

func (RootTypeSet) First

func (rts RootTypeSet) First(rtList []RootType) RootType

func (RootTypeSet) IsEmpty

func (rts RootTypeSet) IsEmpty() bool

type RootValue

type RootValue struct {
	// contains filtered or unexported fields
}

RootValue is the value of the Database and is the committed value in every Dolt commit.

func EmptyRootValue

func EmptyRootValue(ctx context.Context, vrw types.ValueReadWriter) (*RootValue, error)

func (*RootValue) CreateEmptyTable

func (root *RootValue) CreateEmptyTable(ctx context.Context, tName string, sch schema.Schema) (*RootValue, error)

CreateEmptyTable creates an empty table in this root with the name and schema given, returning the new root value.

func (*RootValue) DebugString

func (root *RootValue) DebugString(ctx context.Context, transitive bool) string

DebugString returns a human readable string with the contents of this root. If |transitive| is true, row data from all tables is also included. This method is very expensive for large root values, so |transitive| should only be used when debugging tests.

func (*RootValue) GenerateTagsForNewColColl

func (root *RootValue) GenerateTagsForNewColColl(ctx context.Context, tableName string, cc *schema.ColCollection) (*schema.ColCollection, error)

func (*RootValue) GenerateTagsForNewColumns

func (root *RootValue) GenerateTagsForNewColumns(
	ctx context.Context,
	tableName string,
	newColNames []string,
	newColKinds []types.NomsKind,
	headRoot *RootValue,
) ([]uint64, error)

GenerateTagsForNewColumns deterministically generates a slice of new tags that are unique within the history of this root. The names and NomsKinds of the new columns are used to see the tag generator.

func (*RootValue) GetAllSchemas

func (root *RootValue) GetAllSchemas(ctx context.Context) (map[string]schema.Schema, error)

func (*RootValue) GetFeatureVersion

func (root *RootValue) GetFeatureVersion(ctx context.Context) (ver FeatureVersion, ok bool, err error)

GetFeatureVersion returns the feature version of this root, if one is written

func (*RootValue) GetForeignKeyCollection

func (root *RootValue) GetForeignKeyCollection(ctx context.Context) (*ForeignKeyCollection, error)

GetForeignKeyCollection returns the ForeignKeyCollection for this root. As collections are meant to be modified in-place, each returned collection may freely be altered without affecting future returned collections from this root.

func (*RootValue) GetForeignKeyCollectionMap

func (root *RootValue) GetForeignKeyCollectionMap(ctx context.Context) (types.Map, error)

GetForeignKeyCollectionMap returns the persisted noms Map of the foreign key collection on this root. If the intent is to retrieve a ForeignKeyCollection in particular, it is advised to call GetForeignKeyCollection as it caches the result for performance.

func (*RootValue) GetSuperSchema

func (root *RootValue) GetSuperSchema(ctx context.Context, tName string) (*schema.SuperSchema, bool, error)

GetSuperSchema returns the SuperSchema for the table name specified if that table exists.

func (*RootValue) GetSuperSchemaMap

func (root *RootValue) GetSuperSchemaMap(ctx context.Context) (types.Map, error)

GerSuperSchemaMap returns the Noms map that tracks SuperSchemas, used to create new RootValues on checkout branch.

func (*RootValue) GetTable

func (root *RootValue) GetTable(ctx context.Context, tName string) (*Table, bool, error)

GetTable will retrieve a table by its case-sensitive name.

func (*RootValue) GetTableByColTag

func (root *RootValue) GetTableByColTag(ctx context.Context, tag uint64) (tbl *Table, name string, found bool, err error)

GetTableByColTag looks for the table containing the given column tag. It returns false if no table exists in the history. If the table containing the given tag previously existed and was deleted, it will return its name and a nil pointer.

func (*RootValue) GetTableHash

func (root *RootValue) GetTableHash(ctx context.Context, tName string) (hash.Hash, bool, error)

func (*RootValue) GetTableInsensitive

func (root *RootValue) GetTableInsensitive(ctx context.Context, tName string) (*Table, string, bool, error)

GetTableInsensitive will retrieve a table by its case-insensitive name.

func (*RootValue) GetTableNames

func (root *RootValue) GetTableNames(ctx context.Context) ([]string, error)

GetTableNames retrieves the lists of all tables for a RootValue

func (*RootValue) HasConflicts

func (root *RootValue) HasConflicts(ctx context.Context) (bool, error)

func (*RootValue) HasConstraintViolations

func (root *RootValue) HasConstraintViolations(ctx context.Context) (bool, error)

HasConstraintViolations returns whether any tables have constraint violations.

func (*RootValue) HasTable

func (root *RootValue) HasTable(ctx context.Context, tName string) (bool, error)

func (*RootValue) HashOf

func (root *RootValue) HashOf() (hash.Hash, error)

HashOf gets the hash of the root value

func (*RootValue) IterTables

func (root *RootValue) IterTables(ctx context.Context, cb func(name string, table *Table, sch schema.Schema) (stop bool, err error)) error

IterTables calls the callback function cb on each table in this RootValue.

func (*RootValue) MapTableHashes

func (root *RootValue) MapTableHashes(ctx context.Context) (map[string]hash.Hash, error)

MapTableHashes returns a map of each table name and hash.

func (*RootValue) PutForeignKeyCollection

func (root *RootValue) PutForeignKeyCollection(ctx context.Context, fkc *ForeignKeyCollection) (*RootValue, error)

PutForeignKeyCollection returns a new root with the given foreign key collection.

func (*RootValue) PutSuperSchema

func (root *RootValue) PutSuperSchema(ctx context.Context, tName string, ss *schema.SuperSchema) (*RootValue, error)

PutSuperSchema writes a new map entry for the table name and super schema supplied, it will overwrite an existing entry.

func (*RootValue) PutTable

func (root *RootValue) PutTable(ctx context.Context, tName string, table *Table) (*RootValue, error)

PutTable inserts a table by name into the map of tables. If a table already exists with that name it will be replaced

func (*RootValue) RemoveTables

func (root *RootValue) RemoveTables(ctx context.Context, skipFKHandling bool, allowDroppingFKReferenced bool, tables ...string) (*RootValue, error)

func (*RootValue) RenameTable

func (root *RootValue) RenameTable(ctx context.Context, oldName, newName string) (*RootValue, error)

RenameTable renames a table by changing its string key in the RootValue's table map. In order to preserve column tag information, use this method instead of a table drop + add.

func (*RootValue) ResolveTableName

func (root *RootValue) ResolveTableName(ctx context.Context, tName string) (string, bool, error)

ResolveTableName resolves a case-insensitive name to the exact name as stored in Dolt. Returns false if no matching name was found.

func (*RootValue) SetTableHash

func (root *RootValue) SetTableHash(ctx context.Context, tName string, h hash.Hash) (*RootValue, error)

func (*RootValue) TablesInConflict

func (root *RootValue) TablesInConflict(ctx context.Context) ([]string, error)

func (*RootValue) TablesWithConstraintViolations

func (root *RootValue) TablesWithConstraintViolations(ctx context.Context) ([]string, error)

TablesWithConstraintViolations returns all tables that have constraint violations.

func (*RootValue) UpdateSuperSchemasFromOther

func (root *RootValue) UpdateSuperSchemasFromOther(ctx context.Context, tblNames []string, other *RootValue) (*RootValue, error)

UpdateSuperSchemasFromOther updates SuperSchemas of tblNames using SuperSchemas from other.

func (*RootValue) VRW

func (root *RootValue) VRW() types.ValueReadWriter

func (*RootValue) ValidateForeignKeysOnSchemas

func (root *RootValue) ValidateForeignKeysOnSchemas(ctx context.Context) (*RootValue, error)

ValidateForeignKeysOnSchemas ensures that all foreign keys' tables are present, removing any foreign keys where the declared table is missing, and returning an error if a key is in an invalid state or a referenced table is missing. Does not check any tables' row data.

type RootValueUnreadable

type RootValueUnreadable struct {
	RootType RootType
	Cause    error
}

func (RootValueUnreadable) Error

func (rvu RootValueUnreadable) Error() string

type Roots

type Roots struct {
	Head    *RootValue
	Working *RootValue
	Staged  *RootValue
}

Roots is a convenience struct to package up the three roots that most library functions will need to inspect and modify the working set. This struct is designed to be passed by value always: functions should take a Roots as a param and return a modified one.

It contains three root values: Head: The root of the head of the current working branch Working: The root of the current working set Staged: The root of the staged value

See doltEnvironment.Roots(context.Context)

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table is a struct which holds row data, as well as a reference to its schema.

func NewNomsTable

func NewNomsTable(ctx context.Context, vrw types.ValueReadWriter, sch schema.Schema, rows types.Map, indexes durable.IndexSet, autoIncVal types.Value) (*Table, error)

NewNomsTable creates a noms Struct which stores row data, index data, and schema.

func NewTable

func NewTable(ctx context.Context, vrw types.ValueReadWriter, sch schema.Schema, rows durable.Index, indexes durable.IndexSet, autoIncVal types.Value) (*Table, error)

NewTable creates a durable object which stores row data, index data, and schema.

func (*Table) AddColumnToRows

func (t *Table) AddColumnToRows(ctx context.Context, newCol string, newSchema schema.Schema) (*Table, error)

AddColumnToRows adds the column named to row data as necessary and returns the resulting table.

func (*Table) ClearConflicts

func (t *Table) ClearConflicts(ctx context.Context) (*Table, error)

ClearConflicts deletes all merge conflicts for this table.

func (*Table) DebugString

func (t *Table) DebugString(ctx context.Context) string

func (*Table) DeleteIndexRowData

func (t *Table) DeleteIndexRowData(ctx context.Context, indexName string) (*Table, error)

DeleteIndexRowData removes the underlying map of an index, along with its key entry. This should only be used when removing an index altogether. If the intent is to clear an index's data, then use SetNomsIndexRows with an empty map.

func (*Table) Format

func (t *Table) Format() *types.NomsBinFormat

Format returns the NomsBinFormat for this table.

func (*Table) GetAutoIncrementValue

func (t *Table) GetAutoIncrementValue(ctx context.Context) (uint64, error)

GetAutoIncrementValue returns the current AUTO_INCREMENT value for this table.

func (*Table) GetConflictSchemas

func (t *Table) GetConflictSchemas(ctx context.Context) (base, sch, mergeSch schema.Schema, err error)

GetConflictSchemas returns the merge conflict schemas for this table.

func (*Table) GetConflicts

GetConflicts returns a map built from ValueReadWriter when there are no conflicts in table.

func (*Table) GetConstraintViolations

func (t *Table) GetConstraintViolations(ctx context.Context) (types.Map, error)

GetConstraintViolations returns a map of all constraint violations for this table, along with a bool indicating whether the table has any violations.

func (*Table) GetConstraintViolationsSchema

func (t *Table) GetConstraintViolationsSchema(ctx context.Context) (schema.Schema, error)

GetConstraintViolationsSchema returns this table's dolt_constraint_violations system table schema.

func (*Table) GetIndexRowData

func (t *Table) GetIndexRowData(ctx context.Context, indexName string) (durable.Index, error)

GetIndexRowData retrieves the underlying map of an index, in which the primary key consists of all indexed columns.

func (*Table) GetIndexSet

func (t *Table) GetIndexSet(ctx context.Context) (durable.IndexSet, error)

GetIndexSet returns the internal index map which goes from index name to a ref of the row data map.

func (*Table) GetNomsIndexRowData

func (t *Table) GetNomsIndexRowData(ctx context.Context, indexName string) (types.Map, error)

GetNomsIndexRowData retrieves the underlying map of an index, in which the primary key consists of all indexed columns.

func (*Table) GetNomsRowData

func (t *Table) GetNomsRowData(ctx context.Context) (types.Map, error)

GetNomsRowData retrieves the underlying map which is a map from a primary key to a list of field values.

func (*Table) GetRowData

func (t *Table) GetRowData(ctx context.Context) (durable.Index, error)

GetRowData retrieves the underlying map which is a map from a primary key to a list of field values.

func (*Table) GetSchema

func (t *Table) GetSchema(ctx context.Context) (schema.Schema, error)

GetSchema will retrieve the schema being referenced from the table in noms and unmarshal it.

func (*Table) GetSchemaHash

func (t *Table) GetSchemaHash(ctx context.Context) (hash.Hash, error)

GetSchemaHash returns the hash of this table's schema.

func (*Table) HasConflicts

func (t *Table) HasConflicts(ctx context.Context) (bool, error)

HasConflicts returns true if this table contains merge conflicts.

func (*Table) HashOf

func (t *Table) HashOf() (hash.Hash, error)

HashOf returns the hash of the underlying table struct.

func (*Table) NumRowsInConflict

func (t *Table) NumRowsInConflict(ctx context.Context) (uint64, error)

NumRowsInConflict returns the number of rows with merge conflicts for this table.

func (*Table) RenameIndexRowData

func (t *Table) RenameIndexRowData(ctx context.Context, oldIndexName, newIndexName string) (*Table, error)

RenameIndexRowData changes the name for the index data. Does not verify that the new name is unoccupied. If the old name does not exist, then this returns the called table without error.

func (*Table) ResolveConflicts

func (t *Table) ResolveConflicts(ctx context.Context, pkTuples []types.Value) (invalid, notFound []types.Value, tbl *Table, err error)

ResolveConflicts resolves conflicts for this table.

func (*Table) SetAutoIncrementValue

func (t *Table) SetAutoIncrementValue(ctx context.Context, val uint64) (*Table, error)

SetAutoIncrementValue sets the current AUTO_INCREMENT value for this table.

func (*Table) SetConflicts

func (t *Table) SetConflicts(ctx context.Context, schemas conflict.ConflictSchema, conflictData durable.ConflictIndex) (*Table, error)

SetConflicts sets the merge conflicts for this table.

func (*Table) SetConstraintViolations

func (t *Table) SetConstraintViolations(ctx context.Context, violationsMap types.Map) (*Table, error)

SetConstraintViolations sets this table's violations to the given map. If the map is empty, then the constraint violations entry on the embedded struct is removed.

func (*Table) SetIndexRows

func (t *Table) SetIndexRows(ctx context.Context, indexName string, idx durable.Index) (*Table, error)

SetIndexRows replaces the current row data for the given index and returns an updated Table.

func (*Table) SetIndexSet

func (t *Table) SetIndexSet(ctx context.Context, indexes durable.IndexSet) (*Table, error)

SetIndexSet replaces the current internal index map, and returns an updated Table.

func (*Table) SetNomsIndexRows

func (t *Table) SetNomsIndexRows(ctx context.Context, indexName string, idx types.Map) (*Table, error)

SetNomsIndexRows replaces the current row data for the given index and returns an updated Table.

func (*Table) UpdateNomsRows

func (t *Table) UpdateNomsRows(ctx context.Context, updatedRows types.Map) (*Table, error)

UpdateNomsRows replaces the current row data and returns and updated Table. Calls to UpdateNomsRows will not be written to the database. The root must be updated with the updated table, and the root must be committed or written.

func (*Table) UpdateRows

func (t *Table) UpdateRows(ctx context.Context, updatedRows durable.Index) (*Table, error)

UpdateRows replaces the current row data and returns and updated Table. Calls to UpdateRows will not be written to the database. The root must be updated with the updated table, and the root must be committed or written.

func (*Table) UpdateSchema

func (t *Table) UpdateSchema(ctx context.Context, sch schema.Schema) (*Table, error)

UpdateSchema updates the table with the schema given and returns the updated table. The original table is unchanged. This method only updates the schema of a table; the row data is unchanged. Schema alterations that require rebuilding the table (e.g. adding a column in the middle, adding a new non-null column, adding a column in the middle of a schema) must account for these changes separately.

func (*Table) ValueReadWriter

func (t *Table) ValueReadWriter() types.ValueReadWriter

ValueReadWriter returns the ValueReadWriter for this table.

func (*Table) VerifyIndexRowData

func (t *Table) VerifyIndexRowData(ctx context.Context, indexName string) error

VerifyIndexRowData verifies that the index with the given name's data matches what the index expects.

type Tag

type Tag struct {
	Name string

	Meta   *datas.TagMeta
	Commit *Commit
	// contains filtered or unexported fields
}

func NewTag

func NewTag(ctx context.Context, name string, ds datas.Dataset, vrw types.ValueReadWriter) (*Tag, error)

NewTag creates a new Tag object.

func (*Tag) GetAddr

func (t *Tag) GetAddr() (hash.Hash, error)

GetAddr returns a content address hash for this Tag.

func (*Tag) GetDoltRef

func (t *Tag) GetDoltRef() ref.DoltRef

GetDoltRef returns a DoltRef for this Tag.

type TagWithHash

type TagWithHash struct {
	Ref  ref.DoltRef
	Hash hash.Hash
}

type UnresolvedFKDetails

type UnresolvedFKDetails struct {
	TableColumns           []string `noms:"x_tbl_cols" json:"x_tbl_cols"`
	ReferencedTableColumns []string `noms:"x_ref_tbl_cols" json:"x_ref_tbl_cols"`
}

UnresolvedFKDetails contains any details necessary for an unresolved foreign key to resolve to a valid foreign key.

type WorkingSet

type WorkingSet struct {
	Name string
	// contains filtered or unexported fields
}

func EmptyWorkingSet

func EmptyWorkingSet(wsRef ref.WorkingSetRef) *WorkingSet

TODO: remove this, require working and staged

func NewWorkingSet

func NewWorkingSet(ctx context.Context, name string, vrw types.ValueReadWriter, ds datas.Dataset) (*WorkingSet, error)

NewWorkingSet creates a new WorkingSet object.

func (WorkingSet) AbortMerge

func (ws WorkingSet) AbortMerge() *WorkingSet

func (WorkingSet) ClearMerge

func (ws WorkingSet) ClearMerge() *WorkingSet

func (*WorkingSet) HashOf

func (ws *WorkingSet) HashOf() (hash.Hash, error)

HashOf returns the hash of the workingset struct, which is not the same as the hash of the root value stored in the working set. This value is used for optimistic locking when updating a working set for a head ref.

func (*WorkingSet) MergeActive

func (ws *WorkingSet) MergeActive() bool

func (*WorkingSet) MergeState

func (ws *WorkingSet) MergeState() *MergeState

func (WorkingSet) Meta

func (ws WorkingSet) Meta() *datas.WorkingSetMeta

func (*WorkingSet) Ref

func (ws *WorkingSet) Ref() ref.WorkingSetRef

Ref returns a WorkingSetRef for this WorkingSet.

func (*WorkingSet) StagedRoot

func (ws *WorkingSet) StagedRoot() *RootValue

func (WorkingSet) StartMerge

func (ws WorkingSet) StartMerge(commit *Commit) *WorkingSet

func (WorkingSet) WithMergeState

func (ws WorkingSet) WithMergeState(mergeState *MergeState) *WorkingSet

func (WorkingSet) WithStagedRoot

func (ws WorkingSet) WithStagedRoot(stagedRoot *RootValue) *WorkingSet

func (WorkingSet) WithWorkingRoot

func (ws WorkingSet) WithWorkingRoot(workingRoot *RootValue) *WorkingSet

func (*WorkingSet) WorkingRoot

func (ws *WorkingSet) WorkingRoot() *RootValue

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL