Help us shape the future of Go! Take the 2026 Go Developer Survey

mysql

package
v0.57.29 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyDatabaseName is returned if an empty string is found where a db name is expected.
	ErrEmptyDatabaseName = errors.New("empty database name is invalid")
	// ErrDatabaseExists is returned if the database already exists.
	ErrDatabaseExists = errors.New("database already exists")
	// ErrDatabaseNotFound is returned if the database does not exist.
	ErrDatabaseNotFound = sql.ErrDatabaseNotFound
	// ErrEmptyTableName is returned if an empty string is found where a table name is expected.
	ErrEmptyTableName = errors.New("empty table name is invalid")
	// ErrEmptyTable is returned if an empty table is found where at least one column is expected.
	ErrEmptyTable = errors.New("empty table with no columns is invalid")
	// ErrEmptyTableColumn is returned if an empty table column is found where one is expected.
	ErrEmptyTableColumn = errors.New("empty table column schema is invalid")
	// ErrEmptyTableColumnName is returned if an empty table column name is found where one is expected.
	ErrEmptyTableColumnName = errors.New("empty table column name is invalid")
	// ErrUnexpectedType is returned if a type assertion failed.
	ErrUnexpectedType = errors.New("sql db unexpected object type")
)

Functions

func BuildTable

func BuildTable(
	ctx context.Context,
	bcs *block.Cursor,
	name string,
	schema sql.PrimaryKeySchema,
	collationID sql.CollationID,
	comment string,
) (*TableRoot, *Table, error)

BuildTable constructs a new table, storing it in the block cursor (if set).

If bcs is nil, the returned *Table will also be nil.

func GetDbContext

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

GetDbContext gets the sql context or returns background.

func NewDatabaseRootBlock

func NewDatabaseRootBlock() block.Block

NewDatabaseRootBlock constructs a new db root block.

func NewRootBlock

func NewRootBlock() block.Block

NewRootBlock constructs a new root block.

func NewSqlConnector

func NewSqlConnector(ctx context.Context, tx *Tx, dsn string) (driver.Connector, error)

NewSqlConnector constructs a new sql conn from a transaction. NOTE: dsn is used to specify arguments and is NOT the db name. ctx is used for the driver Resolve() function.

func NewSqlDb

func NewSqlDb(ctx context.Context, tx *Tx, dsn string) (*sql.DB, error)

NewSqlDb opens the sql database driver as a stdlib *sql.DB. stdlib database/sql pulls reflect through its convert.go Scan path, and the browser GoScript build never opens a high-level *sql.DB; the only caller is the native gorm adapter. Keep this native-only so reflect stays out of the web build. NOTE: dsn is used to specify arguments and is NOT the db name. ctx is used for the provider Resolve function.

func NewSqlDriver

func NewSqlDriver(ctx context.Context, tx *Tx, driverOpts *gdriver.Options) *gdriver.Driver

NewSqlDriver constructs a sql driver from a transaction.

ctx is used for the driver Resolve() function.

func NewTableRootBlock

func NewTableRootBlock() block.Block

NewTableRootBlock constructs an empty table root block.

func ParseColumnType

func ParseColumnType(typeStr string) (*sqlparser.ColumnType, error)

ParseColumnType parses a column type string to a sqlparser.ColumnType.

Types

type CommitFn

type CommitFn func(nref *bucket.ObjectRef) error

CommitFn is a function to call with the updated root before confirming it. Should be used to write the updated state back to storage. Note: engine rmtx is locked while cb is called, do not block or call engine funcs! If an error is returned the change will be rolled back. Do not change the nrootBcs during this call.

type Database

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

Database is the block-graph backed SQL db cursor. NOTE: calls are not concurrency-safe.

func NewDatabase

func NewDatabase(ctx context.Context, name string, readOnly bool, bcs *block.Cursor) (*Database, error)

NewDatabase constructs a new database handle.

func (*Database) CreateTable

func (d *Database) CreateTable(ctx *sql.Context, name string, schema sql.PrimaryKeySchema, collation sql.CollationID, comment string) error

CreateTable creates the table with the given name and schema. If a table with that name already exists, returns sql.ErrTableAlreadyExists.

func (*Database) DropTable

func (d *Database) DropTable(ctx *sql.Context, name string) error

DropTable deletes a table, if it exists.

func (*Database) GetTableInsensitive

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

GetTableInsensitive retrieves a table by its case insensitive name. Implementations should look for exact (case-sensitive matches) first. If no exact matches are found then any table matching the name case insensitively should be returned. If there is more than one table that matches a case insensitive comparison the resolution strategy is not defined.

func (*Database) GetTableNames

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

GetTableNames returns the table names of every table in the database

func (*Database) IsReadOnly

func (d *Database) IsReadOnly() bool

IsReadOnly returns whether this database is read-only.

func (*Database) MarkDirty added in v0.51.0

func (d *Database) MarkDirty()

MarkDirty marks the database root dirty for the next transaction write.

func (*Database) Name

func (d *Database) Name() string

Name returns the name.

func (*Database) RenameTable

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

RenameTable renames a table from oldName to newName as given. It returns sql.ErrTableAlreadyExists when a table named newName exists.

func (*Database) TableCount

func (d *Database) TableCount() int

TableCount returns the count of tables in the database.

type DatabaseRoot

type DatabaseRoot struct {

	// Tables contains the table list sorted by name.
	Tables []*DatabaseRootTable `protobuf:"bytes,1,rep,name=tables,proto3" json:"tables,omitempty"`
	// contains filtered or unexported fields
}

DatabaseRoot is the root object of the database.

func LoadDatabaseRoot

func LoadDatabaseRoot(ctx context.Context, cursor *block.Cursor) (*DatabaseRoot, error)

LoadDatabaseRoot follows the database root cursor. may return nil

func (*DatabaseRoot) ApplySubBlock

func (r *DatabaseRoot) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*DatabaseRoot) BlockAliasIdentity added in v0.52.0

func (r *DatabaseRoot) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for DatabaseRoot.

func (*DatabaseRoot) CloneMessageVT

func (m *DatabaseRoot) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*DatabaseRoot) CloneVT

func (m *DatabaseRoot) CloneVT() *DatabaseRoot

func (*DatabaseRoot) EqualMessageVT

func (this *DatabaseRoot) EqualMessageVT(thatMsg any) bool

func (*DatabaseRoot) EqualVT

func (this *DatabaseRoot) EqualVT(that *DatabaseRoot) bool

func (*DatabaseRoot) GetRootTableSet

func (r *DatabaseRoot) GetRootTableSet(bcs *block.Cursor) *namedsbset.NamedSubBlockSet

GetRootTableSet returns the root table set sub-block.

bcs is optional

func (*DatabaseRoot) GetSubBlockCtor

func (r *DatabaseRoot) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*DatabaseRoot) GetSubBlocks

func (r *DatabaseRoot) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*DatabaseRoot) GetTables

func (x *DatabaseRoot) GetTables() []*DatabaseRootTable

func (*DatabaseRoot) InsertTable

func (r *DatabaseRoot) InsertTable(name string, ref *block.BlockRef, bcs *block.Cursor) (*block.Cursor, bool)

InsertTable inserts a new table. Caller should check if it doesn't exist before calling.

Returns new cursor, added. bcs can be nil, or should be located at root.

func (*DatabaseRoot) IsNil

func (r *DatabaseRoot) IsNil() bool

IsNil returns if the object is nil.

func (*DatabaseRoot) MarshalJSON

func (x *DatabaseRoot) MarshalJSON() ([]byte, error)

MarshalJSON marshals the DatabaseRoot to JSON.

func (*DatabaseRoot) MarshalProtoJSON

func (x *DatabaseRoot) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the DatabaseRoot message to JSON.

func (*DatabaseRoot) MarshalProtoText

func (x *DatabaseRoot) MarshalProtoText() string

func (*DatabaseRoot) MarshalToSizedBufferVT

func (m *DatabaseRoot) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*DatabaseRoot) MarshalToVT

func (m *DatabaseRoot) MarshalToVT(dAtA []byte) (int, error)

func (*DatabaseRoot) MarshalVT

func (m *DatabaseRoot) MarshalVT() (dAtA []byte, err error)

func (*DatabaseRoot) ProtoMessage

func (*DatabaseRoot) ProtoMessage()

func (*DatabaseRoot) Reset

func (x *DatabaseRoot) Reset()

func (*DatabaseRoot) SizeVT

func (m *DatabaseRoot) SizeVT() (n int)

func (*DatabaseRoot) String

func (x *DatabaseRoot) String() string

func (*DatabaseRoot) UnmarshalJSON

func (x *DatabaseRoot) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the DatabaseRoot from JSON.

func (*DatabaseRoot) UnmarshalProtoJSON

func (x *DatabaseRoot) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the DatabaseRoot message from JSON.

func (*DatabaseRoot) UnmarshalVT

func (m *DatabaseRoot) UnmarshalVT(dAtA []byte) error

func (*DatabaseRoot) Validate

func (r *DatabaseRoot) Validate() error

Validate validates the database root block.

type DatabaseRootTable

type DatabaseRootTable struct {

	// Name is the unique name of the table.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Ref is the block reference to the table root.
	// Type: TableRoot.
	Ref *block.BlockRef `protobuf:"bytes,2,opt,name=ref,proto3" json:"ref,omitempty"`
	// contains filtered or unexported fields
}

DatabaseRootTable contains the reference to the TableRoot.

func (*DatabaseRootTable) ApplyBlockRef

