types

package
v0.0.0-...-c96b3bb Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Uint2TypName  = "uint2"
	Uint4TypName  = "uint4"
	Uint8TypName  = "uint8"
	Uint16TypName = "uint16"

	Int16TypName = "int16"
)

Variables

This section is empty.

Functions

func RegisterAll

func RegisterAll(ctx context.Context, conn *pgx.Conn) ([]*Type, error)

RegisterAll registers both integer types and their associated variants.

This function invokes RegisterTypes to register the main integer types (uint2, uint4, uint8, uint16 and int16) and subsequently registers their variants (array, range, multirange) in the TypeMap of pgx.Conn by calling RegisterDefaultPgTypeVariants.

It returns a slice of pointers to the registered Type structs. If an error occurs during the registration process, it returns nil along with the error.

The returned types can be used to register them on new connections without issuing actual database queries. For example, you can use the following code:

	conn.TypeMap().RegisterTypes(regTypes)
 types.RegisterDefaultPgTypeVariants(conn.TypeMap())

Note that the uniqueness of type OIDs is guaranteed only within a single server and a single database on that server. Consequently, OIDs may conflict across different databases or servers.

func RegisterDefaultPgTypeVariants

func RegisterDefaultPgTypeVariants(tMap *Map)

func RegisterTypes

func RegisterTypes(ctx context.Context, conn *pgx.Conn) ([]*Type, error)

RegisterTypes registers all integer types (uint2, uint4, uint8, uint16 and int16) at once.

It returns a slice of pointers to the registered Type structs corresponding to these types.

The returned types can be used to register them on new connections without issuing actual database queries. For example, you can use the following code:

conn.TypeMap().RegisterTypes(types)

Note that the uniqueness of type OIDs is guaranteed only within a single server and a single database on that server. Consequently, OIDs may conflict across different databases or servers.

If there is an error while loading the types, it will be returned, along with a nil slice.

Types

type Int16

type Int16 struct {
	I128  num.I128
	Valid bool
}

func (Int16) Int64Value

func (n Int16) Int64Value() (Int8, error)

func (Int16) MarshalJSON

func (src Int16) MarshalJSON() ([]byte, error)

func (*Int16) Scan

func (dst *Int16) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Int16) ScanInt64

func (dst *Int16) ScanInt64(n Int8) error

ScanInt64 implements the Int64Scanner interface.

func (*Int16) ScanUint64

func (dst *Int16) ScanUint64(n UInt8) error

ScanUint64 implements the Uint64Scanner interface.

func (Int16) Uint64Value

func (n Int16) Uint64Value() (UInt8, error)

func (*Int16) UnmarshalJSON

func (dst *Int16) UnmarshalJSON(b []byte) error

func (Int16) Value

func (src Int16) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Int16Codec

type Int16Codec struct{}

func (Int16Codec) DecodeDatabaseSQLValue

func (c Int16Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)

func (Int16Codec) DecodeValue

func (c Int16Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Int16Codec) FormatSupported

func (Int16Codec) FormatSupported(format int16) bool

func (Int16Codec) PlanEncode

