Documentation
¶
Index ¶
- func AddHandler(schemaName string, tableName string, handler Handler)
- func Init()
- func WrapSqlDatabase(db sql.Database) sql.Database
- type Database
- type Handler
- type IndexedTableHandler
- type PgDatabase
- func (d *PgDatabase) AllSchemas(ctx *sql.Context) ([]sql.DatabaseSchema, error)
- func (d *PgDatabase) DropTable(ctx *sql.Context, tableName string) error
- func (d *PgDatabase) GenerateIndexName(ctx *sql.Context, tableName string, idxDef sql.IndexDef, _ sql.Table) (string, error)
- func (d *PgDatabase) GetSchema(ctx *sql.Context, schemaName string) (sql.DatabaseSchema, bool, error)
- func (d *PgDatabase) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)
- func (d *PgDatabase) ValidateNewIndexName(ctx *sql.Context, newIndexName string, skipIfExists bool) (nameAlreadyUsed bool, err error)
- func (d *PgDatabase) ValidateNewSequenceName(ctx *sql.Context, newSequenceName string, skipIfExists bool) (nameAlreadyUsed bool, err error)
- func (d *PgDatabase) ValidateNewTableName(ctx *sql.Context, newTableName string, skipIfExists bool) (nameAlreadyUsed bool, err error)
- func (d *PgDatabase) ValidateNewViewName(ctx *sql.Context, newViewName string, replaceAllowed bool) error
- type PgReadOnlyDatabase
- func (d *PgReadOnlyDatabase) AllSchemas(ctx *sql.Context) ([]sql.DatabaseSchema, error)
- func (d *PgReadOnlyDatabase) GetSchema(ctx *sql.Context, schemaName string) (sql.DatabaseSchema, bool, error)
- func (d *PgReadOnlyDatabase) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)
- type VirtualTable
- func (tbl *VirtualTable) Collation() sql.CollationID
- func (tbl *VirtualTable) DatabaseSchema() sql.DatabaseSchema
- func (tbl *VirtualTable) DebugString(ctx *sql.Context) string
- func (tbl *VirtualTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error)
- func (tbl *VirtualTable) IndexedAccess(ctx *sql.Context, lookup sql.IndexLookup) sql.IndexedTable
- func (tbl *VirtualTable) LookupPartitions(ctx *sql.Context, lookup sql.IndexLookup) (sql.PartitionIter, error)
- func (tbl *VirtualTable) Name() string
- func (tbl *VirtualTable) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)
- func (tbl *VirtualTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error)
- func (tbl *VirtualTable) PreciseMatch() bool
- func (tbl *VirtualTable) PrimaryKeySchema(ctx *sql.Context) sql.PrimaryKeySchema
- func (tbl *VirtualTable) Schema(ctx *sql.Context) sql.Schema
- func (tbl *VirtualTable) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHandler ¶
AddHandler adds the given handler to the handler set.
func Init ¶
func Init()
Init handles initialization of all Postgres-specific and Doltgres-specific tables.
func WrapSqlDatabase ¶ added in v0.56.5
WrapSqlDatabase wraps any Dolt database variant as a Pg-aware database. ReadOnlyDatabase embeds sqle.Database by value, so a plain sqle.Database type assertion does not match it; this function handles both cases.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is a wrapper around Dolt's database object, allowing for functionality specific to Doltgres (such as system tables).
func (Database) GetTableInsensitive ¶
GetTableInsensitive implements the interface sql.DatabaseSchema.
func (Database) GetTableNames ¶
GetTableNames implements the interface sql.DatabaseSchema.
func (Database) SchemaName ¶
type Handler ¶
type Handler interface {
// Name returns the name of the table.
Name() string
// RowIter returns a sql.RowIter that returns the rows of the table.
RowIter(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)
// PkSchema returns the table's schema.
PkSchema() sql.PrimaryKeySchema
}
Handler is an interface that controls how data is represented for some table.
type IndexedTableHandler ¶ added in v0.52.0
type IndexedTableHandler interface {
Handler
// Indexes returns the table's indexes.
Indexes() ([]sql.Index, error)
// LookupPartitions returns a sql.PartitionIter that can be used to look up rows in the table using the given lookup
LookupPartitions(context *sql.Context, lookup sql.IndexLookup) (sql.PartitionIter, error)
}
type PgDatabase ¶ added in v0.56.5
PgDatabase wraps a sqle.Database to add PostgreSQL-specific behavior.
func WrapSqleDatabase ¶ added in v0.56.5
func WrapSqleDatabase(db sqle.Database) *PgDatabase
WrapSqleDatabase creates a PgDatabase from a sqle.Database.
func (*PgDatabase) AllSchemas ¶ added in v0.56.5
func (d *PgDatabase) AllSchemas(ctx *sql.Context) ([]sql.DatabaseSchema, error)
AllSchemas overrides sqle.Database.AllSchemas to apply Doltgres schema wrapping.
func (*PgDatabase) DropTable ¶ added in v0.56.5
func (d *PgDatabase) DropTable(ctx *sql.Context, tableName string) error
DropTable overrides sqle.Database.DropTable to prevent dropping virtual pg_catalog tables.
func (*PgDatabase) GenerateIndexName ¶ added in v0.56.5
func (d *PgDatabase) GenerateIndexName(ctx *sql.Context, tableName string, idxDef sql.IndexDef, _ sql.Table) (string, error)
GenerateIndexName implements the sql.IndexNameGenerator interface with PostgreSQL-compatible naming conventions:
- UNIQUE indexes: <table>_<col1>[_col2...]_key
- All other indexes: <table>_<col1>[_col2...]_idx
Collisions are resolved by appending a numeric suffix (1, 2, …) to the base name. The collision check uses doesRelationExist so that any schema-level relation — table, view, sequence, or another index — blocks a candidate name, matching PostgreSQL's behavior where all relations in a schema share one namespace.
func (*PgDatabase) GetSchema ¶ added in v0.56.5
func (d *PgDatabase) GetSchema(ctx *sql.Context, schemaName string) (sql.DatabaseSchema, bool, error)
GetSchema overrides sqle.Database.GetSchema to apply Doltgres schema wrapping.
func (*PgDatabase) GetTableInsensitive ¶ added in v0.56.5
GetTableInsensitive overrides sqle.Database.GetTableInsensitive to check the pg_catalog virtual schema before falling back to user tables.
func (*PgDatabase) ValidateNewIndexName ¶ added in v0.56.5
func (d *PgDatabase) ValidateNewIndexName(ctx *sql.Context, newIndexName string, skipIfExists bool) (nameAlreadyUsed bool, err error)
ValidateNewIndexName implements the sql.SchemaObjectNameValidator interface
func (*PgDatabase) ValidateNewSequenceName ¶ added in v0.56.5
func (d *PgDatabase) ValidateNewSequenceName(ctx *sql.Context, newSequenceName string, skipIfExists bool) (nameAlreadyUsed bool, err error)
ValidateNewSequenceName implements the sql.SchemaObjectNameValidator interface
func (*PgDatabase) ValidateNewTableName ¶ added in v0.56.5
func (d *PgDatabase) ValidateNewTableName(ctx *sql.Context, newTableName string, skipIfExists bool) (nameAlreadyUsed bool, err error)
ValidateNewTableName implements the sql.SchemaObjectNameValidator interface
func (*PgDatabase) ValidateNewViewName ¶ added in v0.56.5
func (d *PgDatabase) ValidateNewViewName(ctx *sql.Context, newViewName string, replaceAllowed bool) error
ValidateNewViewName implements the sql.SchemaObjectNameValidator interface
type PgReadOnlyDatabase ¶ added in v0.56.5
type PgReadOnlyDatabase struct {
sqle.ReadOnlyDatabase
}
PgReadOnlyDatabase is the read-only variant of PgDatabase, used for revision databases such as "postgres/main" returned by sqle.DoltDatabaseProvider for detached-HEAD sessions. It applies the same schema-wrapping logic as PgDatabase.
func (*PgReadOnlyDatabase) AllSchemas ¶ added in v0.56.5
func (d *PgReadOnlyDatabase) AllSchemas(ctx *sql.Context) ([]sql.DatabaseSchema, error)
AllSchemas overrides sqle.ReadOnlyDatabase.AllSchemas to apply Doltgres schema wrapping.
func (*PgReadOnlyDatabase) GetSchema ¶ added in v0.56.5
func (d *PgReadOnlyDatabase) GetSchema(ctx *sql.Context, schemaName string) (sql.DatabaseSchema, bool, error)
GetSchema overrides sqle.ReadOnlyDatabase.GetSchema to apply Doltgres schema wrapping.
func (*PgReadOnlyDatabase) GetTableInsensitive ¶ added in v0.56.5
func (d *PgReadOnlyDatabase) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error)
GetTableInsensitive overrides sqle.Database.GetTableInsensitive to check the pg_catalog virtual schema before falling back to user tables.
type VirtualTable ¶
type VirtualTable struct {
// contains filtered or unexported fields
}
VirtualTable represents a table that does not enforce any particular storage of its data.
func NewVirtualTable ¶
func NewVirtualTable(handler Handler, schema sql.DatabaseSchema) *VirtualTable
NewVirtualTable creates a new *VirtualTable from the given Handler.
func (*VirtualTable) Collation ¶
func (tbl *VirtualTable) Collation() sql.CollationID
Collation implements the interface sql.Table.
func (*VirtualTable) DatabaseSchema ¶ added in v0.51.0
func (tbl *VirtualTable) DatabaseSchema() sql.DatabaseSchema
func (*VirtualTable) DebugString ¶
func (tbl *VirtualTable) DebugString(ctx *sql.Context) string
DebugString implements the interface sql.DebugStringer.
func (*VirtualTable) GetIndexes ¶ added in v0.52.0
GetIndexes implements the interface sql.IndexedTable.
func (*VirtualTable) IndexedAccess ¶ added in v0.52.0
func (tbl *VirtualTable) IndexedAccess(ctx *sql.Context, lookup sql.IndexLookup) sql.IndexedTable
IndexedAccess implements the interface sql.IndexAddressableTable.
func (*VirtualTable) LookupPartitions ¶ added in v0.52.0
func (tbl *VirtualTable) LookupPartitions(ctx *sql.Context, lookup sql.IndexLookup) (sql.PartitionIter, error)
LookupPartitions implements the interface sql.IndexedTable.
func (*VirtualTable) Name ¶
func (tbl *VirtualTable) Name() string
Name implements the interface sql.Table.
func (*VirtualTable) PartitionRows ¶
func (tbl *VirtualTable) PartitionRows(ctx *sql.Context, partition sql.Partition) (sql.RowIter, error)
PartitionRows implements the interface sql.Table.
func (*VirtualTable) Partitions ¶
func (tbl *VirtualTable) Partitions(ctx *sql.Context) (sql.PartitionIter, error)
Partitions implements the interface sql.Table.
func (*VirtualTable) PreciseMatch ¶ added in v0.52.0
func (tbl *VirtualTable) PreciseMatch() bool
GetIndexLookup implements the interface sql.IndexAddressableTable.
func (*VirtualTable) PrimaryKeySchema ¶
func (tbl *VirtualTable) PrimaryKeySchema(ctx *sql.Context) sql.PrimaryKeySchema
PrimaryKeySchema implements the interface sql.PrimaryKeyTable.
func (*VirtualTable) Schema ¶
func (tbl *VirtualTable) Schema(ctx *sql.Context) sql.Schema
Schema implements the interface sql.Table.
func (*VirtualTable) String ¶
func (tbl *VirtualTable) String() string
String implements the interface sql.Table.