sqle

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: 55 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ADD                = "add"
	AGAINST            = "against"
	ALL                = "all"
	ALTER              = "alter"
	ANALYZE            = "analyze"
	AND                = "and"
	AS                 = "as"
	ASC                = "asc"
	AUTO_INCREMENT     = "auto_increment"
	BEGIN              = "begin"
	BETWEEN            = "between"
	BIGINT             = "bigint"
	BINARY             = "binary"
	BIT                = "bit"
	BLOB               = "blob"
	BOOL               = "bool"
	BOOLEAN            = "boolean"
	BY                 = "by"
	CASE               = "case"
	CAST               = "cast"
	CHAR               = "char"
	CHARACTER          = "character"
	CHARSET            = "charset"
	COLLATE            = "collate"
	COLUMN             = "column"
	COMMENT            = "comment"
	COMMIT             = "commit"
	COMMITTED          = "committed"
	CONSTRAINT         = "constraint"
	CONVERT            = "convert"
	CREATE             = "create"
	CROSS              = "cross"
	CURRENT_DATE       = "current_date"
	CURRENT_TIME       = "current_time"
	CURRENT_TIMESTAMP  = "current_timestamp"
	DATABASE           = "database"
	DATABASES          = "databases"
	DATE               = "date"
	DATETIME           = "datetime"
	DECIMAL            = "decimal"
	DEFAULT            = "default"
	DELETE             = "delete"
	DESC               = "desc"
	DESCRIBE           = "describe"
	DISTINCT           = "distinct"
	DIV                = "div"
	DOUBLE             = "double"
	DROP               = "drop"
	DUAL               = "dual"
	DUPLICATE          = "duplicate"
	ELSE               = "else"
	END                = "end"
	ENUM               = "enum"
	ESCAPE             = "escape"
	EXISTS             = "exists"
	EXPANSION          = "expansion"
	EXPLAIN            = "explain"
	EXTENDED           = "extended"
	FALSE              = "false"
	FLOAT_TYPE         = "float"
	FOR                = "for"
	FORCE              = "force"
	FOREIGN            = "foreign"
	FROM               = "from"
	FULL               = "full"
	FULLTEXT           = "fulltext"
	GEOMETRY           = "geometry"
	GEOMETRYCOLLECTION = "geometrycollection"
	GLOBAL             = "global"
	GROUP              = "group"
	GROUP_CONCAT       = "group_concat"
	HAVING             = "having"
	IF                 = "if"
	IGNORE             = "ignore"
	IN                 = "in"
	INDEX              = "index"
	INNER              = "inner"
	INSERT             = "insert"
	INT                = "int"
	INTEGER            = "integer"
	INTERVAL           = "interval"
	INTO               = "into"
	IS                 = "is"
	ISOLATION          = "isolation"
	JOIN               = "join"
	JSON               = "json"
	KEY                = "key"
	KEYS               = "keys"
	KEY_BLOCK_SIZE     = "key_block_size"
	LANGUAGE           = "language"
	LAST_INSERT_ID     = "last_insert_id"
	LEFT               = "left"
	LESS               = "less"
	LEVEL              = "level"
	LIKE               = "like"
	LIMIT              = "limit"
	LINESTRING         = "linestring"
	LOCALTIME          = "localtime"
	LOCALTIMESTAMP     = "localtimestamp"
	LOCK               = "lock"
	LONGBLOB           = "longblob"
	LONGTEXT           = "longtext"
	MATCH              = "match"
	MAXVALUE           = "maxvalue"
	MEDIUMBLOB         = "mediumblob"
	MEDIUMINT          = "mediumint"
	MEDIUMTEXT         = "mediumtext"
	MOD                = "mod"
	MODE               = "mode"
	MULTILINESTRING    = "multilinestring"
	MULTIPOINT         = "multipoint"
	MULTIPOLYGON       = "multipolygon"
	NAMES              = "names"
	NATURAL            = "natural"
	NCHAR              = "nchar"
	NEXT               = "next"
	NOT                = "not"
	NULL               = "null"
	NUMERIC            = "numeric"
	OFFSET             = "offset"
	ON                 = "on"
	ONLY               = "only"
	OPTIMIZE           = "optimize"
	OR                 = "or"
	ORDER              = "order"
	OUTER              = "outer"
	PARTITION          = "partition"
	POINT              = "point"
	POLYGON            = "polygon"
	PRIMARY            = "primary"
	PROCEDURE          = "procedure"
	PROCESSLIST        = "processlist"
	QUERY              = "query"
	READ               = "read"
	REAL               = "real"
	REGEXP             = "regexp"
	RLIKE              = "rlike"
	RENAME             = "rename"
	REORGANIZE         = "reorganize"
	REPAIR             = "repair"
	REPEATABLE         = "repeatable"
	REPLACE            = "replace"
	RIGHT              = "right"
	ROLLBACK           = "rollback"
	SCHEMA             = "schema"
	SELECT             = "select"
	SEPARATOR          = "separator"
	SERIALIZABLE       = "serializable"
	SESSION            = "session"
	SET                = "set"
	SHARE              = "share"
	SHOW               = "show"
	SIGNED             = "signed"
	SMALLINT           = "smallint"
	SPATIAL            = "spatial"
	SQL_CACHE          = "sql_cache"
	SQL_NO_CACHE       = "sql_no_cache"
	START              = "start"
	STATUS             = "status"
	STRAIGHT_JOIN      = "straight_join"
	STREAM             = "stream"
	SUBSTR             = "substr"
	SUBSTRING          = "substring"
	TABLE              = "table"
	TABLES             = "tables"
	TEXT               = "text"
	THAN               = "than"
	THEN               = "then"
	TIME               = "time"
	TIMESTAMP          = "timestamp"
	TINYBLOB           = "tinyblob"
	TINYINT            = "tinyint"
	TINYTEXT           = "tinytext"
	TO                 = "to"
	TRANSACTION        = "transaction"
	TRIGGER            = "trigger"
	TRUE               = "true"
	TRUNCATE           = "truncate"
	UNCOMMITTED        = "uncommitted"
	UNDERSCORE_BINARY  = "_binary"
	UNION              = "union"
	UNIQUE             = "unique"
	UNSIGNED           = "unsigned"
	UPDATE             = "update"
	USE                = "use"
	USING              = "using"
	UTC_DATE           = "utc_date"
	UTC_TIME           = "utc_time"
	UTC_TIMESTAMP      = "utc_timestamp"
	UUID               = "uuid"
	VALUES             = "values"
	VARBINARY          = "varbinary"
	VARCHAR            = "varchar"
	VARIABLES          = "variables"
	VIEW               = "view"
	WHEN               = "when"
	WHERE              = "where"
	WITH               = "with"
	WRITE              = "write"
	YEAR               = "year"
	ZEROFILL           = "zerofill"
)

SQL keyword constants for use in switches and comparisons

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 (
	ReplicateToRemoteKey     = "dolt_replicate_to_remote"
	ReadReplicaRemoteKey     = "dolt_read_replica_remote"
	SkipReplicationErrorsKey = "dolt_skip_replication_errors"
	ReplicateHeadsKey        = "dolt_replicate_heads"
	ReplicateAllHeadsKey     = "dolt_replicate_all_heads"
	AsyncReplicationKey      = "dolt_async_replication"
)
View Source
const (
	SysVarFalse = int8(0)
	SysVarTrue  = int8(1)
)
View Source
const (
	IdTag = iota + 200
	FirstNameTag
	LastNameTag
	IsMarriedTag
	AgeTag

	RatingTag
	UuidTag
	NumEpisodesTag
)
View Source
const (
	EpisodeIdTag = iota + 300
	EpNameTag
	EpAirDateTag
	EpRatingTag
)
View Source
const (
	AppCharacterTag = iota + 400
	AppEpTag
	AppCommentsTag
)
View Source
const (
	HomerId = iota
	MargeId
	BartId
	LisaId
	MoeId
	BarneyId
)
View Source
const NoUpperBound = 0xffffffffffffffff
View Source
const TableWithHistoryName = "test_table"

