Documentation
¶
Overview ¶
Package table provides table management for XxSql storage engine.
Index ¶
- Constants
- type IndexInfo
- type Table
- func (t *Table) AddCheckConstraint(constraint *types.CheckConstraintInfo) error
- func (t *Table) AddCheckConstraints(constraints []*types.CheckConstraintInfo) error
- func (t *Table) AddColumn(col *types.ColumnInfo) error
- func (t *Table) AddForeignKey(fk *types.ForeignKeyInfo) error
- func (t *Table) AddForeignKeys(fks []*types.ForeignKeyInfo) error
- func (t *Table) AddUniqueConstraint(colName, constraintName string) error
- func (t *Table) Close() error
- func (t *Table) Columns() []*types.ColumnInfo
- func (t *Table) CreateIndex(name string, columns []string, unique bool) error
- func (t *Table) Delete(predicate func(*row.Row) bool) (int, error)
- func (t *Table) Drop() error
- func (t *Table) DropCheckConstraint(name string) error
- func (t *Table) DropColumn(colName string) error
- func (t *Table) DropForeignKey(name string) error
- func (t *Table) DropIndex(name string) error
- func (t *Table) DropUniqueConstraint(constraintName string) error
- func (t *Table) FindByKey(key types.Value) (*row.Row, error)
- func (t *Table) Flush() error
- func (t *Table) GetCheckConstraints() []*types.CheckConstraintInfo
- func (t *Table) GetForeignKeys() []*types.ForeignKeyInfo
- func (t *Table) GetIndexManager() *btree.IndexManager
- func (t *Table) GetInfo() *TableInfo
- func (t *Table) Insert(values []types.Value) (row.RowID, error)
- func (t *Table) ModifyColumn(col *types.ColumnInfo) error
- func (t *Table) Name() string
- func (t *Table) Rename(newName string) error
- func (t *Table) RenameColumn(oldName, newName string) error
- func (t *Table) RowCount() uint64
- func (t *Table) Scan() ([]*row.Row, error)
- func (t *Table) SetPrimaryKey(colName string) error
- func (t *Table) Truncate() error
- func (t *Table) Update(predicate func(*row.Row) bool, updates map[int]types.Value) (int, error)
- type TableInfo
- type TableState
Constants ¶
const ( // MetaFileExt is the extension for table metadata files. MetaFileExt = ".xmeta" // DataFileExt is the extension for table data files. DataFileExt = ".xdb" // IndexFileExt is the extension for index files. IndexFileExt = ".xidx" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexInfo ¶
type IndexInfo struct {
Name string `json:"name"`
Columns []string `json:"columns"`
Unique bool `json:"unique"`
RootPageID page.PageID `json:"root_page_id"`
}
IndexInfo represents index metadata.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents an open table.
func OpenTable ¶
func OpenTable(dataDir, name string, columns []*types.ColumnInfo) (*Table, error)
OpenTable opens or creates a table.
func (*Table) AddCheckConstraint ¶
func (t *Table) AddCheckConstraint(constraint *types.CheckConstraintInfo) error
AddCheckConstraint adds a single CHECK constraint to the table.
func (*Table) AddCheckConstraints ¶
func (t *Table) AddCheckConstraints(constraints []*types.CheckConstraintInfo) error
AddCheckConstraints adds CHECK constraints to the table.
func (*Table) AddColumn ¶
func (t *Table) AddColumn(col *types.ColumnInfo) error
AddColumn adds a column to the table.
func (*Table) AddForeignKey ¶
func (t *Table) AddForeignKey(fk *types.ForeignKeyInfo) error
AddForeignKey adds a single FOREIGN KEY constraint to the table.
func (*Table) AddForeignKeys ¶
func (t *Table) AddForeignKeys(fks []*types.ForeignKeyInfo) error
AddForeignKeys adds FOREIGN KEY constraints to the table.
func (*Table) AddUniqueConstraint ¶
AddUniqueConstraint adds a UNIQUE constraint to a column.
func (*Table) Columns ¶
func (t *Table) Columns() []*types.ColumnInfo
Columns returns the column definitions.
func (*Table) CreateIndex ¶
CreateIndex creates a new index on the table.
func (*Table) DropCheckConstraint ¶
DropCheckConstraint drops a CHECK constraint by name.
func (*Table) DropColumn ¶
DropColumn drops a column from the table.
func (*Table) DropForeignKey ¶
DropForeignKey drops a FOREIGN KEY constraint by name.
func (*Table) DropUniqueConstraint ¶
DropUniqueConstraint drops a UNIQUE constraint by name.
func (*Table) GetCheckConstraints ¶
func (t *Table) GetCheckConstraints() []*types.CheckConstraintInfo
GetCheckConstraints returns the CHECK constraints.
func (*Table) GetForeignKeys ¶
func (t *Table) GetForeignKeys() []*types.ForeignKeyInfo
GetForeignKeys returns the FOREIGN KEY constraints.
func (*Table) GetIndexManager ¶
func (t *Table) GetIndexManager() *btree.IndexManager
GetIndexManager returns the index manager.
func (*Table) ModifyColumn ¶
func (t *Table) ModifyColumn(col *types.ColumnInfo) error
ModifyColumn modifies a column definition.
func (*Table) RenameColumn ¶
RenameColumn renames a column.
func (*Table) SetPrimaryKey ¶
SetPrimaryKey sets a column as primary key.
type TableInfo ¶
type TableInfo struct {
Name string `json:"name"`
Columns []*types.ColumnInfo `json:"columns"`
PrimaryKey []string `json:"primary_key,omitempty"`
Indexes []*IndexInfo `json:"indexes,omitempty"`
CheckConstraints []*types.CheckConstraintInfo `json:"check_constraints,omitempty"`
ForeignKeys []*types.ForeignKeyInfo `json:"foreign_keys,omitempty"`
CreatedAt time.Time `json:"created_at"`
ModifiedAt time.Time `json:"modified_at"`
RowCount uint64 `json:"row_count"`
NextRowID uint64 `json:"next_row_id"`
NextPageID page.PageID `json:"next_page_id"`
RootPageID page.PageID `json:"root_page_id"`
State TableState `json:"state"`
}
TableInfo represents table metadata.
type TableState ¶
type TableState uint8
TableState represents the state of a table.
const ( TableStateActive TableState = iota TableStateDeleting TableStateDeleted )