database

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package database provides database primitives such as tables, transactions and indexes.

Index

Constants

View Source
const (
	CatalogTableName  = InternalPrefix + "catalog"
	SequenceTableName = InternalPrefix + "sequence"
)

System tables

View Source
const (
	RelationTableType    = "table"
	RelationIndexType    = "index"
	RelationSequenceType = "sequence"
)

Relation types

View Source
const (
	CatalogTableNamespace    tree.Namespace = 1
	SequenceTableNamespace   tree.Namespace = 2
	RollbackSegmentNamespace tree.Namespace = 3
	MinTransientNamespace    tree.Namespace = math.MaxInt64 - 1<<24
	MaxTransientNamespace    tree.Namespace = math.MaxInt64
)

System namespaces

View Source
const (
	// OnConflictDoNothing ignores the duplicate error and returns nothing.
	OnConflictDoNothing = iota + 1

	// OnConflictDoReplace replaces the conflicting row with a new one.
	OnConflictDoReplace
)
View Source
const (
	InternalPrefix = "__chai_"
)
View Source
const (
	StoreSequence = InternalPrefix + "store_seq"
)

System sequences

Variables

View Source
var (
	// ErrIndexDuplicateValue is returned when a value is already associated with a key
	ErrIndexDuplicateValue = errors.New("duplicate value")
)

Functions

func CastConversion

func CastConversion(v types.Value, path object.Path, targetType types.ValueType) (types.Value, error)

CastConversion is a ConversionFunc that casts the value to the target type.

func IsConstraintViolationError

func IsConstraintViolationError(err error) bool

Types

type AnonymousType

type AnonymousType struct {
	FieldConstraints FieldConstraints
}

func (*AnonymousType) AddFieldConstraint

func (an *AnonymousType) AddFieldConstraint(newFc *FieldConstraint) error

func (*AnonymousType) String

func (an *AnonymousType) String() string

type BasicRow

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

func NewBasicRow

func NewBasicRow(obj types.Object) *BasicRow

func (*BasicRow) Get

func (r *BasicRow) Get(name string) (types.Value, error)

func (*BasicRow) Iterate

func (r *BasicRow) Iterate(fn func(name string, value types.Value) error) error

func (*BasicRow) Key

func (r *BasicRow) Key() *tree.Key

func (*BasicRow) MarshalJSON

func (r *BasicRow) MarshalJSON() ([]byte, error)

func (*BasicRow) Object

func (r *BasicRow) Object() types.Object

func (*BasicRow) ResetWith

func (r *BasicRow) ResetWith(tableName string, key *tree.Key, obj types.Object)

func (*BasicRow) TableName

func (r *BasicRow) TableName() string

type Catalog

type Catalog struct {
	Cache        *catalogCache
	CatalogTable *CatalogStore

	TransientNamespaces *atomic.Counter
}

Catalog manages all database objects such as tables, indexes and sequences. It stores all these objects in memory for fast access. Any modification is persisted into the __chai_catalog table.

func NewCatalog

func NewCatalog() *Catalog

func (*Catalog) Clone

func (c *Catalog) Clone() *Catalog

func (*Catalog) GetFreeTransientNamespace

func (c *Catalog) GetFreeTransientNamespace() tree.Namespace

GetFreeTransientNamespace returns the next available transient namespace. Transient namespaces start from math.MaxInt64 - (2 << 24) to math.MaxInt64 (around 16 M). The transient namespaces counter is not persisted and resets when the database is restarted. Once the counter reaches its maximum value, it will wrap around to the minimum value. Technically, if a transient namespace is still in use by the time the counter wraps around its data may be overwritten. However, transient trees are supposed to verify that the namespace is not in use before writing to it.

func (*Catalog) GetIndex

func (c *Catalog) GetIndex(tx *Transaction, indexName string) (*Index, error)

GetIndex returns an index by name.

func (*Catalog) GetIndexInfo

func (c *Catalog) GetIndexInfo(indexName string) (*IndexInfo, error)

GetIndexInfo returns an index info by name.

func (*Catalog) GetSequence

func (c *Catalog) GetSequence(name string) (*Sequence, error)

func (*Catalog) GetTable

func (c *Catalog) GetTable(tx *Transaction, tableName string) (*Table, error)