Variables

View Source
var AddAddrAt3HistSch = dtestutils.MustSchema(idColTag0TypeUUID, firstColTag1TypeStr, lastColTag2TypeStr, addrColTag3TypeStr)
View Source
var AddAgeAt4HistSch = dtestutils.MustSchema(idColTag0TypeUUID, firstColTag1TypeStr, lastColTag2TypeStr, ageColTag4TypeInt)
View Source
var AllAppsRows = Rs(app1, app2, app3, app4, app5, app6, app7, app8, app9, app10)

nobody in episode 4, that one was terrible Unlike the other tables, you can't count on the order of these rows matching the insertion order.

View Source
var AllEpsRows = Rs(Ep1, Ep2, Ep3, Ep4)
View Source
var AllKeywords = []string{}/* 201 elements not displayed */

All SQL keywords that we treat as reserved words

View Source
var AllPeopleRows = Rs(Homer, Marge, Bart, Lisa, Moe, Barney)
View Source
var AppearancesTableName = "appearances"
View Source
var AppearancesTestSchema = createAppearancesTestSchema()
View Source
var Barney = NewPeopleRowWithOptionalFields(BarneyId, "Barney", "Gumble", false, 40, 4, uuid.MustParse("00000000-0000-0000-0000-000000000005"), 555)
View Source
var Bart = NewPeopleRowWithOptionalFields(BartId, "Bart", "Simpson", false, 10, 9, uuid.MustParse("00000000-0000-0000-0000-000000000002"), 222)

Well-supported keywords that are likely to be useful in e.g. autocompletion

View Source
var DiffSchema = dtestutils.MustSchema(
	schema.NewColumn("to_id", 0, types.IntKind, false),
	schema.NewColumn("to_first_name", 1, types.StringKind, false),
	schema.NewColumn("to_last_name", 2, types.StringKind, false),
	schema.NewColumn("to_addr", 3, types.StringKind, false),
	schema.NewColumn("from_id", 7, types.IntKind, false),
	schema.NewColumn("from_first_name", 8, types.StringKind, false),
	schema.NewColumn("from_last_name", 9, types.StringKind, false),
	schema.NewColumn("from_addr", 10, types.StringKind, false),
	schema.NewColumn("diff_type", 14, types.StringKind, false),
)
View Source
var EmptyReadReplica = ReadReplicaDatabase{}
View Source
var Ep1 = newEpsRow2(1, "Simpsons Roasting On an Open Fire", "1989-12-18 03:00:00", 8.0)

Actually the first 4 episodes of the show

View Source
var Ep2 = newEpsRow2(2, "Bart the Genius", "1990-01-15 03:00:00", 9.0)
View Source
var Ep3 = newEpsRow2(3, "Homer's Odyssey", "1990-01-22 03:00:00", 7.0)
View Source
var Ep4 = newEpsRow2(4, "There's No Disgrace Like Home", "1990-01-29 03:00:00", 8.5)
View Source
var EpisodesTableName = "episodes"
View Source
var EpisodesTestSchema = createEpisodesTestSchema()
View Source
var ErrCannotCreateReplicaRevisionDbForCommit = errors.New("cannot create replica revision db for commit")
View Source
var ErrFailedToCastToReplicaDb = errors.New("failed to cast to ReadReplicaDatabase")
View Source
var ErrFailedToLoadReplicaDB = errors.New("failed to load replica database")
View Source
var ErrInvalidNonLiteralArgument = errors.NewKind("Invalid argument to %s: %s – only literal values supported")
View Source
var ErrInvalidReplicateHeadsSetting = errors.New("invalid replicate heads setting")
View Source
var ErrInvalidTableName = errors.NewKind("Invalid table name %s. Table names must match the regular expression " + doltdb.TableNameRegexStr)
View Source
var ErrKeylessAltTbl = errors.New("schema alterations not supported for keyless tables")
View Source
var ErrPrimaryKeySetsIncompatible = errors.New("primary key sets incompatible")
View Source
var ErrReservedTableName = errors.NewKind("Invalid table name %s. Table names beginning with `dolt_` are reserved for internal use")
View Source
var ErrSystemTableAlter = errors.NewKind("Cannot alter table %s: system tables cannot be dropped or altered")
View Source
var Homer = NewPeopleRow(HomerId, "Homer", "Simpson", true, 40, 8.5)

6 characters

View Source
var InitialHistSch = dtestutils.MustSchema(idColTag0TypeUUID, firstColTag1TypeStr, lastColTag2TypeStr)
View Source
var Lisa = NewPeopleRowWithOptionalFields(LisaId, "Lisa", "Simpson", false, 8, 10, uuid.MustParse("00000000-0000-0000-0000-000000000003"), 333)
View Source
var Marge = NewPeopleRowWithOptionalFields(MargeId, "Marge", "Simpson", true, 38, 8, uuid.MustParse("00000000-0000-0000-0000-000000000001"), 111)
View Source
var MaxRowsPerPartition uint64 = 32 * 1024
View Source
var MinRowsPerPartition uint64 = 1024
View Source
var Moe = NewPeopleRowWithOptionalFields(MoeId, "Moe", "Szyslak", false, 48, 6.5, uuid.MustParse("00000000-0000-0000-0000-000000000004"), 444)
View Source
var PeopleTableName = "people"
View Source
var PeopleTestSchema = createPeopleTestSchema()
View Source
var ReaddAgeAt5HistSch = dtestutils.MustSchema(idColTag0TypeUUID, firstColTag1TypeStr, lastColTag2TypeStr, addrColTag3TypeStr, ageColTag5TypeUint)

Functions

func AddDoltSystemVariables

func AddDoltSystemVariables()

func CompressRow

func CompressRow(sch schema.Schema, r row.Row) row.Row

Rewrites the tag numbers for the row given to begin at zero and be contiguous, just like result set schemas. We don't want to just use the field mappings in the result set schema used by sqlselect, since that would only demonstrate that the code was consistent with itself, not actually correct.

func CompressRows

func CompressRows(sch schema.Schema, rs ...row.Row) []row.Row

Compresses each of the rows given ala compressRow

func CompressSchema

func CompressSchema(sch schema.Schema, colNames ...string) schema.Schema

Rewrites the tag numbers for the schema given to start at 0, just like result set schemas. If one or more column names are given, only those column names are included in the compressed schema. The column list can also be used to reorder the columns as necessary.

func CompressSchemas

func CompressSchemas(schs ...schema.Schema) schema.Schema

Rewrites the tag numbers for the schemas given to start at 0, just like result set schemas.

func CreateEmptyTestDatabase

func CreateEmptyTestDatabase(dEnv *env.DoltEnv, t *testing.T)

Creates a test database without any data in it

func CreateTestDatabase

func CreateTestDatabase(dEnv *env.DoltEnv, t *testing.T)

Creates a test database with the test data set in it

func DatetimeStrToTimestamp

func DatetimeStrToTimestamp(datetime string) time.Time

func DoltProceduresAddProcedure

func DoltProceduresAddProcedure(ctx *sql.Context, db Database, spd sql.StoredProcedureDetails) (retErr error)

DoltProceduresAddProcedure adds the stored procedure to the `dolt_procedures` table in the given db, creating it if it does not exist.

func DoltProceduresDropProcedure

func DoltProceduresDropProcedure(ctx *sql.Context, db Database, name string) (retErr error)

DoltProceduresDropProcedure removes the stored procedure from the `dolt_procedures` table. The procedure named must exist.

func DoltProceduresGetAll