func (r *DatabaseRootTable) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*DatabaseRootTable) BlockAliasIdentity added in v0.52.0

func (r *DatabaseRootTable) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for DatabaseRootTable.

func (*DatabaseRootTable) CloneMessageVT

func (m *DatabaseRootTable) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*DatabaseRootTable) CloneVT

func (m *DatabaseRootTable) CloneVT() *DatabaseRootTable

func (*DatabaseRootTable) EqualMessageVT

func (this *DatabaseRootTable) EqualMessageVT(thatMsg any) bool

func (*DatabaseRootTable) EqualVT

func (this *DatabaseRootTable) EqualVT(that *DatabaseRootTable) bool

func (*DatabaseRootTable) GetBlockRefCtor

func (r *DatabaseRootTable) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*DatabaseRootTable) GetBlockRefs

func (r *DatabaseRootTable) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*DatabaseRootTable) GetName

func (x *DatabaseRootTable) GetName() string

func (*DatabaseRootTable) GetRef

func (x *DatabaseRootTable) GetRef() *block.BlockRef

func (*DatabaseRootTable) IsNil

func (r *DatabaseRootTable) IsNil() bool

IsNil returns if the object is nil.

func (*DatabaseRootTable) MarshalJSON

func (x *DatabaseRootTable) MarshalJSON() ([]byte, error)

MarshalJSON marshals the DatabaseRootTable to JSON.

func (*DatabaseRootTable) MarshalProtoJSON

func (x *DatabaseRootTable) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the DatabaseRootTable message to JSON.

func (*DatabaseRootTable) MarshalProtoText

func (x *DatabaseRootTable) MarshalProtoText() string

func (*DatabaseRootTable) MarshalToSizedBufferVT

func (m *DatabaseRootTable) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*DatabaseRootTable) MarshalToVT

func (m *DatabaseRootTable) MarshalToVT(dAtA []byte) (int, error)

func (*DatabaseRootTable) MarshalVT

func (m *DatabaseRootTable) MarshalVT() (dAtA []byte, err error)

func (*DatabaseRootTable) ProtoMessage

func (*DatabaseRootTable) ProtoMessage()

func (*DatabaseRootTable) Reset

func (x *DatabaseRootTable) Reset()

func (*DatabaseRootTable) SizeVT

func (m *DatabaseRootTable) SizeVT() (n int)

func (*DatabaseRootTable) String

func (x *DatabaseRootTable) String() string

func (*DatabaseRootTable) UnmarshalJSON

func (x *DatabaseRootTable) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the DatabaseRootTable from JSON.

func (*DatabaseRootTable) UnmarshalProtoJSON

func (x *DatabaseRootTable) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the DatabaseRootTable message from JSON.

func (*DatabaseRootTable) UnmarshalVT

func (m *DatabaseRootTable) UnmarshalVT(dAtA []byte) error

func (*DatabaseRootTable) Validate

func (r *DatabaseRootTable) Validate() error

Validate performs cursory validation.

type DriverProvider

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

DriverProvider implements the Provider interface for the sql driver.

func NewDriverProvider

func NewDriverProvider(ctx context.Context, sqlTx *Tx) *DriverProvider

NewDriverProvider constructs a driver provider.

ctx is used for the Resolve() function.

func (*DriverProvider) NewContext

func (p *DriverProvider) NewContext(
	ctx context.Context,
	conn *gdriver.Conn,
	opts ...sql.ContextOption,
) (*sql.Context, error)

NewContext constructs the SQL context for the conn.

func (*DriverProvider) NewSession

func (p *DriverProvider) NewSession(
	ctx context.Context,
	id uint32,
	conn *gdriver.Connector,
) (sql.Session, error)

NewSession builds a session for the connection.

func (*DriverProvider) Resolve

func (p *DriverProvider) Resolve(name string, options *gdriver.Options) (string, sql.DatabaseProvider, error)

Resolve is called in OpenConnector to lookup the database with the given name.

type Mysql

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

Mysql is the root of a mysql server data structure, containing named databases.

func NewMysql

func NewMysql(rootCursor RootCursor, commitFn CommitFn) *Mysql

NewMysql creates a handle with an optional root object cursor pointing to the tree. The cursor ref can be empty to indicate a new tree.

func (*Mysql) GetRootNodeRef

func (t *Mysql) GetRootNodeRef() *bucket.ObjectRef

GetRootNodeRef returns the reference to the root node.

func (*Mysql) NewMysqlTransaction

func (t *Mysql) NewMysqlTransaction(ctx context.Context, write bool) (*Tx, error)

NewMysqlTransaction returns a transaction against the db.

func (*Mysql) NewSqlTransaction

func (t *Mysql) NewSqlTransaction(ctx context.Context, write bool, dsn string) (sql.SqlTransaction, error)

NewTransaction returns a new SqlDB transaction.

func (*Mysql) SetRootNodeRef added in v0.52.0

func (t *Mysql) SetRootNodeRef(ref *bucket.ObjectRef)

SetRootNodeRef switches the root cursor to an externally advanced root.

type Root

type Root struct {

	// Databases contains the root set of databases, sorted by name.
	Databases []*RootDb `protobuf:"bytes,1,rep,name=databases,proto3" json:"databases,omitempty"`
	// contains filtered or unexported fields
}

Root is the root object of the mysql database.

func LoadRoot

func LoadRoot(ctx context.Context, cursor *block.Cursor) (*Root, error)

LoadRoot follows the root cursor. may return nil

func (*Root) ApplySubBlock

func (n *Root) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Root) CloneMessageVT

func (m *Root) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Root) CloneVT

func (m *Root) CloneVT() *Root

func (*Root) EqualMessageVT

func (this *Root) EqualMessageVT(thatMsg any) bool

func (*Root) EqualVT

func (this *Root) EqualVT(that *Root) bool

func (*Root) GetDatabases

func (x *Root) GetDatabases() []*RootDb

func (*Root) GetRootDbSet

func (n *Root) GetRootDbSet(bcs *block.Cursor) *namedsbset.NamedSubBlockSet

GetRootDbSet returns the root db set sub-block.

bcs is optional

func (*Root) GetSubBlockCtor

func (n *Root) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Root) GetSubBlocks

func (n *Root) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Root) InsertDatabase

func (n *Root) InsertDatabase(name string, ref *block.BlockRef, bcs *block.Cursor) (*RootDb, *block.Cursor)

InsertDatabase inserts a new database. Caller should check if it doesn't exist before calling.

Returns new cursor located at *RootDb, added. bcs can be nil, or should be located at root of db.

func (*Root) MarshalJSON

func (x *Root) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Root to JSON.

func (*Root) MarshalProtoJSON

func (x *Root) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Root message to JSON.

func (*Root) MarshalProtoText

func (x *Root) MarshalProtoText() string

func (*Root) MarshalToSizedBufferVT

func (m *Root) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Root) MarshalToVT

func (m *Root) MarshalToVT(dAtA []byte) (int, error)

func (*Root) MarshalVT

func (m *Root) MarshalVT() (dAtA []byte, err error)

func (*Root) ProtoMessage

func (*Root) ProtoMessage()

func (*Root) Reset

func (x *Root) Reset()

func (*Root) SizeVT

func (m *Root) SizeVT() (n int)

func (*Root) String

func (x *Root) String() string

func (*Root) UnmarshalJSON

func (x *Root) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Root from JSON.

func (*Root) UnmarshalProtoJSON

func (x *Root) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Root message from JSON.

func (*Root) UnmarshalVT

func (m *Root) UnmarshalVT(dAtA []byte) error

func (*Root) Validate

func (n *Root) Validate() error

Validate validates the root block.

type RootCursor added in v0.51.0

type RootCursor interface {
	// BuildTransaction opens a block transaction at the committed root.
	BuildTransaction(*block.PutOpts) (*block.Transaction, *block.Cursor)
	// GetRef returns the committed root object reference.
	GetRef() *bucket.ObjectRef
	// SetRootRef advances the committed root to ref.
	SetRootRef(*block.BlockRef)
}

RootCursor is the minimal cursor surface Mysql needs to read and update the root object reference.

type RootDb

type RootDb struct {

	// Name is the unique name of the database.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Ref is the block reference to the database root.
	// If empty, the database is empty.
	// Type: DatabaseRoot.
	Ref *block.BlockRef `protobuf:"bytes,2,opt,name=ref,proto3" json:"ref,omitempty"`
	// contains filtered or unexported fields
}

RootDb contains the root definition of a database.

func (*RootDb) ApplyBlockRef

func (r *RootDb) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*RootDb) BlockAliasIdentity added in v0.52.0

func (r *RootDb) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for RootDb.

func (*RootDb) CloneMessageVT

func (m *RootDb) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*RootDb) CloneVT

func (m *RootDb) CloneVT() *RootDb

func (*RootDb) EqualMessageVT

func (this *RootDb) EqualMessageVT(thatMsg any) bool

func (*RootDb) EqualVT

func (this *RootDb) EqualVT(that *RootDb) bool

func (*RootDb) GetBlockRefCtor

func (r *RootDb) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*RootDb) GetBlockRefs

func (r *RootDb) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*RootDb) GetName

func (x *RootDb) GetName() string

func (*RootDb) GetRef

func (x *RootDb) GetRef() *block.BlockRef

func (*RootDb) IsNil

func (r *RootDb) IsNil() bool

IsNil returns if the object is nil.

func (*RootDb) MarshalJSON

func (x *RootDb) MarshalJSON() ([]byte, error)

MarshalJSON marshals the RootDb to JSON.

