Versions in this module Expand all Collapse all v0 v0.16.0 Dec 25, 2023 Changes in this version + const CatalogTableName + const CatalogTableNamespace + const InternalPrefix + const MaxTransientNamespace + const MinTransientNamespace + const OnConflictDoNothing + const OnConflictDoReplace + const RelationIndexType + const RelationSequenceType + const RelationTableType + const RollbackSegmentNamespace + const SequenceTableName + const SequenceTableNamespace + const StoreSequence + var ErrIndexDuplicateValue = errors.New("duplicate value") + func CastConversion(v types.Value, path object.Path, targetType types.ValueType) (types.Value, error) + func IsConstraintViolationError(err error) bool + type AnonymousType struct + FieldConstraints FieldConstraints + func (an *AnonymousType) AddFieldConstraint(newFc *FieldConstraint) error + func (an *AnonymousType) String() string + type BasicRow struct + func NewBasicRow(obj types.Object) *BasicRow + func (r *BasicRow) Get(name string) (types.Value, error) + func (r *BasicRow) Iterate(fn func(name string, value types.Value) error) error + func (r *BasicRow) Key() *tree.Key + func (r *BasicRow) MarshalJSON() ([]byte, error) + func (r *BasicRow) Object() types.Object + func (r *BasicRow) ResetWith(tableName string, key *tree.Key, obj types.Object) + func (r *BasicRow) TableName() string + type Catalog struct + Cache *catalogCache + CatalogTable *CatalogStore + TransientNamespaces *atomic.Counter + func NewCatalog() *Catalog + func (c *Catalog) Clone() *Catalog + func (c *Catalog) GetFreeTransientNamespace() tree.Namespace + func (c *Catalog) GetIndex(tx *Transaction, indexName string) (*Index, error) + func (c *Catalog) GetIndexInfo(indexName string) (*IndexInfo, error) + func (c *Catalog) GetSequence(name string) (*Sequence, error) + func (c *Catalog) GetTable(tx *Transaction, tableName string) (*Table, error) + func (c *Catalog) GetTableInfo(tableName string) (*TableInfo, error) + func (c *Catalog) ListIndexes(tableName string) []string + func (c *Catalog) ListSequences() []string + type CatalogLoader interface + LoadCatalog func(kv.Session) (*Catalog, error) + type CatalogStore struct + func (s *CatalogStore) Delete(tx *Transaction, name string) error + func (s *CatalogStore) Info() *TableInfo + func (s *CatalogStore) Insert(tx *Transaction, r Relation) error + func (s *CatalogStore) Replace(tx *Transaction, name string, r Relation) error + func (s *CatalogStore) Table(tx *Transaction) *Table + type CatalogWriter struct + func NewCatalogWriter(c *Catalog) *CatalogWriter + func (c *CatalogWriter) AddFieldConstraint(tx *Transaction, tableName string, fc *FieldConstraint, tcs TableConstraints) error + func (c *CatalogWriter) CreateIndex(tx *Transaction, info *IndexInfo) (*IndexInfo, error) + func (c *CatalogWriter) CreateSequence(tx *Transaction, info *SequenceInfo) error + func (c *CatalogWriter) CreateTable(tx *Transaction, tableName string, info *TableInfo) error + func (c *CatalogWriter) DropIndex(tx *Transaction, name string) error + func (c *CatalogWriter) DropSequence(tx *Transaction, name string) error + func (c *CatalogWriter) DropTable(tx *Transaction, tableName string) error + func (c *CatalogWriter) Init(tx *Transaction) error + func (c *CatalogWriter) RenameTable(tx *Transaction, oldName, newName string) error + type ConstraintViolationError struct + Constraint string + Key *tree.Key + Paths []object.Path + func (c ConstraintViolationError) Error() string + type ConversionFunc func(v types.Value, path object.Path, targetType types.ValueType) (types.Value, error) + type Database struct + Store *kv.Store + TransactionIDs uint64 + func Open(path string, opts *Options) (*Database, error) + func (db *Database) Begin(writable bool) (*Transaction, error) + func (db *Database) BeginTx(opts *TxOptions) (*Transaction, error) + func (db *Database) Catalog() *Catalog + func (db *Database) Close() error + func (db *Database) GetAttachedTx() *Transaction + func (db *Database) SetCatalog(c *Catalog) + type EncodedObject struct + func NewEncodedObject(fcs *FieldConstraints, data []byte) *EncodedObject + func (e *EncodedObject) GetByField(field string) (v types.Value, err error) + func (e *EncodedObject) Iterate(fn func(field string, value types.Value) error) error + func (e *EncodedObject) MarshalJSON() ([]byte, error) + func (e *EncodedObject) ResetWith(fcs *FieldConstraints, data []byte) + type FieldConstraint struct + AnonymousType *AnonymousType + DefaultValue TableExpression + Field string + IsNotNull bool + Position int + Type types.ValueType + func (f *FieldConstraint) IsEmpty() bool + func (f *FieldConstraint) String() string + type FieldConstraints struct + AllowExtraFields bool + ByField map[string]*FieldConstraint + Ordered []*FieldConstraint + func MustNewFieldConstraints(constraints ...*FieldConstraint) FieldConstraints + func NewFieldConstraints(constraints ...*FieldConstraint) (FieldConstraints, error) + func (f *FieldConstraints) Add(newFc *FieldConstraint) error + func (f FieldConstraints) ConvertValueAtPath(path object.Path, v types.Value, conversionFn ConversionFunc) (types.Value, error) + func (f FieldConstraints) GetFieldConstraintForPath(path object.Path) *FieldConstraint + type Index struct + Arity int + Tree *tree.Tree + func NewIndex(tr *tree.Tree, opts IndexInfo) *Index + func (idx *Index) Delete(vs []types.Value, key []byte) error + func (idx *Index) Exists(vs []types.Value) (bool, *tree.Key, error) + func (idx *Index) IterateOnRange(rng *tree.Range, reverse bool, fn func(key *tree.Key) error) error + func (idx *Index) Set(vs []types.Value, key []byte) error + func (idx *Index) Truncate() error + type IndexInfo struct + IndexName string + KeySortOrder tree.SortOrder + Owner Owner + Paths []object.Path + StoreNamespace tree.Namespace + Unique bool + func (i IndexInfo) Clone() *IndexInfo + func (idx *IndexInfo) String() string + type IndexInfoRelation struct + Info *IndexInfo + func (r *IndexInfoRelation) Clone() Relation + func (r *IndexInfoRelation) GenerateBaseName() string + func (r *IndexInfoRelation) Name() string + func (r *IndexInfoRelation) SetName(name string) + func (r *IndexInfoRelation) Type() string + type LazyRow struct + func (r *LazyRow) Get(name string) (types.Value, error) + func (r *LazyRow) GetByField(field string) (types.Value, error) + func (r *LazyRow) Iterate(fn func(name string, value types.Value) error) error + func (r *LazyRow) Key() *tree.Key + func (r *LazyRow) MarshalJSON() ([]byte, error) + func (r *LazyRow) Object() types.Object + func (r *LazyRow) ResetWith(table *Table, key *tree.Key) + func (r *LazyRow) TableName() string + type OnConflictAction int + func (o OnConflictAction) String() string + type Options struct + CatalogLoader func(tx *Transaction) error + type Owner struct + Paths object.Paths + TableName string + type Pivot []types.Value + type PrimaryKey struct + Paths object.Paths + SortOrder tree.SortOrder + Types []types.ValueType + type Range struct + Exact bool + Exclusive bool + Max Pivot + Min Pivot + func (r *Range) Convert(constraints *FieldConstraints, v types.Value, p object.Path, isMin bool) (types.Value, error) + func (r *Range) IsEqual(other *Range) bool + func (r *Range) ToTreeRange(constraints *FieldConstraints, paths []object.Path) (*tree.Range, error) + type Relation interface + Clone func() Relation + GenerateBaseName func() string + Name func() string + SetName func(name string) + Type func() string + type Row interface + Get func(name string) (types.Value, error) + Iterate func(fn func(column string, value types.Value) error) error + Key func() *tree.Key + MarshalJSON func() ([]byte, error) + Object func() types.Object + TableName func() string + type RowIterator interface + Iterate func(fn func(Row) error) error + type Sequence struct + Cached uint64 + CurrentValue *int64 + Info *SequenceInfo + Key *tree.Key + func NewSequence(info *SequenceInfo, currentValue *int64) Sequence + func (s *Sequence) Clone() Relation + func (s *Sequence) Drop(tx *Transaction, catalog *Catalog) error + func (s *Sequence) GenerateBaseName() string + func (s *Sequence) GetOrCreateTable(tx *Transaction) (*Table, error) + func (s *Sequence) Init(tx *Transaction) error + func (s *Sequence) Name() string + func (s *Sequence) Next(tx *Transaction) (int64, error) + func (s *Sequence) Release(tx *Transaction) error + func (s *Sequence) SetLease(tx *Transaction, name string, v int64) error + func (s *Sequence) SetName(name string) + func (s *Sequence) Type() string + type SequenceInfo struct + Cache uint64 + Cycle bool + IncrementBy int64 + Max int64 + Min int64 + Name string + Owner Owner + Start int64 + func (s *SequenceInfo) String() string + func (s SequenceInfo) Clone() *SequenceInfo + type Table struct + Info *TableInfo + Tree *tree.Tree + Tx *Transaction + func (t *Table) Delete(key *tree.Key) error + func (t *Table) GetRow(key *tree.Key) (Row, error) + func (t *Table) Insert(o types.Object) (*tree.Key, Row, error) + func (t *Table) IterateOnRange(rng *Range, reverse bool, fn func(key *tree.Key, r Row) error) error + func (t *Table) Put(key *tree.Key, o types.Object) (Row, error) + func (t *Table) Replace(key *tree.Key, o types.Object) (Row, error) + func (t *Table) Truncate() error + type TableConstraint struct + Check TableExpression + Name string + Paths object.Paths + PrimaryKey bool + SortOrder tree.SortOrder + Unique bool + func (t *TableConstraint) String() string + type TableConstraints []*TableConstraint + func (t *TableConstraints) ValidateRow(tx *Transaction, r Row) error + type TableExpression interface + Eval func(tx *Transaction, o types.Object) (types.Value, error) + String func() string + type TableInfo struct + FieldConstraints FieldConstraints + PrimaryKey *PrimaryKey + ReadOnly bool + RowidSequenceName string + StoreNamespace tree.Namespace + TableConstraints TableConstraints + TableName string + func (t *TableInfo) EncodeObject(tx *Transaction, dst []byte, o types.Object) ([]byte, error) + func (ti *TableInfo) AddFieldConstraint(newFc *FieldConstraint) error + func (ti *TableInfo) AddTableConstraint(newTc *TableConstraint) error + func (ti *TableInfo) BuildPrimaryKey() + func (ti *TableInfo) Clone() *TableInfo + func (ti *TableInfo) EncodeKey(key *tree.Key) ([]byte, error) + func (ti *TableInfo) GetFieldConstraintForPath(p object.Path) *FieldConstraint + func (ti *TableInfo) PrimaryKeySortOrder() tree.SortOrder + func (ti *TableInfo) String() string + type TableInfoRelation struct + Info *TableInfo + func (r *TableInfoRelation) Clone() Relation + func (r *TableInfoRelation) GenerateBaseName() string + func (r *TableInfoRelation) Name() string + func (r *TableInfoRelation) SetName(name string) + func (r *TableInfoRelation) Type() string + type Transaction struct + Catalog *Catalog + ID uint64 + OnCommitHooks []func() + OnRollbackHooks []func() + Session kv.Session + Store *kv.Store + TxStart time.Time + Writable bool + WriteTxMu *sync.Mutex + func (tx *Transaction) CatalogWriter() *CatalogWriter + func (tx *Transaction) Commit() error + func (tx *Transaction) Rollback() error + type TxOptions struct + Attached bool + ReadOnly bool