core

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DoltgresFeatureVersion = doltdb.DoltFeatureVersion + 0

DoltgresFeatureVersion is Doltgres' feature version. We use Dolt's feature version added to our own.

Functions

func ClearContextValues added in v0.51.1

func ClearContextValues(ctx *sql.Context)

ClearContextValues clears all context values. This is primarily for operations that are directly called from Dolt, as Dolt does not have the Doltgres concept of context values. Care must be taken to ensure that intermediate state written to the context values are not overwritten.

func CloseContextRootFinalizer added in v0.8.0

func CloseContextRootFinalizer(ctx *sql.Context) error

CloseContextRootFinalizer finalizes any changes persisted within the context by writing them to the working root. This should ONLY be called by the ContextRootFinalizer node.

func GetCurrentSchema added in v0.7.5

func GetCurrentSchema(ctx *sql.Context) (string, error)

GetCurrentSchema returns the current schema used by the context. Defaults to "public" if the context does not specify a schema.

func GetDoltTableFromContext added in v0.12.0

func GetDoltTableFromContext(ctx *sql.Context, tableName doltdb.TableName) (*doltdb.Table, error)

GetDoltTableFromContext returns the Dolt table from the context. Returns nil if no table was found.

func GetExtensionsCollectionFromContext added in v0.51.0

func GetExtensionsCollectionFromContext(ctx *sql.Context, database string) (*extensions.Collection, error)

GetExtensionsCollectionFromContext returns the extensions collection from the given context. Will always return a collection if no error is returned.

func GetFunctionsCollectionFromContext added in v0.18.0

func GetFunctionsCollectionFromContext(ctx *sql.Context) (*functions.Collection, error)

GetFunctionsCollectionFromContext returns the functions collection from the given context. Will always return a collection if no error is returned.

func GetPgCatalogCache added in v0.15.0

func GetPgCatalogCache(ctx *sql.Context) (any, error)

GetPgCatalogCache returns a cache of data for pg_catalog tables. This function should only be used by pg_catalog table handlers. The catalog cache instance stores generated pg_catalog table data so that it only has to generated table data once per query.

TODO: The return type here is currently any, to avoid a package import cycle. This could be cleaned up by introducing a new interface type, in a package that does not depend on core or pgcatalog packages.

func GetSchemaName added in v0.12.0

func GetSchemaName(ctx *sql.Context, db sql.Database, schemaName string) (string, error)

GetSchemaName returns the schema name if there is any exist. If the given schema is not empty, it's returned. If it is empty, uses given database to get schema name if it's DatabaseSchema. If it's not of DatabaseSchema type or the schema name of it is empty, it tries retrieving the current schema used by the context. Defaults to "public" if the context does not specify a schema.

func GetSequencesCollectionFromContext added in v0.14.0

func GetSequencesCollectionFromContext(ctx *sql.Context, database string) (*sequences.Collection, error)

GetSequencesCollectionFromContext returns the given sequence collection from the context for the database named. If no database is provided, the context's current database is used. Will always return a collection if no error is returned.

func GetSqlDatabaseFromContext added in v0.12.0

func GetSqlDatabaseFromContext(ctx *sql.Context, database string) (sql.Database, error)

GetSqlDatabaseFromContext returns the database from the context. Uses the context's current database if an empty string is provided. Returns nil if the database was not found.

func GetSqlTableFromContext added in v0.12.0

func GetSqlTableFromContext(ctx *sql.Context, databaseName string, tableName doltdb.TableName) (sql.Table, error)

GetSqlTableFromContext returns the table from the context. Uses the context's current database if an empty database name is provided. Returns nil if no table was found.

func GetTriggersCollectionFromContext added in v0.50.1

func GetTriggersCollectionFromContext(ctx *sql.Context, database string) (*triggers.Collection, error)

GetTriggersCollectionFromContext returns the triggers collection from the given context. Will always return a collection if no error is returned.

func GetTypesCollectionFromContext added in v0.14.0

func GetTypesCollectionFromContext(ctx *sql.Context) (*typecollection.TypeCollection, error)

GetTypesCollectionFromContext returns the given type collection from the context. Will always return a collection if no error is returned.

func Init