func (*Catalog) GetTableInfo

func (c *Catalog) GetTableInfo(tableName string) (*TableInfo, error)

GetTableInfo returns the table info for the given table name.

func (*Catalog) ListIndexes

func (c *Catalog) ListIndexes(tableName string) []string

ListIndexes returns all indexes for a given table name. If tableName is empty if returns a list of all indexes. The returned list of indexes is sorted lexicographically.

func (*Catalog) ListSequences

func (c *Catalog) ListSequences() []string

ListSequences returns all sequence names sorted lexicographically.

type CatalogLoader

type CatalogLoader interface {
	LoadCatalog(kv.Session) (*Catalog, error)
}

CatalogLoader loads the catalog from the disk. It may parse a SQL representation of the catalog and return a Catalog that represents all entities stored on disk.

type CatalogStore

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

func (*CatalogStore) Delete

func (s *CatalogStore) Delete(tx *Transaction, name string) error

func (*CatalogStore) Info

func (s *CatalogStore) Info() *TableInfo

func (*CatalogStore) Insert

func (s *CatalogStore) Insert(tx *Transaction, r Relation) error

Insert a catalog object to the table.

func (*CatalogStore) Replace

func (s *CatalogStore) Replace(tx *Transaction, name string, r Relation) error

Replace a catalog object with another.

func (*CatalogStore) Table

func (s *CatalogStore) Table(tx *Transaction) *Table

type CatalogWriter

type CatalogWriter struct {
	*Catalog
}

A CatalogWriter is used to apply modifications to the catalog in a thread-safe manner. All the updates are only visible to the current transaction and don't require any lock. Upon commit, the transaction will apply the changes to the catalog.

func NewCatalogWriter

func NewCatalogWriter(c *Catalog) *CatalogWriter

func (*CatalogWriter) AddFieldConstraint

func (c *CatalogWriter) AddFieldConstraint(tx *Transaction, tableName string, fc *FieldConstraint, tcs TableConstraints) error

AddFieldConstraint adds a field constraint to a table.

func (*CatalogWriter) CreateIndex

func (c *CatalogWriter) CreateIndex(tx *Transaction, info *IndexInfo) (*IndexInfo, error)

CreateIndex creates an index with the given name. If it already exists, returns errs.ErrIndexAlreadyExists.

func (*CatalogWriter) CreateSequence

func (c *CatalogWriter) CreateSequence(tx *Transaction, info *SequenceInfo) error

CreateSequence creates a sequence with the given name.

func (*CatalogWriter) CreateTable

func (c *CatalogWriter) CreateTable(tx *Transaction, tableName string, info *TableInfo) error

CreateTable creates a table with the given name. If it already exists, returns ErrTableAlreadyExists.

func (*CatalogWriter) DropIndex

func (c *CatalogWriter) DropIndex(tx *Transaction, name string) error

DropIndex deletes an index from the

func (*CatalogWriter) DropSequence

func (c *CatalogWriter) DropSequence(tx *Transaction, name string) error

DropSequence deletes a sequence from the catalog.

func (*CatalogWriter) DropTable

func (c *CatalogWriter) DropTable(tx *Transaction, tableName string) error

DropTable deletes a table from the catalog

func (*CatalogWriter) Init

func (c *CatalogWriter) Init(tx *Transaction) error

func (*CatalogWriter) RenameTable

func (c *CatalogWriter) RenameTable(tx *Transaction, oldName, newName string) error

RenameTable renames a table. If it doesn't exist, it returns errs.ErrTableNotFound.

type ConstraintViolationError

type ConstraintViolationError struct {
	Constraint string
	Paths      []object.Path
	Key        *tree.Key
}

func (ConstraintViolationError) Error

func (c ConstraintViolationError) Error() string

type ConversionFunc

type ConversionFunc func(v types.Value, path object.Path, targetType types.ValueType) (types.Value, error)

ConversionFunc is called when the type of a value is different than the expected type and the value needs to be converted.

type Database

type Database struct {

	// TransactionIDs is used to assign transaction an ID at runtime.
	// Since transaction IDs are not persisted and not used for concurrent
	// access, we can use 8 bytes ids that will be reset every time
	// the database restarts.
	TransactionIDs uint64

	// Underlying kv store.
	Store *kv.Store
	// contains filtered or unexported fields
}

