functions

package
v0.51.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NanosPerMicro = 1000
	NanosPerMilli = NanosPerMicro * duration.MicrosPerMilli
	NanosPerSec   = NanosPerMicro * duration.MicrosPerMilli * duration.MillisPerSec
)

Variables

View Source
var ErrStepSizeCannotEqualZero = errors.NewKind("step size cannot equal zero")
View Source
var ErrUnitNotSupported = errors.NewKind("unit \"%s\" not supported for type %s")

Functions

func GetIntervalDurationFromTimeComponents added in v0.11.0

func GetIntervalDurationFromTimeComponents(years, months, days, hours, minutes, seconds, nanos int64) duration.Duration

func GetServerLocation added in v0.16.0

func GetServerLocation(ctx *sql.Context) (*time.Location, error)

GetServerLocation returns timezone value set for the server.

func Init added in v0.7.0

func Init()

Init initializes all functions in this package.

func IterateCurrentDatabase added in v0.16.0

func IterateCurrentDatabase(ctx *sql.Context, callbacks Callbacks) error

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.16.0

func IterateDatabase(ctx *sql.Context, database string, callbacks Callbacks) error

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 added in v0.16.0

func RunCallback(ctx *sql.Context, internalID id.Id, callbacks Callbacks) error

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 added in v0.16.0

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)
	// 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)
	// 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 added in v0.16.0

type ColumnWithIndex struct {
	Column      *sql.Column
	ColumnIndex int
}

ColumnWithIndex is a helper struct to pass the column and its index to the ColumnDefault callback.

type ItemCheck added in v0.16.0

type ItemCheck struct {
	OID  id.Check
	Item sql.CheckDefinition
}

ItemCheck contains the relevant information to pass to the Check callback.

type ItemColumnDefault added in v0.16.0

type ItemColumnDefault struct {
	OID  id.ColumnDefault
	Item ColumnWithIndex
}

ItemColumnDefault contains the relevant information to pass to the ColumnDefault callback.

type ItemForeignKey added in v0.16.0

type ItemForeignKey struct {
	OID  id.ForeignKey
	Item sql.ForeignKeyConstraint
}

ItemForeignKey contains the relevant information to pass to the ForeignKey callback.

type ItemIndex added in v0.16.0

type ItemIndex struct {
	OID  id.Index
	Item sql.Index
}

ItemIndex contains the relevant information to pass to the Index callback.

type ItemSchema added in v0.16.0

type ItemSchema struct {
	OID  id.Namespace
	Item sql.DatabaseSchema
}

ItemSchema contains the relevant information to pass to the Schema callback.

func (ItemSchema) IsSystemSchema added in v0.16.0

func (is ItemSchema) IsSystemSchema() bool

type ItemSequence added in v0.16.0

type ItemSequence struct {
	OID  id.Sequence
	Item *sequences.Sequence
}

ItemSequence contains the relevant information to pass to the Sequence callback.

type ItemTable added in v0.16.0

type ItemTable struct {
	OID  id.Table
	Item sql.Table
}

ItemTable contains the relevant information to pass to the Table callback.

type ItemView added in v0.16.0

type ItemView struct {
	OID  id.View
	Item sql.ViewDefinition
}

ItemView contains the relevant information to pass to the View callback.

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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