id

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Null is an empty, invalid ID.
	Null Id = ""
	// NullAccessMethod is an empty, invalid ID. This is exactly equivalent to Null.
	NullAccessMethod AccessMethod = ""
	// NullCheck is an empty, invalid ID. This is exactly equivalent to Null.
	NullCheck Check = ""
	// NullCollation is an empty, invalid ID. This is exactly equivalent to Null.
	NullCollation Collation = ""
	// NullColumnDefault is an empty, invalid ID. This is exactly equivalent to Null.
	NullColumnDefault ColumnDefault = ""
	// NullDatabase is an empty, invalid ID. This is exactly equivalent to Null.
	NullDatabase Database = ""
	// NullEnumLabel is an empty, invalid ID. This is exactly equivalent to Null.
	NullEnumLabel EnumLabel = ""
	// NullForeignKey is an empty, invalid ID. This is exactly equivalent to Null.
	NullForeignKey ForeignKey = ""
	// NullFunction is an empty, invalid ID. This is exactly equivalent to Null.
	NullFunction Function = ""
	// NullIndex is an empty, invalid ID. This is exactly equivalent to Null.
	NullIndex Index = ""
	// NullNamespace is an empty, invalid ID. This is exactly equivalent to Null.
	NullNamespace Namespace = ""
	// NullSequence is an empty, invalid ID. This is exactly equivalent to Null.
	NullSequence Sequence = ""
	// NullTable is an empty, invalid ID. This is exactly equivalent to Null.
	NullTable Table = ""
	// NullType is an empty, invalid ID. This is exactly equivalent to Null.
	NullType Type = ""
	// NullView is an empty, invalid ID. This is exactly equivalent to Null.
	NullView View = ""
)

Variables

This section is empty.

Functions

func Cache

func Cache() *cacheStruct

Cache returns the global cache that is used for the server session.

func PerformOperation added in v0.17.0

func PerformOperation(ctx *sql.Context, targetSection Section, operation Operation, originalID Id, newID Id) error

PerformOperation calls all registered performers that are associated with the given section. This does not call any validators, which should be done using ValidateOperation. This returns the first error that is encountered.

func RegisterListener added in v0.17.0

func RegisterListener(listener Listener, sections ...Section)

RegisterListener registers the given listener for the given sections.

For example, sequences are related to tables. Whenever a table operation is performed that changes its ID, sequences will also need to update their IDs that reference the table. This is accomplished by registering a performer that accepts a table section, where the performer modifies sequences as needed.

Performers should not register sections that are directly related to themselves. For example, a sequence performer should not register itself under the sequence section, as it will be the one broadcasting that section, and therefore could cause a loop.

func ValidateOperation added in v0.17.0

func ValidateOperation(ctx *sql.Context, targetSection Section, operation Operation, originalID Id, newID Id) error

ValidateOperation calls all registered validators that are associated with the given section.

Types

type AccessMethod added in v0.17.0

type AccessMethod Id

AccessMethod is an Id wrapper for access methods. This wrapper must not be returned to the client.

func NewAccessMethod added in v0.17.0

func NewAccessMethod(methodName string) AccessMethod

NewAccessMethod returns a new AccessMethod. This wrapper must not be returned to the client.

func (AccessMethod) AsId added in v0.17.0

func (id AccessMethod) AsId() Id

AsId returns the unwrapped ID.

func (AccessMethod) IsValid added in v0.17.0

func (id AccessMethod) IsValid() bool

IsValid returns whether the ID is valid.

func (AccessMethod) MethodName added in v0.17.0

func (id AccessMethod) MethodName() string

MethodName returns the method's name.

type Check added in v0.17.0

type Check Id

Check is an Id wrapper for checks. This wrapper must not be returned to the client.

func NewCheck added in v0.17.0

func NewCheck(schemaName string, tableName string, checkName string) Check

NewCheck returns a new Check. This wrapper must not be returned to the client.

func (Check) AsId added in v0.17.0

func (id Check) AsId() Id

AsId returns the unwrapped ID.

func (Check) CheckName added in v0.17.0

func (id Check) CheckName() string

CheckName returns the check's name.

func (Check) IsValid added in v0.17.0

func (id Check) IsValid() bool