func Open

func Open(path string, opts *Options) (*Database, error)

func (*Database) Begin

func (db *Database) Begin(writable bool) (*Transaction, error)

Begin starts a new transaction with default options. The returned transaction must be closed either by calling Rollback or Commit.

func (*Database) BeginTx

func (db *Database) BeginTx(opts *TxOptions) (*Transaction, error)

BeginTx starts a new transaction with the given options. If opts is empty, it will use the default options. The returned transaction must be closed either by calling Rollback or Commit. If the Attached option is passed, it opens a database level transaction, which gets attached to the database and prevents any other transaction to be opened afterwards until it gets rolled back or commited.

func (*Database) Catalog

func (db *Database) Catalog() *Catalog

func (*Database) Close

func (db *Database) Close() error

Close the database.

func (*Database) GetAttachedTx

func (db *Database) GetAttachedTx() *Transaction

GetAttachedTx returns the transaction attached to the database. It returns nil if there is no such transaction. The returned transaction is not thread safe.

func (*Database) SetCatalog

func (db *Database) SetCatalog(c *Catalog)

type EncodedObject

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

func NewEncodedObject

func NewEncodedObject(fcs *FieldConstraints, data []byte) *EncodedObject

func (*EncodedObject) GetByField

func (e *EncodedObject) GetByField(field string) (v types.Value, err error)

GetByField decodes the selected field from the buffer.

func (*EncodedObject) Iterate

func (e *EncodedObject) Iterate(fn func(field string, value types.Value) error) error

Iterate decodes each columns one by one and passes them to fn until the end of the row or until fn returns an error.

func (*EncodedObject) MarshalJSON

func (e *EncodedObject) MarshalJSON() ([]byte, error)

func (*EncodedObject) ResetWith

func (e *EncodedObject) ResetWith(fcs *FieldConstraints, data []byte)

type FieldConstraint

type FieldConstraint struct {
	Position      int
	Field         string
	Type          types.ValueType
	IsNotNull     bool
	DefaultValue  TableExpression
	AnonymousType *AnonymousType
}

FieldConstraint describes constraints on a particular field.

func (*FieldConstraint) IsEmpty

func (f *FieldConstraint) IsEmpty() bool

func (*FieldConstraint) String

func (f *FieldConstraint) String() string

type FieldConstraints

type FieldConstraints struct {
	Ordered          []*FieldConstraint
	ByField          map[string]*FieldConstraint
	AllowExtraFields bool
}

FieldConstraints is a list of field constraints.

func MustNewFieldConstraints

func MustNewFieldConstraints(constraints ...*FieldConstraint) FieldConstraints

func NewFieldConstraints

func NewFieldConstraints(constraints ...*FieldConstraint) (FieldConstraints, error)

func (*FieldConstraints) Add

func (f *FieldConstraints) Add(newFc *FieldConstraint) error

Add a field constraint to the list. If another constraint exists for the same path and they are equal, an error is returned.

func (FieldConstraints) ConvertValueAtPath

func (f FieldConstraints) ConvertValueAtPath(path object.Path, v types.Value, conversionFn ConversionFunc) (types.Value, error)

ConvertValueAtPath converts the value using the field constraints that are applicable at the given path.

func (FieldConstraints) GetFieldConstraintForPath

func (f FieldConstraints) GetFieldConstraintForPath(path object.Path) *FieldConstraint

type Index

type Index struct {
	// How many values the index is operating on.
	// For example, an index created with `CREATE INDEX idx_a_b ON foo (a, b)` has an arity of 2.
	Arity int
	Tree  *tree.Tree
}

An Index associates encoded values with keys.

The association is performed by encoding the values in a binary format that preserve ordering when compared lexicographically. For the implementation, see the binarysort package and the types.ValueEncoder.

func NewIndex

func NewIndex(tr *tree.Tree, opts IndexInfo) *Index

NewIndex creates an index that associates values with a list of keys.

func (*Index) Delete

func (idx *Index) Delete(vs []types.Value, key []byte) error

Delete all the references to the key from the index.

func (*Index) Exists

func (idx *Index) Exists(vs []types.Value) (bool, *tree.Key, error)

Exists iterates over the index and check if the value exists

func (*Index) IterateOnRange