func Init()

Init initializes this package.

func IsContextValid added in v0.18.0

func IsContextValid(ctx *sql.Context) bool

IsContextValid returns whether the context is valid for use with any of the functions in the package. If this is not false, then there's a high likelihood that the context is being used in a temporary scenario (such as setting up the database, etc.).

func SetPgCatalogCache added in v0.15.0

func SetPgCatalogCache(ctx *sql.Context, pgCatalogCache any) error

SetPgCatalogCache sets |pgCatalogCache| as the catalog cache instance for this session.

TODO: The input type here is currently any, to avoid a package import cycle. This could be cleaned up by introducing a new interface type, in a package that does not depend on core or pgcatalog packages.

Types

type RelationType added in v0.8.0

type RelationType byte

RelationType states the type of the relation.

const (
	RelationType_DoesNotExist RelationType = iota
	RelationType_Table
	RelationType_Sequence
)

func GetRelationType added in v0.8.0

func GetRelationType(ctx *sql.Context, schema string, relation string) (RelationType, error)

GetRelationType returns whether the working root has the given relation, and what type of relation it is. According to the Postgres docs, a relation may be one of: table, sequence, index, view, materialized view, foreign table. This may also include composite types and partitions, but this hasn't been confirmed.

func GetRelationTypeFromRoot added in v0.8.0

func GetRelationTypeFromRoot(ctx *sql.Context, schema string, relation string, root *RootValue) (RelationType, error)

GetRelationTypeFromRoot performs the same function as GetRelationType, except that it uses the given root rather than the working session's root.

type RootValue added in v0.7.5

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

RootValue is Doltgres' implementation of doltdb.RootValue.

func GetRootFromContext added in v0.51.0

func GetRootFromContext(ctx *sql.Context) (*dsess.DoltSession, *RootValue, error)

GetRootFromContext returns the working session's root from the context, along with the session.

func (*RootValue) CreateDatabaseSchema added in v0.7.5

func (root *RootValue) CreateDatabaseSchema(ctx context.Context, dbSchema schema.DatabaseSchema) (doltdb.RootValue, error)

CreateDatabaseSchema implements the interface doltdb.RootValue.

func (*RootValue) DebugString added in v0.7.5

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

DebugString implements the interface doltdb.RootValue.

func (*RootValue) FilterRootObjectNames added in v0.50.0

func (root *RootValue) FilterRootObjectNames(ctx context.Context, names []doltdb.TableName) ([]doltdb.TableName, error)

FilterRootObjectNames implements the interface doltdb.RootValue.

func (*RootValue) GetAllTableNames added in v0.51.2

func (root *RootValue) GetAllTableNames(ctx context.Context, includeRootObjects bool) ([]doltdb.TableName, error)

GetAllTableNames implements the interface doltdb.RootValue.

func (*RootValue) GetCollation added in v0.7.5

func (root *RootValue) GetCollation(ctx context.Context) (schema.Collation, error)

GetCollation implements the interface doltdb.RootValue.

func (*RootValue) GetConflictRootObject added in v0.51.1

func (root *RootValue) GetConflictRootObject(ctx context.Context, tName doltdb.TableName) (doltdb.ConflictRootObject, bool, error)

GetConflictRootObject implements the interface doltdb.RootValue. This function is specifically used to find conflicts, as the standard GetRootObject will not look at the conflicts collection.

func (*RootValue) GetConflictRootObjects added in v0.51.1

func (root *RootValue) GetConflictRootObjects(ctx context.Context) ([]doltdb.ConflictRootObject, error)

GetConflictRootObjects implements the interface doltdb.RootValue.

func (*RootValue) GetDatabaseSchemas added in v0.7.5

func (root *RootValue) GetDatabaseSchemas(ctx context.Context) ([]schema.DatabaseSchema, error)

GetDatabaseSchemas implements the interface doltdb.RootValue.

func (*RootValue) GetFeatureVersion added in v0.7.5

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

GetFeatureVersion implements the interface doltdb.RootValue.

func (*RootValue) GetForeignKeyCollection added in v0.7.5

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

GetForeignKeyCollection implements the interface doltdb.RootValue.

func (*RootValue) GetRootObject added in v0.50.0