IsValid returns whether the ID is valid.

func (Check) SchemaName added in v0.17.0

func (id Check) SchemaName() string

SchemaName returns the schema name of the check.

func (Check) TableName added in v0.17.0

func (id Check) TableName() string

TableName returns the name of the table that the check belongs to.

type Collation added in v0.17.0

type Collation Id

Collation is an Id wrapper for collations. This wrapper must not be returned to the client.

func NewCollation added in v0.17.0

func NewCollation(schemaName string, collationName string) Collation

NewCollation returns a new Collation. This wrapper must not be returned to the client.

func (Collation) AsId added in v0.17.0

func (id Collation) AsId() Id

AsId returns the unwrapped ID.

func (Collation) CollationName added in v0.17.0

func (id Collation) CollationName() string

CollationName returns the collation's name.

func (Collation) IsValid added in v0.17.0

func (id Collation) IsValid() bool

IsValid returns whether the ID is valid.

func (Collation) SchemaName added in v0.17.0

func (id Collation) SchemaName() string

SchemaName returns the schema name of the collation.

type ColumnDefault added in v0.17.0

type ColumnDefault Id

ColumnDefault is an Id wrapper for column defaults. This wrapper must not be returned to the client.

func NewColumnDefault added in v0.17.0

func NewColumnDefault(schemaName string, tableName string, columnName string) ColumnDefault

NewColumnDefault returns a new ColumnDefault. This wrapper must not be returned to the client.

func (ColumnDefault) AsId added in v0.17.0

func (id ColumnDefault) AsId() Id

AsId returns the unwrapped ID.

func (ColumnDefault) ColumnName added in v0.17.0

func (id ColumnDefault) ColumnName() string

ColumnName returns the column's name that the default belongs to.

func (ColumnDefault) IsValid added in v0.17.0

func (id ColumnDefault) IsValid() bool

IsValid returns whether the ID is valid.

func (ColumnDefault) SchemaName added in v0.17.0

func (id ColumnDefault) SchemaName() string

SchemaName returns the schema name of the column default.

func (ColumnDefault) TableName added in v0.17.0

func (id ColumnDefault) TableName() string

TableName returns the name of the table that the column belongs to.

type Database added in v0.17.0

type Database Id

Database is an Id wrapper for databases. This wrapper must not be returned to the client.

func NewDatabase added in v0.17.0

func NewDatabase(dbName string) Database

NewDatabase returns a new Database. This wrapper must not be returned to the client.

func (Database) AsId added in v0.17.0

func (id Database) AsId() Id

AsId returns the unwrapped ID.

func (Database) DatabaseName added in v0.17.0

func (id Database) DatabaseName() string

DatabaseName returns the database's name.

func (Database) IsValid added in v0.17.0

func (id Database) IsValid() bool

IsValid returns whether the ID is valid.

type EnumLabel added in v0.17.0

type EnumLabel Id

EnumLabel is an Id wrapper for enum labels. This wrapper must not be returned to the client.

func NewEnumLabel added in v0.17.0

func NewEnumLabel(parent Type, label string) EnumLabel

NewEnumLabel returns a new EnumLabel. This wrapper must not be returned to the client.

func (EnumLabel) AsId added in v0.17.0

func (id EnumLabel) AsId() Id

AsId returns the unwrapped ID.

func (EnumLabel) IsValid added in v0.17.0

func (id EnumLabel) IsValid() bool

IsValid returns whether the ID is valid.

func (EnumLabel) Label added in v0.17.0

func (id EnumLabel) Label() string

Label returns the name of the label.

func (EnumLabel) Parent added in v0.17.0

func (id EnumLabel) Parent() Type

Parent returns the parent ENUM for the label.

type ForeignKey added in v0.17.0

type ForeignKey Id

ForeignKey is an Id wrapper for foreign keys. This wrapper must not be returned to the client.

func NewForeignKey added in v0.17.0

func NewForeignKey(schemaName string, tableName string, fkName string) ForeignKey

NewForeignKey returns a new ForeignKey. This wrapper must not be returned to the client.

func (ForeignKey) AsId added in v0.17.0

func (id ForeignKey) AsId() Id

AsId returns the unwrapped ID.

func (ForeignKey) ForeignKeyName added in v0.17.0