func (*RootDb) MarshalProtoJSON

func (x *RootDb) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the RootDb message to JSON.

func (*RootDb) MarshalProtoText

func (x *RootDb) MarshalProtoText() string

func (*RootDb) MarshalToSizedBufferVT

func (m *RootDb) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*RootDb) MarshalToVT

func (m *RootDb) MarshalToVT(dAtA []byte) (int, error)

func (*RootDb) MarshalVT

func (m *RootDb) MarshalVT() (dAtA []byte, err error)

func (*RootDb) ProtoMessage

func (*RootDb) ProtoMessage()

func (*RootDb) Reset

func (x *RootDb) Reset()

func (*RootDb) SizeVT

func (m *RootDb) SizeVT() (n int)

func (*RootDb) String

func (x *RootDb) String() string

func (*RootDb) UnmarshalJSON

func (x *RootDb) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the RootDb from JSON.

func (*RootDb) UnmarshalProtoJSON

func (x *RootDb) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the RootDb message from JSON.

func (*RootDb) UnmarshalVT

func (m *RootDb) UnmarshalVT(dAtA []byte) error

func (*RootDb) Validate

func (r *RootDb) Validate() error

Validate performs cursory checks on the RootDb.

type SqlConn

type SqlConn interface {
	driver.Conn
	hydra_sql.SqlOps
}

SqlConn is the set of interfaces the mysql driver conn implements.

func NewSqlConn

func NewSqlConn(ctx context.Context, tx *Tx, dsn string) (SqlConn, error)

NewSqlConn creates a sql conn from a transaction and dsn. NOTE: dsn is used to specify arguments and is NOT the db name.

type SqlTx

type SqlTx struct {
	*Tx
	// contains filtered or unexported fields
}

SqlTx implements sql.Transaction with a *Tx.

func NewSqlTx

func NewSqlTx(ctx context.Context, tx *Tx, dsn string) (*SqlTx, error)

NewSqlTx constructs a new SqlTx.

func (*SqlTx) GetReadOnly

func (r *SqlTx) GetReadOnly() bool

GetReadOnly returns if the transaction is read-only.

func (*SqlTx) GetSqlOps

func (r *SqlTx) GetSqlOps(ctx context.Context) (hydra_sql.SqlOps, error)

GetSqlOps returns the sql operations interface.

type Table

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

Table is the block-graph backed data table cursor. NOTE: calls are not concurrency-safe.

func LoadTable

func LoadTable(ctx context.Context, name string, bcs *block.Cursor) (*Table, error)

LoadTable constructs a new table handle, loading the root block.

func (*Table) AddColumn added in v0.52.0

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

AddColumn adds a column and rewrites stored rows to the new schema.

func (*Table) AutoIncrementSetter

func (t *Table) AutoIncrementSetter(sqlCtx *sql.Context) sql.AutoIncrementSetter

AutoIncrementSetter returns an AutoIncrementSetter.

func (*Table) Collation

func (t *Table) Collation() sql.CollationID

Collation returns the collation type ID.

func (*Table) CreateIndex added in v0.52.0

func (t *Table) CreateIndex(ctx *sql.Context, def sql.IndexDef) error

CreateIndex builds a secondary tree from the existing rows.

func (*Table) Deleter added in v0.52.0

func (t *Table) Deleter(sqlCtx *sql.Context) sql.RowDeleter

Deleter returns a row deleter for the table.

func (*Table) DropColumn added in v0.52.0

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

DropColumn drops a column and rewrites stored rows to the new schema.

func (*Table) DropIndex added in v0.52.0

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

DropIndex removes a secondary tree and its definition.

func (*Table) GetIndexes added in v0.52.0

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

GetIndexes returns primary-key and secondary index metadata for planning.

func (*Table) GetNextAutoIncrementValue

func (t *Table) GetNextAutoIncrementValue(sqlCtx *sql.Context, insertVal any) (uint64, error)

GetNextAutoIncrementValue returns the current counter, raised to insertVal when larger.

func (*Table) IndexedAccess added in v0.52.0

func (t *Table) IndexedAccess(ctx *sql.Context, lookup sql.IndexLookup) sql.IndexedTable

IndexedAccess returns a table that resolves equality lookups through stored keys.

func (*Table) Inserter

func (t *Table) Inserter(sqlCtx *sql.Context) sql.RowInserter

Inserter returns a row inserter for the table.

func (*Table) LookupPartitions added in v0.52.0

func (t *Table) LookupPartitions(ctx *sql.Context, lookup sql.IndexLookup) (sql.PartitionIter, error)

LookupPartitions fetches matching rows from the stored index keys.

func (*Table) ModifyColumn added in v0.52.0

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

ModifyColumn replaces an existing column definition and optionally moves it.

func (*Table) Name

func (t *Table) Name() string

Name returns the name.

func (*Table) NewTableEditor

func (t *Table) NewTableEditor(sqlCtx *sql.Context) *TableEditor

NewTableEditor constructs a new table editor.

func (*Table) PartitionAtIndex

func (t *Table) PartitionAtIndex(ix int) (*TablePartition, error)

PartitionAtIndex returns the partition at an index.

Returns io.EOF if out of range.

func (*Table) PartitionCount

func (t *Table) PartitionCount(*sql.Context) (int64, error)

PartitionCount returns the number of partitions.

func (*Table) PartitionRows

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

PartitionRows returns a table iterator for the rows in a partition.

Index partitions already contain the rows fetched by their encoded keys.

func (*Table) Partitions

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

Partitions returns an iterator for the table partitions.

func (*Table) PeekNextAutoIncrementValue

func (t *Table) PeekNextAutoIncrementValue(*sql.Context) (uint64, error)

PeekNextAutoIncrementValue returns the next AUTO_INCREMENT value without reserving it.

func (*Table) PreciseMatch added in v0.52.0

func (t *Table) PreciseMatch() bool

PreciseMatch reports whether IndexedAccess can replace predicate filters.

func (*Table) PrimaryKeySchema

func (t *Table) PrimaryKeySchema(*sql.Context) sql.PrimaryKeySchema

PrimaryKeySchema returns the table schema with its primary key ordinals.

func (*Table) RenameIndex added in v0.52.0

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

RenameIndex renames secondary index metadata.

func (*Table) Replacer

func (t *Table) Replacer(sqlCtx *sql.Context) sql.RowReplacer

Replacer returns a row replacer for the table.

func (*Table) Schema

func (t *Table) Schema(*sql.Context) sql.Schema

Schema returns the table's SQL schema.

func (*Table) String

func (t *Table) String() string

String returns the table in string form.

func (*Table) Updater added in v0.51.7

func (t *Table) Updater(sqlCtx *sql.Context) sql.RowUpdater

Updater returns a row updater for the table.

type TableColumn

type TableColumn struct {

	// Value contains the SQL value. If no field is set, the column is NULL.
	//
	// Types that are assignable to Value:
	//	*TableColumn_BoolValue
	//	*TableColumn_IntValue
	//	*TableColumn_UintValue
	//	*TableColumn_FloatValue
	//	*TableColumn_StringBlob
	//	*TableColumn_BytesBlob
	//	*TableColumn_JsonBlob
	//	*TableColumn_TimestampValue
	//	*TableColumn_TimespanMicros
	//	*TableColumn_DecimalText
	Value isTableColumn_Value `protobuf_oneof:"value"`
	// contains filtered or unexported fields
}

TableColumn is an entry in a table row.

func BuildTableColumn

func BuildTableColumn(
	ctx context.Context,
	bcs *block.Cursor,
	opts *blob.BuildBlobOpts,
	col any,
) (*TableColumn, error)

BuildTableColumn constructs a TableColumn by marshaling a col.

bcs must be set.

func (*TableColumn) ApplySubBlock

func (t *TableColumn) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*TableColumn) BlockAliasIdentity added in v0.52.0

func (t *TableColumn) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for TableColumn.

func (*TableColumn) CloneMessageVT

func (m *TableColumn) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableColumn) CloneVT

func (m *TableColumn) CloneVT() *TableColumn

func (*TableColumn) EqualMessageVT

func (this *TableColumn) EqualMessageVT(thatMsg any) bool

func (*TableColumn) EqualVT

func (this *TableColumn) EqualVT(that *TableColumn) bool

func (*TableColumn) FetchSqlColumn

func (t *TableColumn) FetchSqlColumn(ctx context.Context, bcs *block.Cursor) (any, error)

FetchSqlColumn converts the column into its SQL value. A scalar value or an inline blob decodes from the column itself. A chunked blob reads through bcs, located at the column, and reads as nil without one.

func (*TableColumn) GetBoolValue

func (x *TableColumn) GetBoolValue() bool

func (*TableColumn) GetBytesBlob

func (x *TableColumn) GetBytesBlob() *blob.Blob

func (*TableColumn) GetDecimalText

func (x *TableColumn) GetDecimalText() string

func (*TableColumn) GetFloatValue

func (x *TableColumn) GetFloatValue() float64

func (*TableColumn) GetIntValue

func (x *TableColumn) GetIntValue() int64

func (*TableColumn) GetJsonBlob

func (x *TableColumn) GetJsonBlob() *blob.Blob

func (*TableColumn) GetStringBlob

func (x *TableColumn) GetStringBlob() *blob.Blob

func (*TableColumn) GetSubBlockCtor

func (t *TableColumn) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*TableColumn) GetSubBlocks

func (t *TableColumn) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*TableColumn) GetTimespanMicros

func (x *TableColumn) GetTimespanMicros() int64

