Documentation ¶
Index ¶
- func CreateOID(section Section, schemaIndex int, dataIndex int) uint32
- func Init()
- func IterateCurrentDatabase(ctx *sql.Context, callbacks Callbacks) error
- func IterateDatabase(ctx *sql.Context, database string, callbacks Callbacks) error
- func RunCallback(ctx *sql.Context, oid uint32, callbacks Callbacks) error
- type Callbacks
- type ColumnWithIndex
- type ItemCheck
- type ItemColumnDefault
- type ItemForeignKey
- type ItemFunction
- type ItemIndex
- type ItemSchema
- type ItemSequence
- type ItemTable
- type ItemType
- type ItemView
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateOID ¶
CreateOID returns an OID with the given contents. If any index is larger than the allotted bit size, then this returns an OID with the section set to Section_Invalid.
The layout of an OID is as follows:
Section[SchemaIndex][DataIndex]
The schemaIndex represents the schema position that the OID is referencing (for all sections except for Section_Namespace) when sorting all schemas in ascending order by name. The dataIndex represents the index of the data according to the Section given (which will use some deterministic algorithm for the index).
func IterateCurrentDatabase ¶
IterateCurrentDatabase iterates over the current database, calling each callback as the relevant items are iterated over. This is a central function that homogenizes all iteration, since OIDs depend on a deterministic iteration over items. This function should be expanded as we add more items to iterate over.
func IterateDatabase ¶ added in v0.11.1
IterateDatabase iterates over the provided database, calling each callback as the relevant items are iterated over. This is a central function that homogenizes all iteration, since OIDs depend on a deterministic iteration over items. This function should be expanded as we add more items to iterate over.
func RunCallback ¶
RunCallback iterates over schemas, etc. to find the item that the given oid points to. Once the item has been found, the relevant callback is called with the item. This means that, at most, only one callback will be called. If the item cannot be found, then no callbacks are called.
Types ¶
type Callbacks ¶
type Callbacks struct { // Check is the callback for check constraints. Check func(ctx *sql.Context, schema ItemSchema, table ItemTable, check ItemCheck) (cont bool, err error) // ColumnDefault is the callback for column defaults. ColumnDefault func(ctx *sql.Context, schema ItemSchema, table ItemTable, check ItemColumnDefault) (cont bool, err error) // ForeignKey is the callback for foreign keys. ForeignKey func(ctx *sql.Context, schema ItemSchema, table ItemTable, foreignKey ItemForeignKey) (cont bool, err error) // Function is the callback for functions. Function func(ctx *sql.Context, function ItemFunction) (cont bool, err error) // Index is the callback for indexes. Index func(ctx *sql.Context, schema ItemSchema, table ItemTable, index ItemIndex) (cont bool, err error) // Schema is the callback for schemas/namespaces. Schema func(ctx *sql.Context, schema ItemSchema) (cont bool, err error) // Sequence is the callback for sequences. Sequence func(ctx *sql.Context, schema ItemSchema, sequence ItemSequence) (cont bool, err error) // Table is the callback for tables. Table func(ctx *sql.Context, schema ItemSchema, table ItemTable) (cont bool, err error) // Types is the callback for types. Type func(ctx *sql.Context, typ ItemType) (cont bool, err error) // View is the callback for views. View func(ctx *sql.Context, schema ItemSchema, view ItemView) (cont bool, err error) // SearchSchemas represents the search path. If left empty, then all schemas are iterated over. If supplied, then // schemas are iterated by their given order. SearchSchemas []string }
Callbacks are a set of callbacks that are used to simplify and coalesce all iteration involving database elements and their OIDs. All callbacks should be left nil except for the ones that are desired. Search paths are also supported through SearchSchemas.
type ColumnWithIndex ¶
ColumnWithIndex is a helper struct to pass the column and its index to the ColumnDefault callback.
type ItemCheck ¶
type ItemCheck struct { Index int OID uint32 Item sql.CheckDefinition }
ItemCheck contains the relevant information to pass to the Check callback.
type ItemColumnDefault ¶
type ItemColumnDefault struct { Index int OID uint32 Item ColumnWithIndex }
ItemColumnDefault contains the relevant information to pass to the ColumnDefault callback.
type ItemForeignKey ¶
type ItemForeignKey struct { Index int OID uint32 Item sql.ForeignKeyConstraint }
ItemForeignKey contains the relevant information to pass to the ForeignKey callback.
type ItemFunction ¶
ItemFunction contains the relevant information to pass to the Function callback.
type ItemSchema ¶
type ItemSchema struct { Index int OID uint32 Item sql.DatabaseSchema }
ItemSchema contains the relevant information to pass to the Schema callback.
func (ItemSchema) IsSystemSchema ¶ added in v0.12.0
func (is ItemSchema) IsSystemSchema() bool
type ItemSequence ¶
ItemSequence contains the relevant information to pass to the Sequence callback.
type ItemType ¶
type ItemType struct { // TODO: add Index when we add custom types OID uint32 Item pgtypes.DoltgresType }
ItemType contains the relevant information to pass to the Type callback.
type ItemView ¶
type ItemView struct { Index int OID uint32 Item sql.ViewDefinition }
ItemView contains the relevant information to pass to the View callback.
type Section ¶
type Section uint8
Section represents a specific space that an OID subset resides in. This makes it relatively simple to find the target of an OID, since each searchable space has its own section.
const ( Section_BuiltIn Section = iota // Contains all of the OIDs that are defined when creating a Postgres database Section_Check // Refers to checks on tables (the dataIndex is obtained by incrementing through all tables' checks) Section_Collation // Refers to collations Section_Database // Refers to the database (schemaIndex does not apply, so only dataIndex should be used) Section_ForeignKey // Refers to foreign keys on tables (the dataIndex is obtained by incrementing through all tables' foreign keys) Section_Function // Refers to functions only (no stored procedures, etc.) Section_Index // Refers to indexes on tables (the dataIndex is obtained by incrementing through all tables' indexes) Section_Namespace // Namespaces are the underlying structure of a schema, so these only use the dataIndex Section_Operator // Refers to operators (+, -, *, etc.) Section_Sequence // Refers to sequences Section_Table // Refers to tables Section_View // Refers to views Section_ColumnDefault // Refers to column defaults on tables (the dataIndex is obtained by incrementing through all tables' column defaults) Section_Invalid // Represents an invalid OID )