func (id ForeignKey) ForeignKeyName() string

ForeignKeyName returns the foreign key's name.

func (ForeignKey) IsValid added in v0.17.0

func (id ForeignKey) IsValid() bool

IsValid returns whether the ID is valid.

func (ForeignKey) SchemaName added in v0.17.0

func (id ForeignKey) SchemaName() string

SchemaName returns the schema name of the foreign key.

func (ForeignKey) TableName added in v0.17.0

func (id ForeignKey) TableName() string

TableName returns the name of the table that the foreign key belongs to.

type Function added in v0.17.0

type Function Id

Function is an Id wrapper for functions. This wrapper must not be returned to the client.

func NewFunction added in v0.17.0

func NewFunction(schemaName string, funcName string, params ...Type) Function

NewFunction returns a new Function. This wrapper must not be returned to the client.

func (Function) AsId added in v0.17.0

func (id Function) AsId() Id

AsId returns the unwrapped ID.

func (Function) FunctionName added in v0.17.0

func (id Function) FunctionName() string

FunctionName returns the function's name.

func (Function) IsValid added in v0.17.0

func (id Function) IsValid() bool

IsValid returns whether the ID is valid.

func (Function) ParameterCount added in v0.17.0

func (id Function) ParameterCount() int

ParameterCount returns the function's name.

func (Function) Parameters added in v0.17.0

func (id Function) Parameters() []Type

Parameters returns the function's name.

func (Function) SchemaName added in v0.17.0

func (id Function) SchemaName() string

SchemaName returns the schema name of the function.

type Id added in v0.17.0

type Id string

Id is an ID that is used within Doltgres. This ID is never exposed to clients through any normal means, and exists solely for internal operations to be able to identify specific items. This functions as an internal replacement for Postgres' OIDs.

func NewId added in v0.17.0

func NewId(section Section, data ...string) Id

NewId constructs an Id using the given section and data. In general, you should prefer to use the `NewIDTYPE` that matches the Section that's being created, and then convert that to an Id for returning or storage. You almost never want to call this function directly.

func (Id) CaseString added in v0.17.0

func (id Id) CaseString() string

CaseString returns a quoted string that may be used to represent this ID in a switch-case.

func (Id) Data added in v0.17.0

func (id Id) Data() []string

Data returns the original data used to create this Id.

func (Id) IsValid added in v0.17.0

func (id Id) IsValid() bool

IsValid returns whether the Id is valid.

func (Id) Section added in v0.17.0

func (id Id) Section() Section

Section returns the Section for this Id.

func (Id) Segment added in v0.17.0

func (id Id) Segment(index int) string

Segment returns the segment from the given index. An empty string is returned for an index not contained by the ID.

func (Id) SegmentCount added in v0.17.0

func (id Id) SegmentCount() int

SegmentCount returns the number of segments that were in the original data.

func (Id) String added in v0.17.0

func (id Id) String() string

String returns a display-suitable version of the ID. Although the ID is implemented as a string, it should not be treated as a string except for the purposes of storage and retrieval.

func (Id) UnderlyingBytes added in v0.17.0

func (id Id) UnderlyingBytes() []byte

UnderlyingBytes returns the underlying bytes for the ID. These must not be modified, as this is intended solely for efficient usage of operations that require byte slices.

type Index added in v0.17.0

type Index Id

Index is an Id wrapper for indexes. This wrapper must not be returned to the client.

func NewIndex added in v0.17.0

func NewIndex(schemaName string, tableName string, indexName string) Index

NewIndex returns a new Index. This wrapper must not be returned to the client.

func (Index) AsId added in v0.17.0

func (id Index) AsId() Id

AsId returns the unwrapped ID.

func (Index) IndexName added in v0.17.0

func (id Index) IndexName() string

IndexName returns the index's name.

func (Index) IsValid added in v0.17.0

func (id Index) IsValid() bool

IsValid returns whether the ID is valid.

func (Index) SchemaName added in v0.17.0

func (id Index) SchemaName() string

SchemaName returns the schema name of the index.

func (Index) TableName added in v0.17.0

func (id Index) TableName() string

TableName returns the name of the table that the index belongs to.

type Listener added in v0.17.0