func (*TableColumn) GetTimestampValue

func (x *TableColumn) GetTimestampValue() *TableTimestamp

func (*TableColumn) GetUintValue

func (x *TableColumn) GetUintValue() uint64

func (*TableColumn) GetValue

func (m *TableColumn) GetValue() isTableColumn_Value

func (*TableColumn) IsEmpty

func (t *TableColumn) IsEmpty() bool

IsEmpty checks if the table column is empty.

func (*TableColumn) IsNil

func (t *TableColumn) IsNil() bool

IsNil returns if the object is nil.

func (*TableColumn) MarshalJSON

func (x *TableColumn) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableColumn to JSON.

func (*TableColumn) MarshalProtoJSON

func (x *TableColumn) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableColumn message to JSON.

func (*TableColumn) MarshalProtoText

func (x *TableColumn) MarshalProtoText() string

func (*TableColumn) MarshalToSizedBufferVT

func (m *TableColumn) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn) MarshalToVT

func (m *TableColumn) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn) MarshalVT

func (m *TableColumn) MarshalVT() (dAtA []byte, err error)

func (*TableColumn) ProtoMessage

func (*TableColumn) ProtoMessage()

func (*TableColumn) Reset

func (x *TableColumn) Reset()

func (*TableColumn) SizeVT

func (m *TableColumn) SizeVT() (n int)

func (*TableColumn) String

func (x *TableColumn) String() string

func (*TableColumn) UnmarshalJSON

func (x *TableColumn) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableColumn from JSON.

func (*TableColumn) UnmarshalProtoJSON

func (x *TableColumn) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableColumn message from JSON.

func (*TableColumn) UnmarshalVT

func (m *TableColumn) UnmarshalVT(dAtA []byte) error

func (*TableColumn) Validate

func (t *TableColumn) Validate() error

Validate performs cursory validation of the table column.

type TableColumn_BoolValue

type TableColumn_BoolValue struct {
	// BoolValue is a boolean SQL value.
	BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"`
}

func (*TableColumn_BoolValue) CloneOneofVT

func (m *TableColumn_BoolValue) CloneOneofVT() isTableColumn_Value

func (*TableColumn_BoolValue) CloneVT

func (*TableColumn_BoolValue) EqualVT

func (this *TableColumn_BoolValue) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_BoolValue) MarshalToSizedBufferVT

func (m *TableColumn_BoolValue) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_BoolValue) MarshalToVT

func (m *TableColumn_BoolValue) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_BoolValue) SizeVT

func (m *TableColumn_BoolValue) SizeVT() (n int)

type TableColumn_BytesBlob

type TableColumn_BytesBlob struct {
	// BytesBlob is a binary SQL value.
	BytesBlob *blob.Blob `protobuf:"bytes,7,opt,name=bytes_blob,json=bytesBlob,proto3,oneof"`
}

func (*TableColumn_BytesBlob) CloneOneofVT

func (m *TableColumn_BytesBlob) CloneOneofVT() isTableColumn_Value

func (*TableColumn_BytesBlob) CloneVT

func (*TableColumn_BytesBlob) EqualVT

func (this *TableColumn_BytesBlob) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_BytesBlob) MarshalToSizedBufferVT

func (m *TableColumn_BytesBlob) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_BytesBlob) MarshalToVT

func (m *TableColumn_BytesBlob) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_BytesBlob) SizeVT

func (m *TableColumn_BytesBlob) SizeVT() (n int)

type TableColumn_DecimalText

type TableColumn_DecimalText struct {
	// DecimalText is a DECIMAL SQL value as its exact text, with its scale.
	DecimalText string `protobuf:"bytes,11,opt,name=decimal_text,json=decimalText,proto3,oneof"`
}

func (*TableColumn_DecimalText) CloneOneofVT

func (m *TableColumn_DecimalText) CloneOneofVT() isTableColumn_Value

func (*TableColumn_DecimalText) CloneVT

func (*TableColumn_DecimalText) EqualVT

func (this *TableColumn_DecimalText) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_DecimalText) MarshalToSizedBufferVT

func (m *TableColumn_DecimalText) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_DecimalText) MarshalToVT

func (m *TableColumn_DecimalText) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_DecimalText) SizeVT

func (m *TableColumn_DecimalText) SizeVT() (n int)

type TableColumn_FloatValue

type TableColumn_FloatValue struct {
	// FloatValue is a floating-point SQL value.
	FloatValue float64 `protobuf:"fixed64,5,opt,name=float_value,json=floatValue,proto3,oneof"`
}

func (*TableColumn_FloatValue) CloneOneofVT

func (m *TableColumn_FloatValue) CloneOneofVT() isTableColumn_Value

func (*TableColumn_FloatValue) CloneVT

func (*TableColumn_FloatValue) EqualVT

func (this *TableColumn_FloatValue) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_FloatValue) MarshalToSizedBufferVT

func (m *TableColumn_FloatValue) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_FloatValue) MarshalToVT

func (m *TableColumn_FloatValue) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_FloatValue) SizeVT

func (m *TableColumn_FloatValue) SizeVT() (n int)

type TableColumn_IntValue

type TableColumn_IntValue struct {
	// IntValue is a signed integer SQL value.
	IntValue int64 `protobuf:"varint,3,opt,name=int_value,json=intValue,proto3,oneof"`
}

func (*TableColumn_IntValue) CloneOneofVT

func (m *TableColumn_IntValue) CloneOneofVT() isTableColumn_Value

func (*TableColumn_IntValue) CloneVT

func (*TableColumn_IntValue) EqualVT

func (this *TableColumn_IntValue) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_IntValue) MarshalToSizedBufferVT

func (m *TableColumn_IntValue) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_IntValue) MarshalToVT

func (m *TableColumn_IntValue) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_IntValue) SizeVT

func (m *TableColumn_IntValue) SizeVT() (n int)

type TableColumn_JsonBlob

type TableColumn_JsonBlob struct {
	// JsonBlob is a JSON SQL value encoded as UTF-8 text.
	JsonBlob *blob.Blob `protobuf:"bytes,8,opt,name=json_blob,json=jsonBlob,proto3,oneof"`
}

func (*TableColumn_JsonBlob) CloneOneofVT

func (m *TableColumn_JsonBlob) CloneOneofVT() isTableColumn_Value

func (*TableColumn_JsonBlob) CloneVT

func (*TableColumn_JsonBlob) EqualVT

func (this *TableColumn_JsonBlob) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_JsonBlob) MarshalToSizedBufferVT

func (m *TableColumn_JsonBlob) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_JsonBlob) MarshalToVT

func (m *TableColumn_JsonBlob) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_JsonBlob) SizeVT

func (m *TableColumn_JsonBlob) SizeVT() (n int)

type TableColumn_StringBlob

type TableColumn_StringBlob struct {
	// StringBlob is a string SQL value encoded as UTF-8 bytes.
	StringBlob *blob.Blob `protobuf:"bytes,6,opt,name=string_blob,json=stringBlob,proto3,oneof"`
}

func (*TableColumn_StringBlob) CloneOneofVT

func (m *TableColumn_StringBlob) CloneOneofVT() isTableColumn_Value

func (*TableColumn_StringBlob) CloneVT

func (*TableColumn_StringBlob) EqualVT

func (this *TableColumn_StringBlob) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_StringBlob) MarshalToSizedBufferVT

func (m *TableColumn_StringBlob) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_StringBlob) MarshalToVT

func (m *TableColumn_StringBlob) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_StringBlob) SizeVT

func (m *TableColumn_StringBlob) SizeVT() (n int)

type TableColumn_TimespanMicros

type TableColumn_TimespanMicros struct {
	// TimespanMicros is a TIME SQL value in microseconds.
	TimespanMicros int64 `protobuf:"varint,10,opt,name=timespan_micros,json=timespanMicros,proto3,oneof"`
}

func (*TableColumn_TimespanMicros) CloneOneofVT

func (m *TableColumn_TimespanMicros) CloneOneofVT() isTableColumn_Value

func (*TableColumn_TimespanMicros) CloneVT

func (*TableColumn_TimespanMicros) EqualVT

func (this *TableColumn_TimespanMicros) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_TimespanMicros) MarshalToSizedBufferVT

func (m *TableColumn_TimespanMicros) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_TimespanMicros) MarshalToVT

func (m *TableColumn_TimespanMicros) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_TimespanMicros) SizeVT

func (m *TableColumn_TimespanMicros) SizeVT() (n int)

type TableColumn_TimestampValue

type TableColumn_TimestampValue struct {
	// TimestampValue is a timestamp, datetime, or date SQL value.
	TimestampValue *TableTimestamp `protobuf:"bytes,9,opt,name=timestamp_value,json=timestampValue,proto3,oneof"`
}

func (*TableColumn_TimestampValue) CloneOneofVT

func (m *TableColumn_TimestampValue) CloneOneofVT() isTableColumn_Value

func (*TableColumn_TimestampValue) CloneVT

func (*TableColumn_TimestampValue) EqualVT

func (this *TableColumn_TimestampValue) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_TimestampValue) MarshalToSizedBufferVT

func (m *TableColumn_TimestampValue) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_TimestampValue) MarshalToVT

func (m *TableColumn_TimestampValue) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_TimestampValue) SizeVT

func (m *TableColumn_TimestampValue) SizeVT() (n int)

type TableColumn_UintValue

type TableColumn_UintValue struct {
	// UintValue is an unsigned integer SQL value.
	UintValue uint64 `protobuf:"varint,4,opt,name=uint_value,json=uintValue,proto3,oneof"`
}