func DoltProceduresGetAll(ctx *sql.Context, db Database) ([]sql.StoredProcedureDetails, error)

func DoltProceduresGetDetails

func DoltProceduresGetDetails(ctx *sql.Context, tbl *WritableDoltTable, name string) (sql.StoredProcedureDetails, bool, error)

DoltProceduresGetDetails returns the stored procedure with the given name from `dolt_procedures` if it exists.

func DoltSchemaFromAlterableTable

func DoltSchemaFromAlterableTable(t *AlterableDoltTable) schema.Schema

DoltSchemaFromAlterableTable is a utility for integration tests

func DoltTableFromAlterableTable

func DoltTableFromAlterableTable(ctx *sql.Context, t *AlterableDoltTable) *doltdb.Table

DoltTableFromAlterableTable is a utility for integration tests

func ExecuteSelect

func ExecuteSelect(t *testing.T, dEnv *env.DoltEnv, ddb *doltdb.DoltDB, root *doltdb.RootValue, query string) ([]sql.Row, error)

ExecuteSelect executes the select statement given and returns the resulting rows, or an error if one is encountered.

func ExecuteSql

func ExecuteSql(t *testing.T, dEnv *env.DoltEnv, root *doltdb.RootValue, statements string) (*doltdb.RootValue, error)

ExecuteSql executes all the SQL non-select statements given in the string against the root value given and returns the updated root, or an error. Statements in the input string are split by `;\n`

func FindRowIndex

func FindRowIndex(find row.Row, rows []row.Row) int

Returns the index of the first row in the list that has the same primary key as the one given, or -1 otherwise.

func GetAllRows

func GetAllRows(root *doltdb.RootValue, tableName string) ([]row.Row, error)

func GetCommitHooks

func GetCommitHooks(ctx context.Context, bThreads *sql.BackgroundThreads, dEnv *env.DoltEnv, logger io.Writer) ([]doltdb.CommitHook, error)

GetCommitHooks creates a list of hooks to execute on database commit. If doltdb.SkipReplicationErrorsKey is set, replace misconfigured hooks with doltdb.LogHook instances that prints a warning when trying to execute.

func GetCreateTableStmt

func GetCreateTableStmt(ctx *sql.Context, engine *sqle.Engine, tableName string) (string, error)

func GetInitialDBState

func GetInitialDBState(ctx context.Context, db SqlDatabase) (dsess.InitialDbState, error)

GetInitialDBState returns the InitialDbState for |db|.

func InitializeWithHistory

func InitializeWithHistory(t *testing.T, ctx context.Context, dEnv *env.DoltEnv, historyNodes ...HistoryNode)

InitializeWithHistory will go through the provided historyNodes and create the intended commit graph

func MutateRow

func MutateRow(sch schema.Schema, r row.Row, tagsAndVals ...interface{}) row.Row

Mutates the row given with pairs of {tag,value} given in the varargs param. Converts built-in types to noms types.

func NewDiffTableFunctionRowIter

func NewDiffTableFunctionRowIter(partitions *dtables.DiffPartitions, ddb *doltdb.DoltDB, joiner *rowconv.Joiner) *diffTableFunctionRowIter

func NewDiffTableFunctionRowIterForSinglePartition

func NewDiffTableFunctionRowIterForSinglePartition(partition sql.Partition, ddb *doltdb.DoltDB, joiner *rowconv.Joiner) *diffTableFunctionRowIter

func NewPeopleRow

func NewPeopleRow(id int, first, last string, isMarried bool, age int, rating float64) row.Row

func NewPeopleRowWithOptionalFields

func NewPeopleRowWithOptionalFields(id int, first, last string, isMarried bool, age int, rating float64, uid uuid.UUID, numEpisodes uint64) row.Row

Most rows don't have these optional fields set, as they aren't needed for basic testing

func NewTestEngine

func NewTestEngine(t *testing.T, dEnv *env.DoltEnv, ctx context.Context, db Database, root *doltdb.RootValue) (*sqle.Engine, *sql.Context, error)

NewTestEngine creates a new default engine, and a *sql.Context and initializes indexes and schema fragments.

func NewTestSQLCtx

func NewTestSQLCtx(ctx context.Context) *sql.Context

NewTestSQLCtx returns a new *sql.Context with a default DoltSession, a new IndexRegistry, and a new ViewRegistry

func NewTestSQLCtxWithProvider

func NewTestSQLCtxWithProvider(ctx context.Context, pro dsess.RevisionDatabaseProvider) *sql.Context

func PrepareCreateTableStmt

func PrepareCreateTableStmt(ctx context.Context, sqlDb sql.Database) (*sql.Context, *sqle.Engine, *dsess.Session)

func ProceduresTableSchema

func ProceduresTableSchema() schema.Schema

The fixed dolt schema for the `dolt_procedures` table.

func ProceduresTableSqlSchema

func ProceduresTableSqlSchema() sql.PrimaryKeySchema

The fixed SQL schema for the `dolt_procedures` table.

func ProllyRowIterFromPartition

func ProllyRowIterFromPartition(ctx context.Context, tbl *doltdb.Table, projections []string, partition doltTablePartition) (sql.RowIter, error)

func Rs

func Rs(rows ...row.Row) []row.Row

Convenience func to avoid the boilerplate of typing []row.Row{} all the time

func SchemasTableSchema

func SchemasTableSchema() schema.Schema

The fixed dolt schema for the `dolt_schemas` table.

func SkipReplicationWarnings

func SkipReplicationWarnings() bool

func SubsetSchema

func SubsetSchema(sch schema.Schema, colNames ...string) schema.Schema

SubsetSchema returns a schema that is a subset of the schema given, with keys and constraints removed. Column names must be verified before subsetting. Unrecognized column names will cause a panic.

func TableToRowIter

func TableToRowIter(ctx *sql.Context, table *WritableDoltTable, columns []string) (sql.RowIter, error)

TableToRowIter returns a |sql.RowIter| for a full table scan for the given |table|. If |columns| is not empty, only columns with names appearing in |columns| will have non-|nil| values in the resulting |sql.Row|s. If |columns| is empty, values for all columns in the table are populated in each returned Row. The returned rows always have the schema of the table, regardless of the value of |columns|. Providing a column name which does not appear in the schema is not an error, but no corresponding column will appear in the results.

func ToSqlRows

func ToSqlRows(sch schema.Schema, rs ...row.Row) []sql.Row

Returns the dolt rows given transformed to sql rows. Exactly the columns in the schema provided are present in the final output rows, even if the input rows contain different columns. The tag numbers for columns in the row and schema given must match.

func UpdateTables

func UpdateTables(t *testing.T, ctx context.Context, root *doltdb.RootValue, tblUpdates map[string]TableUpdate) *doltdb.RootValue

Types

type AlterableDoltTable

type AlterableDoltTable struct {
	WritableDoltTable
}

AlterableDoltTable allows altering the schema of the table. It implements sql.AlterableTable.

func (*AlterableDoltTable) AddColumn

func (t *AlterableDoltTable) AddColumn(ctx *sql.Context, column *sql.Column, order *sql.ColumnOrder) error

AddColumn implements sql.AlterableTable

func (*AlterableDoltTable) AddForeignKey

func (t *AlterableDoltTable) AddForeignKey(ctx *sql.Context, sqlFk sql.ForeignKeyConstraint) error

AddForeignKey implements sql.ForeignKeyTable

func (*AlterableDoltTable) CreateCheck

func (t *AlterableDoltTable) CreateCheck(ctx *sql.Context, check *sql.CheckDefinition) error

func (*AlterableDoltTable) CreateIndex

func (t *AlterableDoltTable) CreateIndex(
	ctx *sql.Context,
	indexName string,
	using sql.IndexUsing,
	constraint sql.IndexConstraint,
	indexColumns []sql.IndexColumn,
	comment string,
) error