type Listener interface {
	// OperationPerformer is a function that performs the given operation on the original ID. Some operations, such as
	// renames, will use the new ID.
	OperationPerformer(ctx *sql.Context, operation Operation, originalID Id, newID Id) error
	// OperationValidator is a function that validates the given operation on the original ID. Some operations, such as
	// renames, will use the new ID. A validator is not required, and is intended for operations that may be relatively
	// expensive to perform, but able to check quickly for failures. In addition, validators should not perform any
	// modifications. If a validator is not required, then this should just return nil.
	OperationValidator(ctx *sql.Context, operation Operation, originalID Id, newID Id) error
}

type Namespace added in v0.17.0

type Namespace Id

Namespace is an Id wrapper for schemas/namespaces. This wrapper must not be returned to the client.

func NewNamespace added in v0.17.0

func NewNamespace(schemaName string) Namespace

NewNamespace returns a new Namespace. This wrapper must not be returned to the client.

func (Namespace) AsId added in v0.17.0

func (id Namespace) AsId() Id

AsId returns the unwrapped ID.

func (Namespace) IsValid added in v0.17.0

func (id Namespace) IsValid() bool

IsValid returns whether the ID is valid.

func (Namespace) SchemaName added in v0.17.0

func (id Namespace) SchemaName() string

SchemaName returns the schema name.

type Oid added in v0.17.0

type Oid Id

Oid is an Id wrapper for OIDs. This wrapper must not be returned to the client.

func NewOID added in v0.17.0

func NewOID(val uint32) Oid

NewOID returns a new Oid. This wrapper must not be returned to the client.

func (Oid) AsId added in v0.17.0

func (id Oid) AsId() Id

AsId returns the unwrapped ID.

func (Oid) IsValid added in v0.17.0

func (id Oid) IsValid() bool

IsValid returns whether the ID is valid.

func (Oid) OID added in v0.17.0

func (id Oid) OID() uint32

OID returns the contained uint32 value.

type Operation added in v0.17.0

type Operation uint8

Operation represents an operation that is being performed or validated.

const (
	Operation_Rename Operation = iota
	Operation_Delete
	Operation_Delete_Cascade
)

func (Operation) String added in v0.17.0

func (op Operation) String() string

String returns the name of the operation.

type Section

type Section uint8

Section represents a specific space that an Internal ID resides in. This makes it relatively simple to find the target of the ID, since each searchable space has its own section.

const (
	Section_Null                 Section = 0  // Represents a null ID
	Section_AccessMethod         Section = 1  // Refers to relation access methods
	Section_Cast                 Section = 2  // Refers to casts between types
	Section_Check                Section = 3  // Refers to checks on tables
	Section_Collation            Section = 4  // Refers to collations
	Section_ColumnDefault        Section = 5  // Refers to column defaults on tables
	Section_Database             Section = 6  // Refers to the database
	Section_EnumLabel            Section = 7  // Refers to a specific label in an ENUM type
	Section_EventTrigger         Section = 8  // Refers to event triggers
	Section_ExclusionConstraint  Section = 9  // Refers to exclusion constraints
	Section_Extension            Section = 10 // Refers to extensions
	Section_ForeignKey           Section = 11 // Refers to foreign keys on tables
	Section_ForeignDataWrapper   Section = 12 // Refers to foreign data wrappers
	Section_ForeignServer        Section = 13 // Refers to foreign servers
	Section_ForeignTable         Section = 14 // Refers to foreign tables
	Section_Function             Section = 15 // Refers to functions
	Section_FunctionLanguage     Section = 16 // Refers to the programming languages available for writing functions
	Section_Index                Section = 17 // Refers to indexes on tables
	Section_Namespace            Section = 18 // Namespaces are the underlying structure of a schema (basically the schema)
	Section_OID                  Section = 19 // Refers to a raw OID that is not actually attached to anything (ONLY used with reg types)
	Section_Operator             Section = 20 // Refers to operators (+, -, *, etc.)
	Section_OperatorClass        Section = 21 // Refers to operator classes
	Section_OperatorFamily       Section = 22 // Refers to operator families
	Section_PrimaryKey           Section = 23 // Refers to primary keys on tables
	Section_Procedure            Section = 24 // Refers to stored procedures
	Section_Publication          Section = 25 // Refers to publications
	Section_RowLevelSecurity     Section = 26 // Refers to row-level security polices on tables
	Section_Sequence             Section = 27 // Refers to sequences
	Section_Subscription         Section = 28 // Refers to logical replication subscriptions
	Section_Table                Section = 29 // Refers to tables
	Section_TextSearchConfig     Section = 30 // Refers to text search configuration
	Section_TextSearchDictionary Section = 31 // Refers to text search dictionaries
	Section_TextSearchParser     Section = 32 // Refers to text search parsers
	Section_TextSearchTemplate   Section = 33 // Refers to text search templates
	Section_Trigger              Section = 34 // Refers to triggers on tables and views
	Section_Type                 Section = 35 // Refers to types
	Section_UniqueKey            Section = 36 // Refers to unique keys on tables
	Section_User                 Section = 37 // Refers to users
	Section_View                 Section = 38 // Refers to views

)