func (*TableColumn_UintValue) CloneOneofVT

func (m *TableColumn_UintValue) CloneOneofVT() isTableColumn_Value

func (*TableColumn_UintValue) CloneVT

func (*TableColumn_UintValue) EqualVT

func (this *TableColumn_UintValue) EqualVT(thatIface isTableColumn_Value) bool

func (*TableColumn_UintValue) MarshalToSizedBufferVT

func (m *TableColumn_UintValue) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableColumn_UintValue) MarshalToVT

func (m *TableColumn_UintValue) MarshalToVT(dAtA []byte) (int, error)

func (*TableColumn_UintValue) SizeVT

func (m *TableColumn_UintValue) SizeVT() (n int)

type TableEditor

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

TableEditor implements row management operations against a table.

Note: all table operations are (currently) not concurrency safe.

func NewTableEditor

func NewTableEditor(ctx context.Context, t *Table) *TableEditor

NewTableEditor constructs a new table row inserter.

func (*TableEditor) AcquireAutoIncrementLock

func (i *TableEditor) AcquireAutoIncrementLock(ctx *sql.Context) (func(), error)

AcquireAutoIncrementLock relies on the enclosing transaction's exclusive write lock.

func (*TableEditor) Close

func (i *TableEditor) Close(sqlCtx *sql.Context) error

Close releases the editor; writes already belong to the enclosing transaction.

func (*TableEditor) Delete added in v0.52.0

func (i *TableEditor) Delete(sqlCtx *sql.Context, row sql.Row) error

Delete deletes the row given.

func (*TableEditor) DiscardChanges

func (i *TableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error

DiscardChanges is called if a statement encounters an error, and all current changes since the statement beginning should be discarded.

func (*TableEditor) Insert

func (i *TableEditor) Insert(sqlCtx *sql.Context, row sql.Row) error

Insert inserts the row given, returning an error if it cannot. Insert will be called once for each row to process for the insert operation, which may involve many rows. After all rows in an operation have been processed, Close is called.

func (*TableEditor) SetAutoIncrementValue

func (i *TableEditor) SetAutoIncrementValue(sqlCtx *sql.Context, val uint64) error

SetAutoIncrementValue sets a new AUTO_INCREMENT value.

func (*TableEditor) SetBuildBlobOpts

func (i *TableEditor) SetBuildBlobOpts(opts *blob.BuildBlobOpts)

SetBuildBlobOpts sets the build blob options.

func (*TableEditor) StatementBegin

func (i *TableEditor) StatementBegin(ctx *sql.Context)

StatementBegin starts a row-edit journal and snapshots the table counters.

func (*TableEditor) StatementComplete

func (i *TableEditor) StatementComplete(ctx *sql.Context) error

StatementComplete releases the successful statement's rollback journal.

func (*TableEditor) Update added in v0.51.7

func (i *TableEditor) Update(sqlCtx *sql.Context, oldRow, newRow sql.Row) error

Update updates the old row to the new row.

type TableIndex added in v0.52.0

type TableIndex struct {

	// Name is the unique name of the index.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Columns is the ordered set of columns in the index.
	Columns []*TableIndexColumn `protobuf:"bytes,2,rep,name=columns,proto3" json:"columns,omitempty"`
	// Unique indicates that indexed values must be unique.
	Unique bool `protobuf:"varint,3,opt,name=unique,proto3" json:"unique,omitempty"`
	// Comment contains the index comment.
	Comment string `protobuf:"bytes,4,opt,name=comment,proto3" json:"comment,omitempty"`
	// KeyValue maps encoded index columns to encoded primary row keys.
	KeyValue *block1.KeyValueStore `protobuf:"bytes,5,opt,name=key_value,json=keyValue,proto3" json:"keyValue,omitempty"`
	// contains filtered or unexported fields
}

TableIndex is a secondary table index definition.

func (*TableIndex) ApplySubBlock

func (r *TableIndex) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies changes to the index tree.

func (*TableIndex) BlockAliasIdentity

func (r *TableIndex) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the per-instance token for the inline index.

func (*TableIndex) CloneMessageVT added in v0.52.0

func (m *TableIndex) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableIndex) CloneVT added in v0.52.0

func (m *TableIndex) CloneVT() *TableIndex

func (*TableIndex) EqualMessageVT added in v0.52.0

func (this *TableIndex) EqualMessageVT(thatMsg any) bool

func (*TableIndex) EqualVT added in v0.52.0

func (this *TableIndex) EqualVT(that *TableIndex) bool

func (*TableIndex) GetColumns added in v0.52.0

func (x *TableIndex) GetColumns() []*TableIndexColumn

func (*TableIndex) GetComment added in v0.52.0

func (x *TableIndex) GetComment() string

func (*TableIndex) GetKeyValue

func (x *TableIndex) GetKeyValue() *block1.KeyValueStore

func (*TableIndex) GetName added in v0.52.0

func (x *TableIndex) GetName() string

func (*TableIndex) GetSubBlockCtor

func (r *TableIndex) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns the constructor for the index tree.

func (*TableIndex) GetSubBlocks

func (r *TableIndex) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns the index's stored tree.

func (*TableIndex) GetUnique added in v0.52.0

func (x *TableIndex) GetUnique() bool

func (*TableIndex) IsNil

func (r *TableIndex) IsNil() bool

IsNil reports whether the index sub-block is absent.

func (*TableIndex) MarshalJSON added in v0.52.0

func (x *TableIndex) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableIndex to JSON.

func (*TableIndex) MarshalProtoJSON added in v0.52.0

func (x *TableIndex) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableIndex message to JSON.

func (*TableIndex) MarshalProtoText added in v0.52.0

func (x *TableIndex) MarshalProtoText() string

func (*TableIndex) MarshalToSizedBufferVT added in v0.52.0

func (m *TableIndex) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableIndex) MarshalToVT added in v0.52.0

func (m *TableIndex) MarshalToVT(dAtA []byte) (int, error)

func (*TableIndex) MarshalVT added in v0.52.0

func (m *TableIndex) MarshalVT() (dAtA []byte, err error)

func (*TableIndex) ProtoMessage added in v0.52.0

func (*TableIndex) ProtoMessage()

func (*TableIndex) Reset added in v0.52.0

func (x *TableIndex) Reset()

func (*TableIndex) SizeVT added in v0.52.0

func (m *TableIndex) SizeVT() (n int)

func (*TableIndex) String added in v0.52.0

func (x *TableIndex) String() string

func (*TableIndex) UnmarshalJSON added in v0.52.0

func (x *TableIndex) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableIndex from JSON.

func (*TableIndex) UnmarshalProtoJSON added in v0.52.0

func (x *TableIndex) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableIndex message from JSON.

func (*TableIndex) UnmarshalVT added in v0.52.0

func (m *TableIndex) UnmarshalVT(dAtA []byte) error

type TableIndexColumn added in v0.52.0

type TableIndexColumn struct {

	// Name is the indexed column name.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Length is the optional prefix length. Zero means full length.
	Length int64 `protobuf:"varint,2,opt,name=length,proto3" json:"length,omitempty"`
	// contains filtered or unexported fields
}

TableIndexColumn is a column in a TableIndex.

func (*TableIndexColumn) CloneMessageVT added in v0.52.0

func (m *TableIndexColumn) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableIndexColumn) CloneVT added in v0.52.0

func (m *TableIndexColumn) CloneVT() *TableIndexColumn

func (*TableIndexColumn) EqualMessageVT added in v0.52.0

func (this *TableIndexColumn) EqualMessageVT(thatMsg any) bool

func (*TableIndexColumn) EqualVT added in v0.52.0

func (this *TableIndexColumn) EqualVT(that *TableIndexColumn) bool

func (*TableIndexColumn) GetLength added in v0.52.0

func (x *TableIndexColumn) GetLength() int64

func (*TableIndexColumn) GetName added in v0.52.0

func (x *TableIndexColumn) GetName() string

func (*TableIndexColumn) MarshalJSON added in v0.52.0

func (x *TableIndexColumn) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableIndexColumn to JSON.

func (*TableIndexColumn) MarshalProtoJSON added in v0.52.0

func (x *TableIndexColumn) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableIndexColumn message to JSON.

func (*TableIndexColumn) MarshalProtoText added in v0.52.0

func (x *TableIndexColumn) MarshalProtoText() string

func (*TableIndexColumn) MarshalToSizedBufferVT added in v0.52.0

func (m *TableIndexColumn) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableIndexColumn) MarshalToVT added in v0.52.0

func (m *TableIndexColumn) MarshalToVT(dAtA []byte) (int, error)

func (*TableIndexColumn) MarshalVT added in v0.52.0

func (m *TableIndexColumn) MarshalVT() (dAtA []byte, err error)

func (*TableIndexColumn) ProtoMessage added in v0.52.0

func (*TableIndexColumn) ProtoMessage()

func (*TableIndexColumn) Reset added in v0.52.0

func (x *TableIndexColumn) Reset()

func (*TableIndexColumn) SizeVT added in v0.52.0

func (m *TableIndexColumn) SizeVT() (n int)

func (*TableIndexColumn) String added in v0.52.0

func (x *TableIndexColumn) String() string

func (*TableIndexColumn) UnmarshalJSON added in v0.52.0

func (x *TableIndexColumn) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableIndexColumn from JSON.

func (*TableIndexColumn) UnmarshalProtoJSON added in v0.52.0

func (x *TableIndexColumn) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableIndexColumn message from JSON.