CreateIndex implements sql.IndexAlterableTable

func (*AlterableDoltTable) CreateIndexForForeignKey

func (t *AlterableDoltTable) CreateIndexForForeignKey(ctx *sql.Context, indexName string, using sql.IndexUsing, constraint sql.IndexConstraint, indexColumns []sql.IndexColumn) error

CreateIndexForForeignKey implements sql.ForeignKeyTable

func (*AlterableDoltTable) CreatePrimaryKey

func (t *AlterableDoltTable) CreatePrimaryKey(ctx *sql.Context, columns []sql.IndexColumn) error

func (*AlterableDoltTable) DropCheck

func (t *AlterableDoltTable) DropCheck(ctx *sql.Context, chName string) error

func (*AlterableDoltTable) DropColumn

func (t *AlterableDoltTable) DropColumn(ctx *sql.Context, columnName string) error

DropColumn implements sql.AlterableTable

func (*AlterableDoltTable) DropForeignKey

func (t *AlterableDoltTable) DropForeignKey(ctx *sql.Context, fkName string) error

DropForeignKey implements sql.ForeignKeyTable

func (*AlterableDoltTable) DropIndex

func (t *AlterableDoltTable) DropIndex(ctx *sql.Context, indexName string) error

DropIndex implements sql.IndexAlterableTable

func (*AlterableDoltTable) DropPrimaryKey

func (t *AlterableDoltTable) DropPrimaryKey(ctx *sql.Context) error

func (*AlterableDoltTable) GetForeignKeyUpdater

func (t *AlterableDoltTable) GetForeignKeyUpdater(ctx *sql.Context) sql.ForeignKeyUpdater

GetForeignKeyUpdater implements sql.ForeignKeyTable

func (*AlterableDoltTable) ModifyColumn

func (t *AlterableDoltTable) ModifyColumn(ctx *sql.Context, columnName string, column *sql.Column, order *sql.ColumnOrder) error

ModifyColumn implements sql.AlterableTable

func (*AlterableDoltTable) PrimaryKeySchema

func (t *AlterableDoltTable) PrimaryKeySchema() sql.PrimaryKeySchema

func (*AlterableDoltTable) RenameIndex

func (t *AlterableDoltTable) RenameIndex(ctx *sql.Context, fromIndexName string, toIndexName string) error

RenameIndex implements sql.IndexAlterableTable

func (*AlterableDoltTable) RewriteInserter

func (t *AlterableDoltTable) RewriteInserter(ctx *sql.Context, newSchema sql.PrimaryKeySchema) (sql.RowInserter, error)

func (*AlterableDoltTable) ShouldRewriteTable

func (t *AlterableDoltTable) ShouldRewriteTable(
	ctx *sql.Context,
	oldSchema sql.PrimaryKeySchema,
	newSchema sql.PrimaryKeySchema,
	modifiedColumn *sql.Column,
) bool

func (*AlterableDoltTable) UpdateForeignKey

func (t *AlterableDoltTable) UpdateForeignKey(ctx *sql.Context, fkName string, sqlFk sql.ForeignKeyConstraint) error

UpdateForeignKey implements sql.ForeignKeyTable

func (*AlterableDoltTable) WithProjections

func (t *AlterableDoltTable) WithProjections(colNames []string) sql.Table

type Database

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

Database implements sql.Database for a dolt DB.

func NewDatabase

func NewDatabase(name string, dbData env.DbData, editOpts editor.Options) Database

NewDatabase returns a new dolt database to use in queries.

func (Database) AllViews

func (db Database) AllViews(ctx *sql.Context) ([]sql.ViewDefinition, error)

AllViews implements sql.ViewDatabase

func (Database) CommitTransaction

func (db Database) CommitTransaction(ctx *sql.Context, tx sql.Transaction) error

func (Database) CreateSavepoint

func (db Database) CreateSavepoint(ctx *sql.Context, tx sql.Transaction, name string) error

func (Database) CreateTable

func (db Database) CreateTable(ctx *sql.Context, tableName string, sch sql.PrimaryKeySchema) error

CreateTable creates a table with the name and schema given.

func (Database) CreateTemporaryTable

func (db Database) CreateTemporaryTable(ctx *sql.Context, tableName string, pkSch sql.PrimaryKeySchema) error

CreateTemporaryTable creates a table that only exists the length of a session.

func (Database) CreateTrigger

func (db Database) CreateTrigger(ctx *sql.Context, definition sql.TriggerDefinition) error

CreateTrigger implements sql.TriggerDatabase.

func (Database) CreateView

func (db Database) CreateView(ctx *sql.Context, name string, definition string) error

CreateView implements sql.ViewCreator. Persists the view in the dolt database, so it can exist in a sql session later. Returns sql.ErrExistingView if a view with that name already exists.

func (Database) DbData

func (db Database) DbData() env.DbData

func (Database) DropStoredProcedure

func (db Database) DropStoredProcedure(ctx *sql.Context, name string) error

DropStoredProcedure implements sql.StoredProcedureDatabase.

func (Database) DropTable

func (db Database) DropTable(ctx *sql.Context, tableName string) error

DropTable drops the table with the name given. The planner returns the correct case sensitive name in tableName

func (Database) DropTrigger

func (db Database) DropTrigger(ctx *sql.Context, name string) error

DropTrigger implements sql.TriggerDatabase.

func (Database) DropView

func (db Database) DropView(ctx *sql.Context, name string) error

DropView implements sql.ViewDropper. Removes a view from persistence in the dolt database. Returns sql.ErrNonExistingView if the view did not exist.

func (Database) EditOptions

func (db Database) EditOptions() editor.Options

func (Database) Flush

func (db Database) Flush(ctx *sql.Context) error

Flush flushes the current batch of outstanding changes and returns any errors.

func (Database) GetAllTableNames

func (db Database) GetAllTableNames(ctx *sql.Context) ([]string, error)

GetAllTableNames returns all user-space tables, including system tables in user space (e.g. dolt_docs, dolt_query_catalog).

func (Database) GetAllTemporaryTables

func (db Database) GetAllTemporaryTables(ctx *sql.Context) ([]sql.Table, error)

GetAllTemporaryTables returns all temporary tables

func (Database) GetDocsReadWriter

func (db Database) GetDocsReadWriter() env.DocsReadWriter

func (Database) GetDoltDB

func (db Database) GetDoltDB() *doltdb.DoltDB

GetDoltDB gets the underlying DoltDB of the Database

func (Database) GetExternalStoredProcedures

func (db Database) GetExternalStoredProcedures(ctx *sql.Context) ([]sql.ExternalStoredProcedureDetails, error)

GetExternalStoredProcedures implements sql.ExternalStoredProcedureDatabase.

func (Database) GetGlobalState

func (db Database) GetGlobalState() globalstate.GlobalState

func (Database) GetHeadRoot

func (db Database) GetHeadRoot(ctx *sql.Context) (*doltdb.RootValue, error)

GetHeadRoot returns root value for the current session head

func (Database) GetRoot

func (db Database) GetRoot(ctx *sql.Context) (*doltdb.RootValue, error)

GetRoot returns the root value for this database session

func (Database) GetStateReader

func (db Database) GetStateReader() env.RepoStateReader

GetStateReader gets the RepoStateReader for a Database

func (Database) GetStateWriter

func (db Database) GetStateWriter() env.RepoStateWriter

GetStateWriter gets the RepoStateWriter for a Database

func (Database) GetStoredProcedures

func (db Database) GetStoredProcedures(ctx *sql.Context) ([]sql.StoredProcedureDetails, error)

GetStoredProcedures implements sql.StoredProcedureDatabase.

func (Database) GetTableInsensitive

func (db Database) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)

GetTableInsensitive is used when resolving tables in queries. It returns a best-effort case-insensitive match for the table name given.