func (idx *Index) IterateOnRange(rng *tree.Range, reverse bool, fn func(key *tree.Key) error) error

func (*Index) Set

func (idx *Index) Set(vs []types.Value, key []byte) error

Set associates values with a key. If Unique is set to false, it is possible to associate multiple keys for the same value but a key can be associated to only one value.

Values are stored in the index following the "index format". Every record is stored like this:

k: <encoded values><primary key>
v: length of the encoded value, as an unsigned varint

func (*Index) Truncate

func (idx *Index) Truncate() error

Truncate deletes all the index data.

type IndexInfo

type IndexInfo struct {
	// namespace of the store associated with the index.
	StoreNamespace tree.Namespace
	IndexName      string
	Paths          []object.Path

	// Sort order of each indexed field.
	KeySortOrder tree.SortOrder

	// If set to true, values will be associated with at most one key. False by default.
	Unique bool

	// If set, this index has been created from a table constraint
	// i.e CREATE TABLE tbl(a INT UNIQUE)
	// The path refers to the path this index is related to.
	Owner Owner
}

IndexInfo holds the configuration of an index.

func (IndexInfo) Clone

func (i IndexInfo) Clone() *IndexInfo

Clone returns a copy of the index information.

func (*IndexInfo) String

func (idx *IndexInfo) String() string

String returns a SQL representation.

type IndexInfoRelation

type IndexInfoRelation struct {
	Info *IndexInfo
}

func (*IndexInfoRelation) Clone

func (r *IndexInfoRelation) Clone() Relation

func (*IndexInfoRelation) GenerateBaseName

func (r *IndexInfoRelation) GenerateBaseName() string

func (*IndexInfoRelation) Name

func (r *IndexInfoRelation) Name() string

func (*IndexInfoRelation) SetName

func (r *IndexInfoRelation) SetName(name string)

func (*IndexInfoRelation) Type

func (r *IndexInfoRelation) Type() string

type LazyRow

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

LazyRow holds an LazyRow key and lazily loads the LazyRow on demand when the Iterate or GetByField method is called. It implements the Row and the object.Keyer interfaces.

func (*LazyRow) Get

func (r *LazyRow) Get(name string) (types.Value, error)

func (*LazyRow) GetByField

func (r *LazyRow) GetByField(field string) (types.Value, error)

func (*LazyRow) Iterate

func (r *LazyRow) Iterate(fn func(name string, value types.Value) error) error

func (*LazyRow) Key

func (r *LazyRow) Key() *tree.Key

func (*LazyRow) MarshalJSON

func (r *LazyRow) MarshalJSON() ([]byte, error)

func (*LazyRow) Object

func (r *LazyRow) Object() types.Object

func (*LazyRow) ResetWith

func (r *LazyRow) ResetWith(table *Table, key *tree.Key)

func (*LazyRow) TableName

func (r *LazyRow) TableName() string

type OnConflictAction

type OnConflictAction int

OnConflictAction is a function triggered when trying to insert a row that already exists. This function is triggered if the key is duplicated or if there is a unique constraint violation on one of the columns of the row.

func (OnConflictAction) String

func (o OnConflictAction) String() string

type Options

type Options struct {
	CatalogLoader func(tx *Transaction) error
}

Options are passed to Open to control how the database is loaded.

type Owner

type Owner struct {
	TableName string
	Paths     object.Paths
}

Owner is used to determine who owns a relation. If the relation has been created by a table (for rowids for example), only the TableName is filled. If it has been created by a field constraint (for identities for example), the path must also be filled.

type Pivot

type Pivot []types.Value

type PrimaryKey

type PrimaryKey struct {
	Paths     object.Paths
	Types     []types.ValueType
	SortOrder tree.SortOrder
}

type Range

type Range struct {
	Min, Max  Pivot
	Exclusive bool
	Exact     bool
}

func (*Range) Convert

func (r *Range) Convert(constraints *FieldConstraints, v types.Value, p object.Path, isMin bool) (types.Value, error)

func (*Range) IsEqual

func (r *Range) IsEqual(other *Range) bool

func (*Range) ToTreeRange

func (r *Range) ToTreeRange(constraints *FieldConstraints, paths []object.Path) (*tree.Range, error)

type Relation