func (Int16Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan

func (Int16Codec) PlanScan

func (Int16Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan

func (Int16Codec) PreferredFormat

func (Int16Codec) PreferredFormat() int16

type UInt16

type UInt16 struct {
	Uint128 uint128.Uint128
	Valid   bool
}

func (UInt16) Int64Value

func (n UInt16) Int64Value() (Int8, error)

func (UInt16) MarshalJSON

func (src UInt16) MarshalJSON() ([]byte, error)

func (*UInt16) Scan

func (dst *UInt16) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*UInt16) ScanInt64

func (dst *UInt16) ScanInt64(n Int8) error

ScanInt64 implements the Int64Scanner interface.

func (*UInt16) ScanUint64

func (dst *UInt16) ScanUint64(n UInt8) error

ScanUint64 implements the Uint64Scanner interface.

func (UInt16) Uint64Value

func (n UInt16) Uint64Value() (UInt8, error)

func (*UInt16) UnmarshalJSON

func (dst *UInt16) UnmarshalJSON(b []byte) error

func (UInt16) Value

func (src UInt16) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type UInt16Codec

type UInt16Codec struct{}

func (UInt16Codec) DecodeDatabaseSQLValue

func (c UInt16Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)

func (UInt16Codec) DecodeValue

func (c UInt16Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (UInt16Codec) FormatSupported

func (UInt16Codec) FormatSupported(format int16) bool

func (UInt16Codec) PlanEncode

func (UInt16Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan

func (UInt16Codec) PlanScan

func (UInt16Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan

func (UInt16Codec) PreferredFormat

func (UInt16Codec) PreferredFormat() int16

type UInt2

type UInt2 struct {
	Uint16 uint16
	Valid  bool
}

func (UInt2) Int64Value

func (n UInt2) Int64Value() (Int8, error)

func (UInt2) MarshalJSON

func (src UInt2) MarshalJSON() ([]byte, error)

func (*UInt2) Scan

func (dst *UInt2) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*UInt2) ScanInt64

func (dst *UInt2) ScanInt64(n Int8) error

ScanInt64 implements the Int64Scanner interface.

func (*UInt2) ScanUint64

func (dst *UInt2) ScanUint64(n UInt8) error

ScanUint64 implements the Uint64Scanner interface.

func (UInt2) Uint64Value

func (n UInt2) Uint64Value() (UInt8, error)

func (*UInt2) UnmarshalJSON

func (dst *UInt2) UnmarshalJSON(b []byte) error

func (UInt2) Value

func (src UInt2) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type UInt2Codec

type UInt2Codec struct{}

func (UInt2Codec) DecodeDatabaseSQLValue

func (c UInt2Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)

func (UInt2Codec) DecodeValue

func (c UInt2Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (UInt2Codec) FormatSupported

func (UInt2Codec) FormatSupported(format int16) bool

func (UInt2Codec) PlanEncode

func (UInt2Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan

func (UInt2Codec) PlanScan

func (UInt2Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan

func (UInt2Codec) PreferredFormat

func (UInt2Codec) PreferredFormat() int16

type UInt4

type UInt4 struct {
	Uint32 uint32
	Valid  bool
}

func (UInt4) Int64Value

func (n UInt4) Int64Value() (Int8, error)

func (UInt4) MarshalJSON

func (src UInt4) MarshalJSON() ([]byte, error)

func (*UInt4) Scan

func (dst *UInt4) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*UInt4) ScanInt64

func (dst *UInt4) ScanInt64(n Int8) error

ScanInt64 implements the Int64Scanner interface.

func (*UInt4) ScanUint64

func (dst *UInt4) ScanUint64(n UInt8) error

ScanUint64 implements the Uint64Scanner interface.

func (UInt4) Uint64Value

func (n UInt4) Uint64Value() (UInt8, error)

func (*UInt4) UnmarshalJSON

func (dst *UInt4) UnmarshalJSON(b []byte) error

func (UInt4) Value

func (src UInt4) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type UInt4Codec

type UInt4Codec struct{}

func (UInt4Codec) DecodeDatabaseSQLValue

func (c UInt4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)

func (UInt4Codec) DecodeValue

func (c UInt4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (UInt4Codec) FormatSupported

func (UInt4Codec) FormatSupported(format int16) bool

func (UInt4Codec) PlanEncode

func (UInt4Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan

func (UInt4Codec) PlanScan

func (UInt4Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan

func (UInt4Codec) PreferredFormat

func (UInt4Codec) PreferredFormat() int16

type UInt8

type UInt8 struct {
	Uint64 uint64
	Valid  bool
}

func (UInt8) Int64Value

func (n UInt8) Int64Value() (Int8, error)

func (UInt8) MarshalJSON

func (src UInt8) MarshalJSON() ([]byte, error)

func (*UInt8) Scan

func (dst *UInt8) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*UInt8) ScanInt64

func (dst *UInt8) ScanInt64(n Int8) error

ScanInt64 implements the Int64Scanner interface.

func (*UInt8) ScanUint64

func (dst *UInt8) ScanUint64(n UInt8) error

ScanUint64 implements the Uint64Scanner interface.

func (UInt8) Uint64Value

func (n UInt8) Uint64Value() (UInt8, error)

func (*UInt8) UnmarshalJSON

func (dst *UInt8) UnmarshalJSON(b []byte) error

func (UInt8) Value

func (src UInt8) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type UInt8Codec

type UInt8Codec struct{}

func (UInt8Codec) DecodeDatabaseSQLValue

func (c UInt8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)

func (UInt8Codec) DecodeValue

func (c UInt8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (UInt8Codec) FormatSupported

func (UInt8Codec) FormatSupported(format int16) bool

func (UInt8Codec) PlanEncode

func (UInt8Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan

func (UInt8Codec) PlanScan

func (UInt8Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan

func (UInt8Codec) PreferredFormat

func (UInt8Codec) PreferredFormat() int16

type Uint64Scanner

type Uint64Scanner interface {
	ScanUint64(UInt8) error
}

type Uint64Valuer

type Uint64Valuer interface {
	Uint64Value() (UInt8, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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