functions

package
v0.53.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NanosPerMicro = 1000
	NanosPerMilli = NanosPerMicro * duration.MicrosPerMilli
	NanosPerSec   = NanosPerMicro * duration.MicrosPerMilli * duration.MillisPerSec
)
View Source
const (
	DCH_A_D keywordID = iota
	DCH_A_M
	DCH_AD
	DCH_AM
	DCH_B_C
	DCH_BC
	DCH_CC
	DCH_DAY
	DCH_DDD
	DCH_DD
	DCH_DY
	DCH_Day
	DCH_Dy
	DCH_D
	DCH_FF1
	DCH_FF2
	DCH_FF3
	DCH_FF4
	DCH_FF5
	DCH_FF6
	DCH_FX
	DCH_HH24
	DCH_HH12
	DCH_HH
	DCH_IDDD
	DCH_ID
	DCH_IW
	DCH_IYYY
	DCH_IYY
	DCH_IY
	DCH_I
	DCH_J
	DCH_MI
	DCH_MM
	DCH_MONTH
	DCH_MON
	DCH_MS
	DCH_Month
	DCH_Mon
	DCH_OF
	DCH_P_M
	DCH_PM
	DCH_Q
	DCH_RM
	DCH_SSSSS
	DCH_SSSS
	DCH_SS
	DCH_TZH
	DCH_TZM
	DCH_TZ
	DCH_US
	DCH_WW
	DCH_W
	DCH_Y_YYY
	DCH_YYYY
	DCH_YYY
	DCH_YY
	DCH_Y
	DCH_a_d
	DCH_a_m
	DCH_ad
	DCH_am
	DCH_b_c
	DCH_bc
	DCH_cc
	DCH_day
	DCH_ddd
	DCH_dd
	DCH_dy
	DCH_d
	DCH_ff1
	DCH_ff2
	DCH_ff3
	DCH_ff4
	DCH_ff5
	DCH_ff6
	DCH_fx
	DCH_hh24
	DCH_hh12
	DCH_hh
	DCH_iddd
	DCH_id
	DCH_iw
	DCH_iyyy
	DCH_iyy
	DCH_iy
	DCH_i
	DCH_j
	DCH_mi
	DCH_mm
	DCH_month
	DCH_mon
	DCH_ms
	DCH_of
	DCH_p_m
	DCH_pm
	DCH_q
	DCH_rm
	DCH_sssss
	DCH_ssss
	DCH_ss
	DCH_tzh
	DCH_tzm
	DCH_tz
	DCH_us
	DCH_ww
	DCH_w
	DCH_y_yyy
	DCH_yyyy
	DCH_yyy
	DCH_yy
	DCH_y

	NUM_COMMA
	NUM_DEC
	NUM_0
	NUM_9
	NUM_B
	NUM_C
	NUM_D
	NUM_E
	NUM_FM
	NUM_G
	NUM_L
	NUM_MI
	NUM_PL
	NUM_PR
	NUM_RN
	NUM_SG
	NUM_SP
	NUM_S
	NUM_TH
	NUM_V
	NUM_b
	NUM_c
	NUM_d
	NUM_e
	NUM_fm
	NUM_g
	NUM_l
	NUM_mi
	NUM_pl
	NUM_pr
	NUM_rn
	NUM_sg
	NUM_sp
	NUM_s
	NUM_th
	NUM_v
)
View Source
const (
	DCH_S_FM int = 0x01
	DCH_S_TH int = 0x02
	DCH_S_th int = 0x04
	DCH_S_SP int = 0x08
	DCH_S_TM int = 0x10
)
View Source
const (
	DateStyleISO      = "ISO"
	DateStyleSQL      = "SQL"
	DateStylePostgres = "Postgres"
	DateStyleGerman   = "German"
)

https://www.postgresql.org/docs/15/datatype-datetime.html

Variables

View Source
var ErrUnitNotSupported = errors.NewKind("unit \"%s\" not supported for type %s")

Functions

func FormatDateTimeWithBC added in v0.51.2

func FormatDateTimeWithBC(t time.Time, layout string, hasTZ bool) string

FormatDateTimeWithBC formats a time.Time that may represent BC dates (negative years) PostgreSQL represents BC years as negative years in time.Time, but Go's Format() doesn't handle this correctly tz is optional timezone value to be appended to formatted value

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)
	// Type is the callback for types.
	Type func(ctx *sql.Context, schema ItemSchema, 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 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 ItemType added in v0.52.3

type ItemType struct {
	Oid  id.Type
	Item *types.DoltgresType
}

ItemType contains the relevant information to pass to the Type 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