func (*TableIndexColumn) UnmarshalVT added in v0.52.0

func (m *TableIndexColumn) UnmarshalVT(dAtA []byte) error

type TablePartition

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

TablePartition is a table partition handle.

func NewTablePartition

func NewTablePartition(
	idx int,
	t *TablePartitionRoot, bcs *block.Cursor,
	schema sql.Schema,
) (*TablePartition, error)

NewTablePartition constructs a table partition handle.

bcs should be located at the TablePartitionRoot sub-block.

func (*TablePartition) BuildTreeTx

func (p *TablePartition) BuildTreeTx(ctx context.Context, detach, write bool) (kvtx.BlockTx, error)

BuildTreeTx builds the avl tree transaction.

func (*TablePartition) IterateRows

func (p *TablePartition) IterateRows(ctx *sql.Context) (sql.RowIter, error)

IterateRows returns a row iterator.

func (*TablePartition) Key

func (p *TablePartition) Key() []byte

Key returns the partition key.

type TablePartitionIter

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

TablePartitionIter is a table partition iterator.

func NewTablePartitionIter

func NewTablePartitionIter(t *Table) *TablePartitionIter

NewTablePartitionIter constructs a new PartitionIter.

func (*TablePartitionIter) Close

func (i *TablePartitionIter) Close(sctx *sql.Context) error

Close closes the iterator.

func (*TablePartitionIter) Next

func (i *TablePartitionIter) Next(sctx *sql.Context) (sql.Partition, error)

Next iterates to the next partition.

type TablePartitionRoot

type TablePartitionRoot struct {

	// RowKeyValue is the key/value tree of objects.
	// Key: encoded primary key, or encoded row and nonce for keyless tables.
	// Value: cid.BlockRef -> Object
	RowKeyValue *block1.KeyValueStore `protobuf:"bytes,1,opt,name=row_key_value,json=rowKeyValue,proto3" json:"rowKeyValue,omitempty"`
	// contains filtered or unexported fields
}

TablePartitionRoot contains the root of a table partition.

func NewTablePartitionRoot

func NewTablePartitionRoot() *TablePartitionRoot

NewTablePartitionRoot constructs a new table partition root object.

func (*TablePartitionRoot) ApplySubBlock

func (r *TablePartitionRoot) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*TablePartitionRoot) BlockAliasIdentity added in v0.52.0

func (r *TablePartitionRoot) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for TablePartitionRoot.

func (*TablePartitionRoot) CloneMessageVT

func (m *TablePartitionRoot) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TablePartitionRoot) CloneVT

func (m *TablePartitionRoot) CloneVT() *TablePartitionRoot

func (*TablePartitionRoot) EqualMessageVT

func (this *TablePartitionRoot) EqualMessageVT(thatMsg any) bool

func (*TablePartitionRoot) EqualVT

func (this *TablePartitionRoot) EqualVT(that *TablePartitionRoot) bool

func (*TablePartitionRoot) GetRowKeyValue

func (x *TablePartitionRoot) GetRowKeyValue() *block1.KeyValueStore

func (*TablePartitionRoot) GetSubBlockCtor

func (r *TablePartitionRoot) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*TablePartitionRoot) GetSubBlocks

func (r *TablePartitionRoot) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*TablePartitionRoot) IsNil

func (r *TablePartitionRoot) IsNil() bool

IsNil returns if the object is nil.

func (*TablePartitionRoot) MarshalJSON

func (x *TablePartitionRoot) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TablePartitionRoot to JSON.

func (*TablePartitionRoot) MarshalProtoJSON

func (x *TablePartitionRoot) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TablePartitionRoot message to JSON.

func (*TablePartitionRoot) MarshalProtoText

func (x *TablePartitionRoot) MarshalProtoText() string

func (*TablePartitionRoot) MarshalToSizedBufferVT

func (m *TablePartitionRoot) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TablePartitionRoot) MarshalToVT

func (m *TablePartitionRoot) MarshalToVT(dAtA []byte) (int, error)

func (*TablePartitionRoot) MarshalVT

func (m *TablePartitionRoot) MarshalVT() (dAtA []byte, err error)

func (*TablePartitionRoot) ProtoMessage

func (*TablePartitionRoot) ProtoMessage()

func (*TablePartitionRoot) Reset

func (x *TablePartitionRoot) Reset()

func (*TablePartitionRoot) SizeVT

func (m *TablePartitionRoot) SizeVT() (n int)

func (*TablePartitionRoot) String

func (x *TablePartitionRoot) String() string

func (*TablePartitionRoot) UnmarshalJSON

func (x *TablePartitionRoot) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TablePartitionRoot from JSON.

func (*TablePartitionRoot) UnmarshalProtoJSON

func (x *TablePartitionRoot) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TablePartitionRoot message from JSON.

func (*TablePartitionRoot) UnmarshalVT

func (m *TablePartitionRoot) UnmarshalVT(dAtA []byte) error

func (*TablePartitionRoot) Validate

func (r *TablePartitionRoot) Validate() error

Validate performs cursory validation of the table partition root.

type TablePartitionRowIter

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

TablePartitionRowIter is a table partition iterator.

func NewTablePartitionRowIter

func NewTablePartitionRowIter(
	ctx context.Context,
	tree kvtx.BlockTx,
	schema sql.Schema,
) (*TablePartitionRowIter, error)

NewTablePartitionRowIter constructs a table partition row iterator.

func (*TablePartitionRowIter) Close

func (i *TablePartitionRowIter) Close(sctx *sql.Context) error

Close releases the partition iterator and its read transaction.

func (*TablePartitionRowIter) GetRow

func (i *TablePartitionRowIter) GetRow(sctx *sql.Context) (sql.Row, error)

GetRow returns the row at the iterator position, checked against the table schema in the SQL context of the query.

func (*TablePartitionRowIter) Next

func (i *TablePartitionRowIter) Next(sctx *sql.Context) (sql.Row, error)

Next retrieves the next row, or io.EOF after the partition is exhausted.

func (*TablePartitionRowIter) Next2

func (i *TablePartitionRowIter) Next2(ctx *sql.Context, frame *sql.RowFrame) error

Next2 appends the next row to frame, or returns io.EOF when exhausted.

type TableRoot

type TableRoot struct {

	// TableSchema is the table schema.
	TableSchema *TableSchema `protobuf:"bytes,1,opt,name=table_schema,json=tableSchema,proto3" json:"tableSchema,omitempty"`
	// PrimaryKeyOrdinals is the PkOrdinals field of PrimaryKeySchema.
	PrimaryKeyOrdinals []int32 `protobuf:"varint,5,rep,packed,name=primary_key_ordinals,json=primaryKeyOrdinals,proto3" json:"primaryKeyOrdinals,omitempty"`
	// TablePartitions contains the set of table partitions.
	TablePartitions []*TablePartitionRoot `protobuf:"bytes,2,rep,name=table_partitions,json=tablePartitions,proto3" json:"tablePartitions,omitempty"`
	// RowNonce distinguishes duplicate rows in tables without a primary key.
	RowNonce uint64 `protobuf:"varint,3,opt,name=row_nonce,json=rowNonce,proto3" json:"rowNonce,omitempty"`
	// AutoIncrVal is the auto increment value, if necessary.
	// Typically contains an integer or float.
	// Empty if auto_incr_index is zero.
	AutoIncrVal *TableColumn `protobuf:"bytes,4,opt,name=auto_incr_val,json=autoIncrVal,proto3" json:"autoIncrVal,omitempty"`
	// CollationId is the method ID of the method used to control sorting.
	CollationId uint32 `protobuf:"varint,6,opt,name=collation_id,json=collationId,proto3" json:"collationId,omitempty"`
	// Comment is an additional comment on the table.
	Comment string `protobuf:"bytes,7,opt,name=comment,proto3" json:"comment,omitempty"`
	// Indexes contains secondary index definitions and their stored trees.
	Indexes []*TableIndex `protobuf:"bytes,8,rep,name=indexes,proto3" json:"indexes,omitempty"`
	// KeyFormat is the version of the row and index key encoding.
	// Tables are readable only when it equals the current format.
	KeyFormat uint32 `protobuf:"varint,9,opt,name=key_format,json=keyFormat,proto3" json:"keyFormat,omitempty"`
	// contains filtered or unexported fields
}

TableRoot is the root object of the table.

func LoadTableRoot

func LoadTableRoot(ctx context.Context, cursor *block.Cursor) (*TableRoot, error)

LoadTableRoot follows the database root cursor and may return nil.

func (*TableRoot) ApplySubBlock

func (r *TableRoot) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*TableRoot) CloneMessageVT

func (m *TableRoot) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableRoot) CloneVT

func (m *TableRoot) CloneVT() *TableRoot

func (*TableRoot) EqualMessageVT

func (this *TableRoot) EqualMessageVT(thatMsg any) bool

func (*TableRoot) EqualVT

func (this *TableRoot) EqualVT(that *TableRoot) bool

func (*TableRoot) FetchAutoIncrVal

func (r *TableRoot) FetchAutoIncrVal(
	ctx context.Context,
	bcs *block.Cursor,
	expectedType sql.Type,
) (any, sql.ConvertInRange, error)

FetchAutoIncrVal fetches and checks the auto-increment value.

bcs should be located at the table root.

func (*TableRoot) GetAutoIncrVal

func (x *TableRoot) GetAutoIncrVal() *TableColumn

func (*TableRoot) GetCollationId

func (x *TableRoot) GetCollationId() uint32

func (*TableRoot) GetComment