All new sections must be given an unused number, as these may be persisted in tables. Changing them would change pre-existing table data, potentially corrupting that table data. At most, there can be 127 sections, since the first bit is reserved to determine a format's encoding.

func (Section) String

func (section Section) String() string

String returns the name of the Section.

type Sequence added in v0.17.0

type Sequence Id

Sequence is an Id wrapper for sequences. This wrapper must not be returned to the client.

func NewSequence added in v0.17.0

func NewSequence(schemaName string, sequenceName string) Sequence

NewSequence returns a new Sequence. This wrapper must not be returned to the client.

func (Sequence) AsId added in v0.17.0

func (id Sequence) AsId() Id

AsId returns the unwrapped ID.

func (Sequence) IsValid added in v0.17.0

func (id Sequence) IsValid() bool

IsValid returns whether the ID is valid.

func (Sequence) SchemaName added in v0.17.0

func (id Sequence) SchemaName() string

SchemaName returns the schema name of the sequence.

func (Sequence) SequenceName added in v0.17.0

func (id Sequence) SequenceName() string

SequenceName returns the name of the sequence.

type Table added in v0.17.0

type Table Id

Table is an Id wrapper for tables. This wrapper must not be returned to the client.

func NewTable added in v0.17.0

func NewTable(schemaName string, tableName string) Table

NewTable returns a new Table. This wrapper must not be returned to the client.

func (Table) AsId added in v0.17.0

func (id Table) AsId() Id

AsId returns the unwrapped ID.

func (Table) IsValid added in v0.17.0

func (id Table) IsValid() bool

IsValid returns whether the ID is valid.

func (Table) SchemaName added in v0.17.0

func (id Table) SchemaName() string

SchemaName returns the schema name of the table.

func (Table) TableName added in v0.17.0

func (id Table) TableName() string

TableName returns the table's name.

type Type added in v0.17.0

type Type Id

Type is an Id wrapper for types. This wrapper must not be returned to the client.

func NewType added in v0.17.0

func NewType(schemaName string, typeName string) Type

NewType returns a new Type. This wrapper must not be returned to the client.

func (Type) AsId added in v0.17.0

func (id Type) AsId() Id

AsId returns the unwrapped ID.

func (Type) IsValid added in v0.17.0

func (id Type) IsValid() bool

IsValid returns whether the ID is valid.

func (Type) SchemaName added in v0.17.0

func (id Type) SchemaName() string

SchemaName returns the schema name of the type.

func (Type) TypeName added in v0.17.0

func (id Type) TypeName() string

TypeName returns the type's name.

type View added in v0.17.0

type View Id

View is an Id wrapper for views. This wrapper must not be returned to the client.

func NewView added in v0.17.0

func NewView(schemaName string, viewName string) View

NewView returns a new View. This wrapper must not be returned to the client.

func (View) AsId added in v0.17.0

func (id View) AsId() Id

AsId returns the unwrapped ID.

func (View) IsValid added in v0.17.0

func (id View) IsValid() bool

IsValid returns whether the ID is valid.

func (View) SchemaName added in v0.17.0

func (id View) SchemaName() string

SchemaName returns the schema name of the view.

func (View) ViewName added in v0.17.0

func (id View) ViewName() string

ViewName returns the view's name.

Jump to

Keyboard shortcuts

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