func (root *RootValue) GetRootObject(ctx context.Context, tName doltdb.TableName) (doltdb.RootObject, bool, error)

GetRootObject implements the interface doltdb.RootValue.

func (*RootValue) GetStorage added in v0.50.0

func (root *RootValue) GetStorage(ctx context.Context) storage.RootStorage

GetStorage returns the underlying storage.

func (*RootValue) GetTable added in v0.7.5

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

GetTable implements the interface doltdb.RootValue.

func (*RootValue) GetTableHash added in v0.7.5

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

GetTableHash implements the interface doltdb.RootValue.

func (*RootValue) GetTableNames added in v0.7.5

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

GetTableNames implements the interface doltdb.RootValue.

func (*RootValue) GetTableSchemaHash added in v0.11.0

func (root *RootValue) GetTableSchemaHash(ctx context.Context, tName doltdb.TableName) (hash.Hash, error)

GetTableSchemaHash implements the interface doltdb.RootValue.

func (*RootValue) HasTable added in v0.7.5

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

HasTable implements the interface doltdb.RootValue.

func (*RootValue) HashOf added in v0.7.5

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

HashOf implements the interface doltdb.RootValue.

func (*RootValue) IterRootObjects added in v0.50.0

func (root *RootValue) IterRootObjects(ctx context.Context, cb func(name doltdb.TableName, table doltdb.RootObject) (stop bool, err error)) error

IterRootObjects implements the interface doltdb.RootValue.

func (*RootValue) IterTables added in v0.7.5

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

IterTables implements the interface doltdb.RootValue.

func (*RootValue) NodeStore added in v0.7.5

func (root *RootValue) NodeStore() tree.NodeStore

NodeStore implements the interface doltdb.RootValue.

func (*RootValue) NomsValue added in v0.7.5

func (root *RootValue) NomsValue() types.Value

NomsValue implements the interface doltdb.RootValue.

func (*RootValue) PutForeignKeyCollection added in v0.7.5

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

PutForeignKeyCollection implements the interface doltdb.RootValue.

func (*RootValue) PutRootObject added in v0.50.0

func (root *RootValue) PutRootObject(ctx context.Context, tName doltdb.TableName, rootObj doltdb.RootObject) (doltdb.RootValue, error)

PutRootObject implements the interface doltdb.RootValue.

func (*RootValue) PutTable added in v0.7.5

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

PutTable implements the interface doltdb.RootValue.

func (*RootValue) RemoveTables added in v0.7.5

func (root *RootValue) RemoveTables(
	ctx context.Context,
	skipFKHandling bool,
	allowDroppingFKReferenced bool,
	originalTables ...doltdb.TableName,
) (doltdb.RootValue, error)

RemoveTables implements the interface doltdb.RootValue.

func (*RootValue) RenameTable added in v0.7.5

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

RenameTable implements the interface doltdb.RootValue.

func (*RootValue) ResolveRootValue added in v0.7.5

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

ResolveRootValue implements the interface doltdb.RootValue.

func (*RootValue) ResolveTableName added in v0.7.5

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

ResolveTableName implements the interface doltdb.RootValue.

func (*RootValue) SetCollation added in v0.7.5

func (root *RootValue) SetCollation(ctx context.Context, collation schema.Collation) (doltdb.RootValue, error)

SetCollation implements the interface doltdb.RootValue.

func (*RootValue) SetFeatureVersion added in v0.7.5

func (root *RootValue) SetFeatureVersion(v doltdb.FeatureVersion) (doltdb.RootValue, error)

SetFeatureVersion implements the interface doltdb.RootValue.

func (*RootValue) SetTableHash added in v0.7.5

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

SetTableHash implements the interface doltdb.RootValue.

func (*RootValue) TableListHash added in v0.11.0

func (root *RootValue) TableListHash() uint64

func (*RootValue) VRW added in v0.7.5

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

VRW implements the interface doltdb.RootValue.

func (*RootValue) WithStorage added in v0.50.0

func (root *RootValue) WithStorage(ctx context.Context, st storage.RootStorage) objinterface.RootValue

WithStorage returns a new root value with the given storage.

Jump to

Keyboard shortcuts

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