func (x *TableRoot) GetComment() string

func (*TableRoot) GetIndexes added in v0.52.0

func (x *TableRoot) GetIndexes() []*TableIndex

func (*TableRoot) GetKeyFormat

func (x *TableRoot) GetKeyFormat() uint32

func (*TableRoot) GetPrimaryKeyOrdinals

func (x *TableRoot) GetPrimaryKeyOrdinals() []int32

func (*TableRoot) GetRowNonce

func (x *TableRoot) GetRowNonce() uint64

func (*TableRoot) GetSubBlockCtor

func (r *TableRoot) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*TableRoot) GetSubBlocks

func (r *TableRoot) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*TableRoot) GetTablePartitions

func (x *TableRoot) GetTablePartitions() []*TablePartitionRoot

func (*TableRoot) GetTableSchema

func (x *TableRoot) GetTableSchema() *TableSchema

func (*TableRoot) MarshalJSON

func (x *TableRoot) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableRoot to JSON.

func (*TableRoot) MarshalProtoJSON

func (x *TableRoot) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableRoot message to JSON.

func (*TableRoot) MarshalProtoText

func (x *TableRoot) MarshalProtoText() string

func (*TableRoot) MarshalToSizedBufferVT

func (m *TableRoot) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableRoot) MarshalToVT

func (m *TableRoot) MarshalToVT(dAtA []byte) (int, error)

func (*TableRoot) MarshalVT

func (m *TableRoot) MarshalVT() (dAtA []byte, err error)

func (*TableRoot) ProtoMessage

func (*TableRoot) ProtoMessage()

func (*TableRoot) Reset

func (x *TableRoot) Reset()

func (*TableRoot) SizeVT

func (m *TableRoot) SizeVT() (n int)

func (*TableRoot) StoreAutoIncrVal

func (r *TableRoot) StoreAutoIncrVal(
	ctx context.Context,
	bcs *block.Cursor,
	buildBlobOpts *blob.BuildBlobOpts,
	val any,
) error

StoreAutoIncrVal stores the auto-increment value.

bcs should be located at the table root.

func (*TableRoot) String

func (x *TableRoot) String() string

func (*TableRoot) UnmarshalJSON

func (x *TableRoot) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableRoot from JSON.

func (*TableRoot) UnmarshalProtoJSON

func (x *TableRoot) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableRoot message from JSON.

func (*TableRoot) UnmarshalVT

func (m *TableRoot) UnmarshalVT(dAtA []byte) error

func (*TableRoot) Validate

func (r *TableRoot) Validate() error

Validate checks the table schema, partitions, indexes and auto-increment value.

type TableRow

type TableRow struct {

	// Columns contains the set of columns.
	Columns []*TableColumn `protobuf:"bytes,1,rep,name=columns,proto3" json:"columns,omitempty"`
	// contains filtered or unexported fields
}

TableRow is a row in a table.

func BuildTableRow

func BuildTableRow(
	ctx context.Context,
	bcs *block.Cursor,
	row sql.Row,
	buildBlobOpts *blob.BuildBlobOpts,
) (*TableRow, error)

BuildTableRow constructs a TableRow by marshaling cols with msgpack blobs.

Stores sub-blocks and references using the cursor. Sets the block at the cursor. If columns are large enough, they will be sharded into separate blocks. Supports streaming decoding at a later time. buildBlobOpts is optional bcs is required autoIncIdx and autoIncVal are optional.

func UnmarshalTableRow

func UnmarshalTableRow(ctx context.Context, bcs *block.Cursor) (*TableRow, error)

UnmarshalTableRow unmarshals the TableRow block, returning nil for an empty cursor.

func (*TableRow) ApplySubBlock

func (r *TableRow) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id. The column set edits the row in place, so there is nothing to apply.

func (*TableRow) CloneMessageVT

func (m *TableRow) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableRow) CloneVT

func (m *TableRow) CloneVT() *TableRow

func (*TableRow) EqualMessageVT

func (this *TableRow) EqualMessageVT(thatMsg any) bool

func (*TableRow) EqualVT

func (this *TableRow) EqualVT(that *TableRow) bool

func (*TableRow) FetchSqlRow

func (r *TableRow) FetchSqlRow(ctx context.Context, bcs *block.Cursor) (sql.Row, error)

FetchSqlRow converts the encoded columns into a sql.Row of Go values, which the caller checks against its schema.

func (*TableRow) GetColumns

func (x *TableRow) GetColumns() []*TableColumn

func (*TableRow) GetSubBlockCtor

func (r *TableRow) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*TableRow) GetSubBlocks

func (r *TableRow) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*TableRow) MarshalJSON

func (x *TableRow) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableRow to JSON.

func (*TableRow) MarshalProtoJSON

func (x *TableRow) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableRow message to JSON.

func (*TableRow) MarshalProtoText

func (x *TableRow) MarshalProtoText() string

func (*TableRow) MarshalToSizedBufferVT

func (m *TableRow) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableRow) MarshalToVT

func (m *TableRow) MarshalToVT(dAtA []byte) (int, error)

func (*TableRow) MarshalVT

func (m *TableRow) MarshalVT() (dAtA []byte, err error)

func (*TableRow) ProtoMessage

func (*TableRow) ProtoMessage()

func (*TableRow) Reset

func (x *TableRow) Reset()

func (*TableRow) SizeVT

func (m *TableRow) SizeVT() (n int)

func (*TableRow) String

func (x *TableRow) String() string

func (*TableRow) UnmarshalJSON

func (x *TableRow) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableRow from JSON.

func (*TableRow) UnmarshalProtoJSON

func (x *TableRow) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableRow message from JSON.

func (*TableRow) UnmarshalVT

func (m *TableRow) UnmarshalVT(dAtA []byte) error

type TableSchema

type TableSchema struct {

	// Columns is the list of columns in the table, sorted by name.
	Columns []*TableSchemaColumn `protobuf:"bytes,1,rep,name=columns,proto3" json:"columns,omitempty"`
	// contains filtered or unexported fields
}

TableSchema is the schema for a table.

func NewTableSchema

func NewTableSchema(schema sql.Schema) *TableSchema

NewTableSchema constructs a table schema from sql schema.

func (*TableSchema) CloneMessageVT

func (m *TableSchema) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableSchema) CloneVT

func (m *TableSchema) CloneVT() *TableSchema

func (*TableSchema) EqualMessageVT

func (this *TableSchema) EqualMessageVT(thatMsg any) bool

func (*TableSchema) EqualVT

func (this *TableSchema) EqualVT(that *TableSchema) bool

func (*TableSchema) GetColumns

func (x *TableSchema) GetColumns() []*TableSchemaColumn

func (*TableSchema) MarshalJSON

func (x *TableSchema) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableSchema to JSON.

func (*TableSchema) MarshalProtoJSON

func (x *TableSchema) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableSchema message to JSON.

func (*TableSchema) MarshalProtoText

func (x *TableSchema) MarshalProtoText() string

func (*TableSchema) MarshalToSizedBufferVT

func (m *TableSchema) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableSchema) MarshalToVT

func (m *TableSchema) MarshalToVT(dAtA []byte) (int, error)

func (*TableSchema) MarshalVT

func (m *TableSchema) MarshalVT() (dAtA []byte, err error)

func (*TableSchema) ProtoMessage

func (*TableSchema) ProtoMessage()

func (*TableSchema) Reset

func (x *TableSchema) Reset()

func (*TableSchema) SizeVT

func (m *TableSchema) SizeVT() (n int)

func (*TableSchema) String

func (x *TableSchema) String() string

func (*TableSchema) ToSqlSchema

func (s *TableSchema) ToSqlSchema() (sql.Schema, error)

ToSqlSchema converts to a table sql schema.

func (*TableSchema) UnmarshalJSON

func (x *TableSchema) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableSchema from JSON.

func (*TableSchema) UnmarshalProtoJSON

func (x *TableSchema) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableSchema message from JSON.

func (*TableSchema) UnmarshalVT

func (m *TableSchema) UnmarshalVT(dAtA []byte) error

func (*TableSchema) Validate

func (s *TableSchema) Validate() error

Validate performs cursory validation of the table schema.

type TableSchemaColumn

type TableSchemaColumn struct {

	// Name is the name of the column.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// ColumnType is the data type of the column.
	ColumnType string `protobuf:"bytes,2,opt,name=column_type,json=columnType,proto3" json:"columnType,omitempty"`
	// DefaultValueExpr is the default value expression, encoded to a string.
	DefaultValueExpr string `protobuf:"bytes,3,opt,name=default_value_expr,json=defaultValueExpr,proto3" json:"defaultValueExpr,omitempty"`
	// AutoIncrement is true if the column auto-increments.
	AutoIncrement bool `protobuf:"varint,4,opt,name=auto_increment,json=autoIncrement,proto3" json:"autoIncrement,omitempty"`
	// Nullable is true if the column can contain NULL values, or false otherwise.
	Nullable bool `protobuf:"varint,5,opt,name=nullable,proto3" json:"nullable,omitempty"`
	// Source is the name of the table this column came from.
	Source string `protobuf:"bytes,6,opt,name=source,proto3" json:"source,omitempty"`
	// PrimaryKey is true if the column is part of the primary key for its table.
	PrimaryKey bool `protobuf:"varint,7,opt,name=primary_key,json=primaryKey,proto3" json:"primaryKey,omitempty"`
	// Comment contains the string comment for this column.
	Comment string `protobuf:"bytes,8,opt,name=comment,proto3" json:"comment,omitempty"`
	// Extra contains any additional information to put in the `extra` column under `information_schema.columns`.
	Extra string `protobuf:"bytes,9,opt,name=extra,proto3" json:"extra,omitempty"`
	// GeneratedExpr is the generated column expression, encoded to a string.
	// Empty unless the column is generated; a generated column has no default.
	GeneratedExpr string `protobuf:"bytes,10,opt,name=generated_expr,json=generatedExpr,proto3" json:"generatedExpr,omitempty"`
	// OnUpdateExpr is the ON UPDATE expression, stored unparenthesized.
	OnUpdateExpr string `protobuf:"bytes,11,opt,name=on_update_expr,json=onUpdateExpr,proto3" json:"onUpdateExpr,omitempty"`
	// Virtual is true if the generated column is computed on read.
	Virtual bool `protobuf:"varint,12,opt,name=virtual,proto3" json:"virtual,omitempty"`
	// contains filtered or unexported fields
}