func (Database) GetTableInsensitiveAsOf

func (db Database) GetTableInsensitiveAsOf(ctx *sql.Context, tableName string, asOf interface{}) (sql.Table, bool, error)

GetTableInsensitiveAsOf implements sql.VersionedDatabase

func (Database) GetTableInsensitiveWithRoot

func (db Database) GetTableInsensitiveWithRoot(ctx *sql.Context, root *doltdb.RootValue, tblName string) (sql.Table, bool, error)

func (Database) GetTableNames

func (db Database) GetTableNames(ctx *sql.Context) ([]string, error)

GetTableNames returns the names of all user tables. System tables in user space (e.g. dolt_docs, dolt_query_catalog) are filtered out. This method is used for queries that examine the schema of the database, e.g. show tables. Table name resolution in queries is handled by GetTableInsensitive. Use GetAllTableNames for an unfiltered list of all tables in user space.

func (Database) GetTableNamesAsOf

func (db Database) GetTableNamesAsOf(ctx *sql.Context, time interface{}) ([]string, error)

GetTableNamesAsOf implements sql.VersionedDatabase

func (Database) GetTriggers

func (db Database) GetTriggers(ctx *sql.Context) ([]sql.TriggerDefinition, error)

GetTriggers implements sql.TriggerDatabase.

func (Database) GetView

func (db Database) GetView(ctx *sql.Context, viewName string) (string, bool, error)

GetView implements sql.ViewDatabase

func (Database) GetWorkingSet

func (db Database) GetWorkingSet(ctx *sql.Context) (*doltdb.WorkingSet, error)

func (Database) Name

func (db Database) Name() string

Name returns the name of this database, set at creation time.

func (Database) ReleaseSavepoint

func (db Database) ReleaseSavepoint(ctx *sql.Context, tx sql.Transaction, name string) error

func (Database) RenameTable

func (db Database) RenameTable(ctx *sql.Context, oldName, newName string) error

renameTable implements sql.TableRenamer

func (Database) Rollback

func (db Database) Rollback(ctx *sql.Context, tx sql.Transaction) error

func (Database) RollbackToSavepoint

func (db Database) RollbackToSavepoint(ctx *sql.Context, tx sql.Transaction, name string) error

func (Database) SaveStoredProcedure

func (db Database) SaveStoredProcedure(ctx *sql.Context, spd sql.StoredProcedureDetails) error

SaveStoredProcedure implements sql.StoredProcedureDatabase.

func (Database) SetRoot

func (db Database) SetRoot(ctx *sql.Context, newRoot *doltdb.RootValue) error

SetRoot should typically be called on the Session, which is where this state lives. But it's available here as a convenience.

func (Database) StartTransaction

func (db Database) StartTransaction(ctx *sql.Context, tCharacteristic sql.TransactionCharacteristic) (sql.Transaction, error)

func (Database) TableEditSession

func (db Database) TableEditSession(ctx *sql.Context) (writer.WriteSession, error)

TableEditSession returns the TableEditSession for this database from the given context.

type DiffTableFunction

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

func (*DiffTableFunction) CheckPrivileges

func (dtf *DiffTableFunction) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool

CheckPrivileges implements the sql.Node interface

func (*DiffTableFunction) Children

func (dtf *DiffTableFunction) Children() []sql.Node

Children implements the sql.Node interface

func (*DiffTableFunction) Database

func (dtf *DiffTableFunction) Database() sql.Database

Database implements the sql.Databaser interface

func (*DiffTableFunction) Expressions

func (dtf *DiffTableFunction) Expressions() []sql.Expression

Expressions implements the sql.Expressioner interface

func (*DiffTableFunction) FunctionName

func (dtf *DiffTableFunction) FunctionName() string

FunctionName implements the sql.TableFunction interface

func (*DiffTableFunction) NewInstance

func (dtf *DiffTableFunction) NewInstance(ctx *sql.Context, database sql.Database, expressions []sql.Expression) (sql.Node, error)

NewInstance implements the TableFunction interface

func (*DiffTableFunction) Resolved

func (dtf *DiffTableFunction) Resolved() bool

Resolved implements the sql.Resolvable interface

func (*DiffTableFunction) RowIter

func (dtf *DiffTableFunction) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error)

RowIter implements the sql.Node interface

func (*DiffTableFunction) Schema

func (dtf *DiffTableFunction) Schema() sql.Schema

Schema implements the sql.Node interface

func (*DiffTableFunction) String

func (dtf *DiffTableFunction) String() string

String implements the Stringer interface

func (*DiffTableFunction) WithChildren

func (dtf *DiffTableFunction) WithChildren(node ...sql.Node) (sql.Node, error)

WithChildren implements the sql.Node interface

func (*DiffTableFunction) WithDatabase

func (dtf *DiffTableFunction) WithDatabase(database sql.Database) (sql.Node, error)

WithDatabase implements the sql.Databaser interface

func (*DiffTableFunction) WithExpressions

func (dtf *DiffTableFunction) WithExpressions(expression ...sql.Expression) (sql.Node, error)

WithExpressions implements the sql.Expressioner interface

type DoltDatabaseProvider

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

func NewDoltDatabaseProvider

func NewDoltDatabaseProvider(defaultBranch string, fs filesys.Filesys, databases ...sql.Database) DoltDatabaseProvider

NewDoltDatabaseProvider returns a provider for the databases given

func (DoltDatabaseProvider) AllDatabases

func (p DoltDatabaseProvider) AllDatabases(ctx *sql.Context) (all []sql.Database)

func (DoltDatabaseProvider) CreateDatabase

func (p DoltDatabaseProvider) CreateDatabase(ctx *sql.Context, name string) error

func (DoltDatabaseProvider) Database

func (p DoltDatabaseProvider) Database(ctx *sql.Context, name string) (db sql.Database, err error)

func (DoltDatabaseProvider) DropDatabase

func (p DoltDatabaseProvider) DropDatabase(ctx *sql.Context, name string) error

func (DoltDatabaseProvider) Function

func (p DoltDatabaseProvider) Function(_ *sql.Context, name string) (sql.Function, error)

Function implements the FunctionProvider interface

func (DoltDatabaseProvider) HasDatabase

func (p DoltDatabaseProvider) HasDatabase(ctx *sql.Context, name string) bool

func (DoltDatabaseProvider) RevisionDbState

func (p DoltDatabaseProvider) RevisionDbState(ctx context.Context, revDB string) (dsess.InitialDbState, error)

func (DoltDatabaseProvider) TableFunction

func (p DoltDatabaseProvider) TableFunction(ctx *sql.Context, name string) (sql.TableFunction, error)

TableFunction implements the TableFunctionProvider interface

func (DoltDatabaseProvider) WithDbFactoryUrl

func (p DoltDatabaseProvider) WithDbFactoryUrl(url string) DoltDatabaseProvider

WithDbFactoryUrl returns a copy of this provider with the DbFactoryUrl set as provided. The URL is used when creating new databases. See doltdb.InMemDoltDB, doltdb.LocalDirDoltDB

func (DoltDatabaseProvider) WithFunctions

func (p DoltDatabaseProvider) WithFunctions(fns []sql.Function) DoltDatabaseProvider

WithFunctions returns a copy of this provider with the functions given. Any previous functions are removed.

type DoltTable

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

DoltTable implements the sql.Table interface and gives access to dolt table rows and schema.

func NewDoltTable

func NewDoltTable(name string, sch schema.Schema, tbl *doltdb.Table, db SqlDatabase, opts editor.Options) (*DoltTable, error)

func (DoltTable) AddForeignKey

func (t DoltTable) AddForeignKey(ctx *sql.Context, fk sql.ForeignKeyConstraint) error

AddForeignKey implements sql.ForeignKeyTable

func (DoltTable) CreateIndexForForeignKey