type Relation interface {
	Type() string
	Name() string
	SetName(name string)
	GenerateBaseName() string
	Clone() Relation
}

type Row

type Row interface {
	// Iterate goes through all the fields of the row and calls the given function
	// by passing the column name
	Iterate(fn func(column string, value types.Value) error) error

	// Get returns the value of the given column.
	// If the column does not exist, it returns ErrColumnNotFound.
	Get(name string) (types.Value, error)

	// TableName returns the name of the table the row belongs to.
	TableName() string

	// MarshalJSON encodes the row as JSON.
	MarshalJSON() ([]byte, error)

	// Key returns the row key.
	Key() *tree.Key

	Object() types.Object
}

type RowIterator

type RowIterator interface {
	// Iterate goes through all the rows of the table and calls the given function by passing each one of them.
	// If the given function returns an error, the iteration stops.
	Iterate(fn func(Row) error) error
}

type Sequence

type Sequence struct {
	Info *SequenceInfo

	CurrentValue *int64
	Cached       uint64
	Key          *tree.Key
}

A Sequence manages a sequence of numbers. It is not thread safe.

func NewSequence

func NewSequence(info *SequenceInfo, currentValue *int64) Sequence

NewSequence creates a new or existing sequence. If currentValue is not nil next call to Next will increase the lease.

func (*Sequence) Clone

func (s *Sequence) Clone() Relation

func (*Sequence) Drop

func (s *Sequence) Drop(tx *Transaction, catalog *Catalog) error

func (*Sequence) GenerateBaseName

func (s *Sequence) GenerateBaseName() string

func (*Sequence) GetOrCreateTable

func (s *Sequence) GetOrCreateTable(tx *Transaction) (*Table, error)

func (*Sequence) Init

func (s *Sequence) Init(tx *Transaction) error

func (*Sequence) Name

func (s *Sequence) Name() string

func (*Sequence) Next

func (s *Sequence) Next(tx *Transaction) (int64, error)

func (*Sequence) Release

func (s *Sequence) Release(tx *Transaction) error

Release the sequence by storing the actual current value to the sequence table. If the sequence has cache, the cached value is overwritten.

func (*Sequence) SetLease

func (s *Sequence) SetLease(tx *Transaction, name string, v int64) error

func (*Sequence) SetName

func (s *Sequence) SetName(name string)

func (*Sequence) Type

func (s *Sequence) Type() string

type SequenceInfo

type SequenceInfo struct {
	Name        string
	IncrementBy int64
	Min, Max    int64
	Start       int64
	Cache       uint64
	Cycle       bool
	Owner       Owner
}

SequenceInfo holds the configuration of a sequence.

func (SequenceInfo) Clone

func (s SequenceInfo) Clone() *SequenceInfo

Clone returns a copy of the sequence information.

func (*SequenceInfo) String

func (s *SequenceInfo) String() string

String returns a SQL representation.

type Table

type Table struct {
	Tx   *Transaction
	Tree *tree.Tree
	// Table information.
	// May not represent the most up to date data.
	// Always get a fresh Table instance before relying on this field.
	Info *TableInfo
}

A Table represents a collection of objects.

func (*Table) Delete

func (t *Table) Delete(key *tree.Key) error

Delete a object by key.

func (*Table) GetRow

func (t *Table) GetRow(key *tree.Key) (Row, error)

GetRow returns one row by key.

func (*Table) Insert

func (t *Table) Insert(o types.Object) (*tree.Key, Row, error)

Insert the object into the table. If a primary key has been specified during the table creation, the field is expected to be present in the given object. If no primary key has been selected, a monotonic autoincremented integer key will be generated. It returns the inserted object alongside its key.

func (*Table) IterateOnRange

func (t *Table) IterateOnRange(rng *Range, reverse bool, fn func(key *tree.Key, r Row) error) error

func (*Table) Put

func (t *Table) Put(key *tree.Key, o types.Object) (Row, error)

Put a row by key. If the key doesn't exist, it is created.

func (*Table) Replace

func (t *Table) Replace(key *tree.Key, o types.Object) (Row, error)

Replace a row by key. An error is returned if the key doesn't exist.

func (*Table) Truncate

func (t *Table) Truncate() error

Truncate deletes all the objects from the table.

type TableConstraint