TableSchemaColumn is the definition of a column for a table schema.

func NewTableSchemaColumn

func NewTableSchemaColumn(col *sql.Column) *TableSchemaColumn

NewTableSchemaColumn constructs a table column from sql schema.

func (*TableSchemaColumn) CloneMessageVT

func (m *TableSchemaColumn) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableSchemaColumn) CloneVT

func (m *TableSchemaColumn) CloneVT() *TableSchemaColumn

func (*TableSchemaColumn) EqualMessageVT

func (this *TableSchemaColumn) EqualMessageVT(thatMsg any) bool

func (*TableSchemaColumn) EqualVT

func (this *TableSchemaColumn) EqualVT(that *TableSchemaColumn) bool

func (*TableSchemaColumn) GetAutoIncrement

func (x *TableSchemaColumn) GetAutoIncrement() bool

func (*TableSchemaColumn) GetColumnType

func (x *TableSchemaColumn) GetColumnType() string

func (*TableSchemaColumn) GetComment

func (x *TableSchemaColumn) GetComment() string

func (*TableSchemaColumn) GetDefaultValueExpr

func (x *TableSchemaColumn) GetDefaultValueExpr() string

func (*TableSchemaColumn) GetExtra

func (x *TableSchemaColumn) GetExtra() string

func (*TableSchemaColumn) GetGeneratedExpr

func (x *TableSchemaColumn) GetGeneratedExpr() string

func (*TableSchemaColumn) GetName

func (x *TableSchemaColumn) GetName() string

func (*TableSchemaColumn) GetNullable

func (x *TableSchemaColumn) GetNullable() bool

func (*TableSchemaColumn) GetOnUpdateExpr

func (x *TableSchemaColumn) GetOnUpdateExpr() string

func (*TableSchemaColumn) GetPrimaryKey

func (x *TableSchemaColumn) GetPrimaryKey() bool

func (*TableSchemaColumn) GetSource

func (x *TableSchemaColumn) GetSource() string

func (*TableSchemaColumn) GetVirtual

func (x *TableSchemaColumn) GetVirtual() bool

func (*TableSchemaColumn) MarshalJSON

func (x *TableSchemaColumn) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableSchemaColumn to JSON.

func (*TableSchemaColumn) MarshalProtoJSON

func (x *TableSchemaColumn) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableSchemaColumn message to JSON.

func (*TableSchemaColumn) MarshalProtoText

func (x *TableSchemaColumn) MarshalProtoText() string

func (*TableSchemaColumn) MarshalToSizedBufferVT

func (m *TableSchemaColumn) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableSchemaColumn) MarshalToVT

func (m *TableSchemaColumn) MarshalToVT(dAtA []byte) (int, error)

func (*TableSchemaColumn) MarshalVT

func (m *TableSchemaColumn) MarshalVT() (dAtA []byte, err error)

func (*TableSchemaColumn) ParseColumnType

func (t *TableSchemaColumn) ParseColumnType() (sql.Type, error)

ParseColumnType parses the column type to sql type.

func (*TableSchemaColumn) ProtoMessage

func (*TableSchemaColumn) ProtoMessage()

func (*TableSchemaColumn) Reset

func (x *TableSchemaColumn) Reset()

func (*TableSchemaColumn) SizeVT

func (m *TableSchemaColumn) SizeVT() (n int)

func (*TableSchemaColumn) String

func (x *TableSchemaColumn) String() string

func (*TableSchemaColumn) ToSqlColumn

func (t *TableSchemaColumn) ToSqlColumn() (*sql.Column, error)

ToSqlColumn converts the proto into a sql column.

Stored expressions return as unresolved text, as Dolt loads its schemas, so each statement's planner binds them to the column type. A parsed expression has no output type and leaves every plan over the table unresolved.

func (*TableSchemaColumn) UnmarshalJSON

func (x *TableSchemaColumn) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableSchemaColumn from JSON.

func (*TableSchemaColumn) UnmarshalProtoJSON

func (x *TableSchemaColumn) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableSchemaColumn message from JSON.

func (*TableSchemaColumn) UnmarshalVT

func (m *TableSchemaColumn) UnmarshalVT(dAtA []byte) error

func (*TableSchemaColumn) Validate

func (t *TableSchemaColumn) Validate() error

Validate performs cursory validation of the table column.

Each stored expression must parse, though the planner binds it to the column type only when a statement uses the table.

type TableTimestamp

type TableTimestamp struct {

	// UnixSeconds is seconds since Unix epoch.
	UnixSeconds int64 `protobuf:"varint,1,opt,name=unix_seconds,json=unixSeconds,proto3" json:"unixSeconds,omitempty"`
	// Nanos is the nanosecond offset within UnixSeconds.
	Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
	// contains filtered or unexported fields
}

TableTimestamp is a timestamp-like SQL value.

func (*TableTimestamp) CloneMessageVT

func (m *TableTimestamp) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*TableTimestamp) CloneVT

func (m *TableTimestamp) CloneVT() *TableTimestamp

func (*TableTimestamp) EqualMessageVT

func (this *TableTimestamp) EqualMessageVT(thatMsg any) bool

func (*TableTimestamp) EqualVT

func (this *TableTimestamp) EqualVT(that *TableTimestamp) bool

func (*TableTimestamp) GetNanos

func (x *TableTimestamp) GetNanos() int32

func (*TableTimestamp) GetUnixSeconds

func (x *TableTimestamp) GetUnixSeconds() int64

func (*TableTimestamp) MarshalJSON

func (x *TableTimestamp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the TableTimestamp to JSON.

func (*TableTimestamp) MarshalProtoJSON

func (x *TableTimestamp) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the TableTimestamp message to JSON.

func (*TableTimestamp) MarshalProtoText

func (x *TableTimestamp) MarshalProtoText() string

func (*TableTimestamp) MarshalToSizedBufferVT

func (m *TableTimestamp) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*TableTimestamp) MarshalToVT

func (m *TableTimestamp) MarshalToVT(dAtA []byte) (int, error)

func (*TableTimestamp) MarshalVT

func (m *TableTimestamp) MarshalVT() (dAtA []byte, err error)

func (*TableTimestamp) ProtoMessage

func (*TableTimestamp) ProtoMessage()

func (*TableTimestamp) Reset

func (x *TableTimestamp) Reset()

func (*TableTimestamp) SizeVT

func (m *TableTimestamp) SizeVT() (n int)

func (*TableTimestamp) String

func (x *TableTimestamp) String() string

func (*TableTimestamp) UnmarshalJSON

func (x *TableTimestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the TableTimestamp from JSON.

func (*TableTimestamp) UnmarshalProtoJSON

func (x *TableTimestamp) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the TableTimestamp message from JSON.

func (*TableTimestamp) UnmarshalVT

func (m *TableTimestamp) UnmarshalVT(dAtA []byte) error

type Tx

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

Tx contains a transaction against the mysql data store.

func (*Tx) BuildDatabaseProvider

func (t *Tx) BuildDatabaseProvider(ctx context.Context) (sql.DatabaseProvider, error)

BuildDatabaseProvider builds the database catalog from the available dbs.

func (*Tx) Commit

func (t *Tx) Commit(ctx context.Context) (cerr error)

Commit commits the transaction to storage. Can return an error to indicate tx failure.

func (*Tx) DatabaseCount

func (t *Tx) DatabaseCount() int

DatabaseCount returns the number of databases in the tree.

func (*Tx) Discard

func (t *Tx) Discard()

Discard cancels the transaction. If called after Commit, does nothing. Cannot return an error. Can be called unlimited times.

func (*Tx) GetBlockTransaction

func (t *Tx) GetBlockTransaction() *block.Transaction

GetBlockTransaction returns the underlying block transaction.

func (*Tx) OpenDatabase

func (t *Tx) OpenDatabase(ctx context.Context, name string, create bool) (*Database, error)

OpenDatabase opens a database with the given name.

If not exist, create is set, and tx is a write tx, it will be created.

Directories

Path Synopsis
Package mysql_devserver serves an in-memory Spacewave SQL database over the MySQL wire protocol, so a build-time tool that types queries by preparing them, such as Reylo, asks the same engine a Space's sql/db objects run on.
Package mysql_devserver serves an in-memory Spacewave SQL database over the MySQL wire protocol, so a build-time tool that types queries by preparing them, such as Reylo, asks the same engine a Space's sql/db objects run on.
Package gormadapter bridges a Mysql transaction to a gorm instance.
Package gormadapter bridges a Mysql transaction to a gorm instance.

Jump to

Keyboard shortcuts

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