func (t DoltTable) CreateIndexForForeignKey(ctx *sql.Context, indexName string, using sql.IndexUsing, constraint sql.IndexConstraint, columns []sql.IndexColumn) error

CreateIndexForForeignKey implements sql.ForeignKeyTable

func (*DoltTable) DataLength

func (t *DoltTable) DataLength(ctx *sql.Context) (uint64, error)

func (DoltTable) DropForeignKey

func (t DoltTable) DropForeignKey(ctx *sql.Context, fkName string) error

DropForeignKey implements sql.ForeignKeyTable

func (*DoltTable) Format

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

Format returns the NomsBinFormat for the underlying table

func (*DoltTable) GetAutoIncrementValue

func (t *DoltTable) GetAutoIncrementValue(ctx *sql.Context) (interface{}, error)

GetAutoIncrementValue gets the last AUTO_INCREMENT value

func (*DoltTable) GetChecks

func (t *DoltTable) GetChecks(ctx *sql.Context) ([]sql.CheckDefinition, error)

func (*DoltTable) GetDeclaredForeignKeys

func (t *DoltTable) GetDeclaredForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)

GetDeclaredForeignKeys implements sql.ForeignKeyTable

func (DoltTable) GetForeignKeyUpdater

func (t DoltTable) GetForeignKeyUpdater(ctx *sql.Context) sql.ForeignKeyUpdater

GetForeignKeyUpdater implements sql.ForeignKeyTable

func (*DoltTable) GetIndexes

func (t *DoltTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error)

GetIndexes implements sql.IndexedTable

func (*DoltTable) GetReferencedForeignKeys

func (t *DoltTable) GetReferencedForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)

GetReferencedForeignKeys implements sql.ForeignKeyTable

func (*DoltTable) IsTemporary

func (t *DoltTable) IsTemporary() bool

func (DoltTable) LockedToRoot

func (t DoltTable) LockedToRoot(rootValue *doltdb.RootValue) *DoltTable

LockedToRoot returns a version of this table with its root value locked to the given value. The table's values will not change as the session's root value changes. Appropriate for AS OF queries, or other use cases where the table's values should not change throughout execution of a session.

func (*DoltTable) Name

func (t *DoltTable) Name() string

Name returns the name of the table.

func (*DoltTable) NumRows

func (t *DoltTable) NumRows(ctx *sql.Context) (uint64, error)

NumRows returns the unfiltered count of rows contained in the table

func (*DoltTable) PartitionRows

func (t *DoltTable) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)

PartitionRows returns the table rows for the partition given

func (DoltTable) PartitionRows2

func (t DoltTable) PartitionRows2(ctx *sql.Context, part sql.Partition) (sql.RowIter2, error)

func (*DoltTable) Partitions

func (t *DoltTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error)

Partitions returns the partitions for this table.

func (*DoltTable) PrimaryKeySchema

func (t *DoltTable) PrimaryKeySchema() sql.PrimaryKeySchema

func (*DoltTable) Projections

func (t *DoltTable) Projections() []string

Projections implements sql.ProjectedTable

func (*DoltTable) Schema

func (t *DoltTable) Schema() sql.Schema

Schema returns the schema for this table.

func (*DoltTable) String

func (t *DoltTable) String() string

String returns a human-readable string to display the name of this SQL node.

func (DoltTable) UpdateForeignKey

func (t DoltTable) UpdateForeignKey(ctx *sql.Context, fkName string, fk sql.ForeignKeyConstraint) error

UpdateForeignKey implements sql.ForeignKeyTable

func (*DoltTable) WithIndexLookup

func (t *DoltTable) WithIndexLookup(lookup sql.IndexLookup) sql.Table

WithIndexLookup implements sql.IndexedTable

func (*DoltTable) WithProjections

func (t *DoltTable) WithProjections(colNames []string) sql.Table

WithProjections implements sql.ProjectedTable

type Extra

type Extra struct {
	CreatedAt int64
}

type HistoryNode

type HistoryNode struct {
	// Branch the branch that the commit should be on
	Branch string

	// CommitMessag is the commit message that should be applied
	CommitMsg string

	// Updates are the changes that should be made to the table's states before committing
	Updates map[string]TableUpdate

	// Children are the child commits of this commit
	Children []HistoryNode
}

HistoryNode represents a commit to be made

func CreateHistory

func CreateHistory(ctx context.Context, dEnv *env.DoltEnv, t *testing.T) []HistoryNode

type IndexedDoltTable

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

IndexedDoltTable is a wrapper for a DoltTable and a doltIndexLookup. It implements the sql.Table interface like DoltTable, but its RowIter function returns values that match the indexLookup, instead of all rows. It's returned by the DoltTable WithIndexLookup function.

func (*IndexedDoltTable) GetIndexes

func (idt *IndexedDoltTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error)

func (*IndexedDoltTable) IsTemporary

func (idt *IndexedDoltTable) IsTemporary() bool

func (*IndexedDoltTable) Name

func (idt *IndexedDoltTable) Name() string

func (*IndexedDoltTable) PartitionRows

func (idt *IndexedDoltTable) PartitionRows(ctx *sql.Context, part sql.Partition) (sql.RowIter, error)

func (*IndexedDoltTable) PartitionRows2

func (idt *IndexedDoltTable) PartitionRows2(ctx *sql.Context, part sql.Partition) (sql.RowIter, error)

func (*IndexedDoltTable) Partitions

func (idt *IndexedDoltTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error)

func (*IndexedDoltTable) Schema

func (idt *IndexedDoltTable) Schema() sql.Schema

func (*IndexedDoltTable) String

func (idt *IndexedDoltTable) String() string

func (*IndexedDoltTable) WithIndexLookup

func (idt *IndexedDoltTable) WithIndexLookup(lookup sql.IndexLookup) sql.Table

type Nullable

type Nullable bool

Nullable represents whether a column can have a null value.

const (
	NotNull Nullable = false
	Null    Nullable = true
)

type ReadOnlyDatabase

type ReadOnlyDatabase struct {
	Database
}

func (ReadOnlyDatabase) IsReadOnly

func (r ReadOnlyDatabase) IsReadOnly() bool

type ReadReplicaDatabase

type ReadReplicaDatabase struct {
	Database
	// contains filtered or unexported fields
}

func NewReadReplicaDatabase

func NewReadReplicaDatabase(ctx context.Context, db Database, remoteName string, dEnv *env.DoltEnv) (ReadReplicaDatabase, error)

func (ReadReplicaDatabase) PullFromRemote

func (rrd ReadReplicaDatabase) PullFromRemote(ctx context.Context) error

func (ReadReplicaDatabase) SetHeadRef

func (rrd ReadReplicaDatabase) SetHeadRef(head ref.DoltRef) (ReadReplicaDatabase, error)

func (ReadReplicaDatabase) StartTransaction

func (rrd ReadReplicaDatabase) StartTransaction(ctx *sql.Context, tCharacteristic sql.TransactionCharacteristic) (sql.Transaction, error)

type SingleTableInfoDatabase

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

SingleTableInfoDatabase is intended to allow a sole schema to make use of any display functionality in `go-mysql-server`. For example, you may have constructed a schema that you want a CREATE TABLE statement for, but the schema is not persisted or is temporary. This allows `go-mysql-server` to interact with that sole schema as though it were a database. No write operations will work with this database.

func NewSingleTableDatabase

func NewSingleTableDatabase(tableName string, sch schema.Schema, foreignKeys []doltdb.ForeignKey, parentSchs map[string]schema.Schema) *SingleTableInfoDatabase

func (*SingleTableInfoDatabase) AddForeignKey

func (db *SingleTableInfoDatabase) AddForeignKey(ctx *sql.Context, fk sql.ForeignKeyConstraint) error

AddForeignKey implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) CreateIndexForForeignKey