type TableConstraint struct {
	Name       string
	Paths      object.Paths
	Check      TableExpression
	Unique     bool
	PrimaryKey bool
	SortOrder  tree.SortOrder
}

A TableConstraint represent a constraint specific to a table and not necessarily to a single field path.

func (*TableConstraint) String

func (t *TableConstraint) String() string

type TableConstraints

type TableConstraints []*TableConstraint

TableConstraints holds the list of CHECK constraints.

func (*TableConstraints) ValidateRow

func (t *TableConstraints) ValidateRow(tx *Transaction, r Row) error

ValidateRow checks all the table constraint for the given row.

type TableExpression

type TableExpression interface {
	Eval(tx *Transaction, o types.Object) (types.Value, error)
	String() string
}

type TableInfo

type TableInfo struct {
	// name of the table.
	TableName string
	// namespace of the store associated with the table.
	StoreNamespace tree.Namespace
	ReadOnly       bool

	// Name of the rowid sequence if any.
	RowidSequenceName string

	FieldConstraints FieldConstraints
	TableConstraints TableConstraints

	PrimaryKey *PrimaryKey
}

TableInfo contains information about a table.

func (*TableInfo) AddFieldConstraint

func (ti *TableInfo) AddFieldConstraint(newFc *FieldConstraint) error

func (*TableInfo) AddTableConstraint

func (ti *TableInfo) AddTableConstraint(newTc *TableConstraint) error

func (*TableInfo) BuildPrimaryKey

func (ti *TableInfo) BuildPrimaryKey()

func (*TableInfo) Clone

func (ti *TableInfo) Clone() *TableInfo

Clone creates another tableInfo with the same values.

func (*TableInfo) EncodeKey

func (ti *TableInfo) EncodeKey(key *tree.Key) ([]byte, error)

func (*TableInfo) EncodeObject

func (t *TableInfo) EncodeObject(tx *Transaction, dst []byte, o types.Object) ([]byte, error)

EncodeObject validates a row against all the constraints of the table and encodes it.

func (*TableInfo) GetFieldConstraintForPath

func (ti *TableInfo) GetFieldConstraintForPath(p object.Path) *FieldConstraint

func (*TableInfo) PrimaryKeySortOrder

func (ti *TableInfo) PrimaryKeySortOrder() tree.SortOrder

func (*TableInfo) String

func (ti *TableInfo) String() string

String returns a SQL representation.

type TableInfoRelation

type TableInfoRelation struct {
	Info *TableInfo
}

func (*TableInfoRelation) Clone

func (r *TableInfoRelation) Clone() Relation

func (*TableInfoRelation) GenerateBaseName

func (r *TableInfoRelation) GenerateBaseName() string

func (*TableInfoRelation) Name

func (r *TableInfoRelation) Name() string

func (*TableInfoRelation) SetName

func (r *TableInfoRelation) SetName(name string)

func (*TableInfoRelation) Type

func (r *TableInfoRelation) Type() string

type Transaction

type Transaction struct {

	// Timestamp at which the transaction was created.
	// The timestamp must use the local timezone.
	TxStart time.Time

	Session   kv.Session
	Store     *kv.Store
	ID        uint64
	Writable  bool
	WriteTxMu *sync.Mutex
	// these functions are run after a successful rollback.
	OnRollbackHooks []func()
	// these functions are run after a successful commit.
	OnCommitHooks []func()

	Catalog *Catalog
	// contains filtered or unexported fields
}

Transaction represents a database transaction. It provides methods for managing the collection of tables and the transaction itself. Transaction is either read-only or read/write. Read-only can be used to read tables and read/write can be used to read, create, delete and modify tables.

func (*Transaction) CatalogWriter

func (tx *Transaction) CatalogWriter() *CatalogWriter

func (*Transaction) Commit

func (tx *Transaction) Commit() error

Commit the transaction. Calling this method on read-only transactions will return an error.

func (*Transaction) Rollback

func (tx *Transaction) Rollback() error

Rollback the transaction. Can be used safely after commit.

type TxOptions

type TxOptions struct {
	// Open a read-only transaction.
	ReadOnly bool
	// Set the transaction as global at the database level.
	// Any queries run by the database will use that transaction until it is
	// rolled back or commited.
	Attached bool
}

TxOptions are passed to Begin to configure transactions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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