func (db *SingleTableInfoDatabase) CreateIndexForForeignKey(ctx *sql.Context, indexName string, using sql.IndexUsing, constraint sql.IndexConstraint, columns []sql.IndexColumn) error

CreateIndexForForeignKey implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) DataLength

func (db *SingleTableInfoDatabase) DataLength(ctx *sql.Context) (uint64, error)

func (*SingleTableInfoDatabase) DropForeignKey

func (db *SingleTableInfoDatabase) DropForeignKey(ctx *sql.Context, fkName string) error

DropForeignKey implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) GetChecks

func (db *SingleTableInfoDatabase) GetChecks(ctx *sql.Context) ([]sql.CheckDefinition, error)

func (*SingleTableInfoDatabase) GetDeclaredForeignKeys

func (db *SingleTableInfoDatabase) GetDeclaredForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)

GetDeclaredForeignKeys implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) GetForeignKeyUpdater

func (db *SingleTableInfoDatabase) GetForeignKeyUpdater(ctx *sql.Context) sql.ForeignKeyUpdater

GetForeignKeyUpdater implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) GetIndexes

func (db *SingleTableInfoDatabase) GetIndexes(ctx *sql.Context) ([]sql.Index, error)

GetIndexes implements sql.IndexedTable.

func (*SingleTableInfoDatabase) GetReferencedForeignKeys

func (db *SingleTableInfoDatabase) GetReferencedForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)

GetReferencedForeignKeys implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) GetTableInsensitive

func (db *SingleTableInfoDatabase) GetTableInsensitive(ctx *sql.Context, tableName string) (sql.Table, bool, error)

GetTableInsensitive implements sql.Database.

func (*SingleTableInfoDatabase) GetTableNames

func (db *SingleTableInfoDatabase) GetTableNames(ctx *sql.Context) ([]string, error)

GetTableNames implements sql.Database.

func (*SingleTableInfoDatabase) IsTemporary

func (db *SingleTableInfoDatabase) IsTemporary() bool

func (*SingleTableInfoDatabase) Name

func (db *SingleTableInfoDatabase) Name() string

Name implements sql.Table and sql.Database.

func (*SingleTableInfoDatabase) NumRows

func (db *SingleTableInfoDatabase) NumRows(context *sql.Context) (uint64, error)

func (*SingleTableInfoDatabase) PartitionRows

func (db *SingleTableInfoDatabase) PartitionRows(*sql.Context, sql.Partition) (sql.RowIter, error)

PartitionRows implements sql.Table.

func (*SingleTableInfoDatabase) PartitionRows2

func (db *SingleTableInfoDatabase) PartitionRows2(ctx *sql.Context, part sql.Partition) (sql.RowIter2, error)

func (*SingleTableInfoDatabase) Partitions

Partitions implements sql.Table.

func (*SingleTableInfoDatabase) PrimaryKeySchema

func (db *SingleTableInfoDatabase) PrimaryKeySchema() sql.PrimaryKeySchema

func (*SingleTableInfoDatabase) Schema

func (db *SingleTableInfoDatabase) Schema() sql.Schema

Schema implements sql.Table.

func (*SingleTableInfoDatabase) String

func (db *SingleTableInfoDatabase) String() string

String implements sql.Table.

func (*SingleTableInfoDatabase) UpdateForeignKey

func (db *SingleTableInfoDatabase) UpdateForeignKey(ctx *sql.Context, fkName string, fk sql.ForeignKeyConstraint) error

UpdateForeignKey implements sql.ForeignKeyTable.

func (*SingleTableInfoDatabase) WithIndexLookup

func (db *SingleTableInfoDatabase) WithIndexLookup(sql.IndexLookup) sql.Table

WithIndexLookup implements sql.IndexedTable.

type SqlDatabase

type SqlDatabase interface {
	sql.Database
	GetRoot(*sql.Context) (*doltdb.RootValue, error)
	DbData() env.DbData
	Name() string

	StartTransaction(ctx *sql.Context, tCharacteristic sql.TransactionCharacteristic) (sql.Transaction, error)
	Flush(*sql.Context) error
	EditOptions() editor.Options
}

func ApplyReplicationConfig

func ApplyReplicationConfig(ctx context.Context, bThreads *sql.BackgroundThreads, mrEnv *env.MultiRepoEnv, logger io.Writer, dbs ...SqlDatabase) ([]SqlDatabase, error)

func DbsAsDSQLDBs

func DbsAsDSQLDBs(dbs []sql.Database) []SqlDatabase

type TableUpdate

type TableUpdate struct {
	// NewSch is an updated schema for this table. It overwrites the existing value.  If not provided the existing value
	// will not change
	NewSch schema.Schema

	// NewRowData if provided overwrites the entirety of the row data in the table.
	NewRowData *types.Map

	// RowUpdates are new values for rows that should be set in the map.  They can be updates or inserts.
	RowUpdates []row.Row
}

TableUpdate defines a list of modifications that should be made to a table

type TempTable

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

func NewTempTable

func NewTempTable(
	ctx context.Context,
	ddb *doltdb.DoltDB,
	pkSch sql.PrimaryKeySchema,
	name, db string,
	opts editor.Options,
) (*TempTable, error)

func (*TempTable) AddForeignKey

func (t *TempTable) AddForeignKey(ctx *sql.Context, fk sql.ForeignKeyConstraint) error

func (*TempTable) Close

func (t *TempTable) Close(ctx *sql.Context) error

func (*TempTable) CreateCheck

func (t *TempTable) CreateCheck(ctx *sql.Context, check *sql.CheckDefinition) error

func (*TempTable) CreateIndex

func (t *TempTable) CreateIndex(ctx *sql.Context, indexName string, using sql.IndexUsing, constraint sql.IndexConstraint, columns []sql.IndexColumn, comment string) error

func (*TempTable) CreateIndexForForeignKey

func (t *TempTable) CreateIndexForForeignKey(ctx *sql.Context, indexName string, using sql.IndexUsing, constraint sql.IndexConstraint, columns []sql.IndexColumn) error

func (*TempTable) DataLength

func (t *TempTable) DataLength(ctx *sql.Context) (uint64, error)

func (*TempTable) Delete

func (t *TempTable) Delete(ctx *sql.Context, sqlRow sql.Row) error

func (*TempTable) Deleter

func (t *TempTable) Deleter(*sql.Context) sql.RowDeleter

func (*TempTable) DiscardChanges

func (t *TempTable) DiscardChanges(ctx *sql.Context, errorEncountered error) error

func (*TempTable) DropCheck

func (t *TempTable) DropCheck(ctx *sql.Context, chName string) error

func (*TempTable) DropForeignKey

func (t *TempTable) DropForeignKey(ctx *sql.Context, fkName string) error

func (*TempTable) DropIndex

func (t *TempTable) DropIndex(ctx *sql.Context, indexName string) error

func (*TempTable) Format

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

func (*TempTable) GetChecks

func (t *TempTable) GetChecks(*sql.Context) ([]sql.CheckDefinition, error)

func (*TempTable) GetDeclaredForeignKeys

func (t *TempTable) GetDeclaredForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)

func (*TempTable) GetForeignKeyUpdater

func (t *TempTable) GetForeignKeyUpdater(ctx *sql.Context) sql.ForeignKeyUpdater

func (*TempTable) GetIndexes

func (t *TempTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error)

func (*TempTable) GetReferencedForeignKeys

func (t *TempTable) GetReferencedForeignKeys(ctx *sql.Context) ([]sql.ForeignKeyConstraint, error)

func (*TempTable) Insert

func (t *TempTable) Insert(ctx *sql.Context, sqlRow sql.Row) error

func (*TempTable) Inserter

func (t *TempTable) Inserter(*sql.Context) sql.RowInserter

func (*TempTable) IsTemporary

func (t *TempTable) IsTemporary() bool

func (*TempTable) Name

func (t *TempTable) Name() string

func (*TempTable) NumRows

func (t *TempTable) NumRows(ctx *sql.Context) (uint64, error)

func (*TempTable) PartitionRows

func (t *TempTable) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)

func (*TempTable) Partitions

func (t *TempTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error)

func (*TempTable) PrimaryKeySchema

func (t *TempTable) PrimaryKeySchema() sql.PrimaryKeySchema

func (*TempTable) RenameIndex

func (t *TempTable) RenameIndex(ctx *sql.Context, fromIndexName string, toIndexName string) error

func (*TempTable) Replacer

func (t *TempTable) Replacer(*sql.Context) sql.RowReplacer

func (*TempTable) Schema

func (t *TempTable) Schema() sql.Schema

func (*TempTable) StatementBegin

func (t *TempTable) StatementBegin(ctx *sql.Context)

func (*TempTable) StatementComplete

func (t *TempTable) StatementComplete(ctx *sql.Context) error

func (*TempTable) String

func (t *TempTable) String() string

func (*TempTable) Update

func (t *TempTable) Update(ctx *sql.Context, oldRow sql.Row, newRow sql.Row) error

func (*TempTable) UpdateForeignKey

func (t *TempTable) UpdateForeignKey(ctx *sql.Context, fkName string, fk sql.ForeignKeyConstraint) error

func (*TempTable) Updater

func (t *TempTable) Updater(*sql.Context) sql.RowUpdater

func (*TempTable) WithIndexLookup

func (t *TempTable) WithIndexLookup(lookup sql.IndexLookup) sql.Table

type UserSpaceDatabase

type UserSpaceDatabase struct {
	*doltdb.RootValue
	// contains filtered or unexported fields
}

UserSpaceDatabase in an implementation of sql.Database for root values. Does not expose any of the internal dolt tables.

func NewUserSpaceDatabase

func NewUserSpaceDatabase(root *doltdb.RootValue, editOpts editor.Options) *UserSpaceDatabase

func (*UserSpaceDatabase) DbData

func (db *UserSpaceDatabase) DbData() env.DbData

func (*UserSpaceDatabase) EditOptions

func (db *UserSpaceDatabase) EditOptions() editor.Options

func (*UserSpaceDatabase) Flush

func (db *UserSpaceDatabase) Flush(ctx *sql.Context) error

func (*UserSpaceDatabase) GetRoot

func (db *UserSpaceDatabase) GetRoot(*sql.Context) (*doltdb.RootValue, error)

func (*UserSpaceDatabase) GetTableInsensitive

func (db *UserSpaceDatabase) GetTableInsensitive(ctx *sql.Context, tableName string) (sql.Table, bool, error)

func (*UserSpaceDatabase) GetTableNames

func (db *UserSpaceDatabase) GetTableNames(ctx *sql.Context) ([]string, error)

func (*UserSpaceDatabase) GetTemporaryTablesRoot

func (db *UserSpaceDatabase) GetTemporaryTablesRoot(*sql.Context) (*doltdb.RootValue, bool)

func (*UserSpaceDatabase) Name

func (db *UserSpaceDatabase) Name() string

func (*UserSpaceDatabase) StartTransaction

func (db *UserSpaceDatabase) StartTransaction(ctx *sql.Context, tCharacteristic sql.TransactionCharacteristic) (sql.Transaction, error)

type WritableDoltTable

type WritableDoltTable struct {
	*DoltTable
	// contains filtered or unexported fields
}

WritableDoltTable allows updating, deleting, and inserting new rows. It implements sql.UpdatableTable and friends.

func DoltProceduresGetOrCreateTable

func DoltProceduresGetOrCreateTable(ctx *sql.Context, db Database) (*WritableDoltTable, error)

DoltProceduresGetOrCreateTable returns the `dolt_procedures` table from the given db, creating it in the db's current root if it doesn't exist

func DoltProceduresGetTable

func DoltProceduresGetTable(ctx *sql.Context, db Database) (*WritableDoltTable, error)

DoltProceduresGetTable returns the `dolt_procedures` table from the given db, or nil if the table doesn't exist

func GetOrCreateDoltSchemasTable

func GetOrCreateDoltSchemasTable(ctx *sql.Context, db Database) (retTbl *WritableDoltTable, retErr error)

GetOrCreateDoltSchemasTable returns the `dolt_schemas` table in `db`, creating it if it does not already exist.

func (*WritableDoltTable) AutoIncrementSetter

func (t *WritableDoltTable) AutoIncrementSetter(ctx *sql.Context) sql.AutoIncrementSetter

AutoIncrementSetter implements sql.AutoIncrementTable

func (*WritableDoltTable) Deleter

func (t *WritableDoltTable) Deleter(ctx *sql.Context) sql.RowDeleter

Deleter implements sql.DeletableTable

func (*WritableDoltTable) GetNextAutoIncrementValue

func (t *WritableDoltTable) GetNextAutoIncrementValue(ctx *sql.Context, potentialVal interface{}) (uint64, error)

GetNextAutoIncrementValue implements sql.AutoIncrementTable

func (*WritableDoltTable) Inserter

func (t *WritableDoltTable) Inserter(ctx *sql.Context) sql.RowInserter

Inserter implements sql.InsertableTable

func (*WritableDoltTable) PeekNextAutoIncrementValue

func (t *WritableDoltTable) PeekNextAutoIncrementValue(ctx *sql.Context) (interface{}, error)

PeekNextAutoIncrementValue implements sql.AutoIncrementTable

func (*WritableDoltTable) Replacer

func (t *WritableDoltTable) Replacer(ctx *sql.Context) sql.RowReplacer

Replacer implements sql.ReplaceableTable

func (*WritableDoltTable) Truncate

func (t *WritableDoltTable) Truncate(ctx *sql.Context) (int, error)

Truncate implements sql.TruncateableTable

func (*WritableDoltTable) Updater

func (t *WritableDoltTable) Updater(ctx *sql.Context) sql.RowUpdater

Updater implements sql.UpdatableTable

func (*WritableDoltTable) WithIndexLookup

func (t *WritableDoltTable) WithIndexLookup(lookup sql.IndexLookup) sql.Table

func (*WritableDoltTable) WithProjections

func (t *WritableDoltTable) WithProjections(colNames []string) sql.Table

WithProjections implements sql.ProjectedTable

type WritableIndexedDoltTable

type WritableIndexedDoltTable struct {
	*WritableDoltTable
	// contains filtered or unexported fields
}

func (*WritableIndexedDoltTable) PartitionRows

func (t *WritableIndexedDoltTable) PartitionRows(ctx *sql.Context, part sql.Partition) (sql.RowIter, error)

func (*WritableIndexedDoltTable) PartitionRows2

func (t *WritableIndexedDoltTable) PartitionRows2(ctx *sql.Context, part sql.Partition) (sql.RowIter2, error)

func (*WritableIndexedDoltTable) Partitions

func (t *WritableIndexedDoltTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error)

func (*WritableIndexedDoltTable) Projections

func (t *WritableIndexedDoltTable) Projections() []string

Projections implements sql.ProjectedTable

func (*WritableIndexedDoltTable) WithProjections

func (t *WritableIndexedDoltTable) WithProjections(colNames []string) sql.Table

WithProjections implements sql.ProjectedTable

Directories

Path Synopsis
Package expreval provides go-mysql-server expression evaluation logic that works directly on noms types.
Package expreval provides go-mysql-server expression evaluation logic that works directly on noms types.
logictest
Package setalgebra provides the ability to perform algebraic set operations on mathematical sets built directly on noms types.
Package setalgebra provides the ability to perform algebraic set operations on mathematical sets built directly on noms types.

Jump to

Keyboard shortcuts

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