pgtypes

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MacAddr8OID      uint32 = 774
	MacAddrArray8OID uint32 = 775
	TimeTZOID        uint32 = 1266
	TimeTZArrayOID   uint32 = 1270
	XmlOID           uint32 = 142
	XmlArrayOID      uint32 = 143
)
View Source
const (
	MessageTypeLogicalDecodingMessage pglogrepl.MessageType = 'M'
)

Variables

This section is empty.

Functions

func AsFieldLength added in v0.5.0

func AsFieldLength(
	typ PgType, modifiers int,
) (int, bool)

func EnhancedArrayTextCodecFactory added in v0.9.0

func EnhancedArrayTextCodecFactory[V any](
	typeMap *pgtype.Map, typ PgType,
) pgtype.Codec

func ParseXlogData added in v0.3.1

func ParseXlogData(
	data []byte, lastTransactionId *uint32,
) (pglogrepl.Message, error)

Types

type BeginMessage

type BeginMessage pglogrepl.BeginMessage

func (BeginMessage) String added in v0.0.12

func (m BeginMessage) String() string

type BoxArrayCodec added in v0.5.0

type BoxArrayCodec struct {
	PgxArrayCodec *pgtype.ArrayCodec
}

BoxArrayCodec is a wrapper codec for box[] which isn't handled gracefully in the pgx base source code (at least in PG < 14 without binary wire protocol support) due to the way the text protocol sends back the value of a box item.

func (*BoxArrayCodec) DecodeDatabaseSQLValue added in v0.5.0

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

func (*BoxArrayCodec) DecodeValue added in v0.5.0

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

func (*BoxArrayCodec) FormatSupported added in v0.5.0

func (c *BoxArrayCodec) FormatSupported(
	format int16,
) bool

func (*BoxArrayCodec) PlanEncode added in v0.5.0

func (c *BoxArrayCodec) PlanEncode(
	m *pgtype.Map, oid uint32, format int16, value any,
) pgtype.EncodePlan

func (*BoxArrayCodec) PlanScan added in v0.5.0

func (c *BoxArrayCodec) PlanScan(
	m *pgtype.Map, oid uint32, format int16, target any,
) pgtype.ScanPlan

func (*BoxArrayCodec) PreferredFormat added in v0.5.0

func (c *BoxArrayCodec) PreferredFormat() int16

type CommitMessage

type CommitMessage pglogrepl.CommitMessage

func (CommitMessage) String added in v0.0.12

func (m CommitMessage) String() string

type CompositeColumn added in v0.5.0

type CompositeColumn interface {
	schema.Buildable
	Name() string
	Type() PgType
	Modifiers() int
	Nullable() bool
}

type CompositeColumnFactory added in v0.5.0

type CompositeColumnFactory func(
	name string, oid uint32, modifiers int, nullable bool,
) (CompositeColumn, error)

type DeleteMessage

type DeleteMessage struct {
	*pglogrepl.DeleteMessage
	OldValues map[string]any
}

func (DeleteMessage) String added in v0.0.12

func (m DeleteMessage) String() string

type EnhancedArrayTextCodec added in v0.9.0

type EnhancedArrayTextCodec[V any] struct {
	PgxArrayCodec *pgtype.ArrayCodec
	// contains filtered or unexported fields
}

EnhancedArrayTextCodec is an enhanced array codec utilizing the typdelim field from pg_type as a separator of the text value representing the array in the PG wire protocol. The pgx internal implementation always expects the delimiter to be a comma (,) which isn't true for all types, such as box, and PostGIS types.

This special version only implements text format, binary is forwarded to the original array codec, as it doesn't have the same issue, since it's a text parsing issue only.

func (*EnhancedArrayTextCodec[V]) DecodeDatabaseSQLValue added in v0.9.0

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

func (*EnhancedArrayTextCodec[V]) DecodeValue added in v0.9.0

func (c *EnhancedArrayTextCodec[V]) DecodeValue(
	m *pgtype.Map, oid uint32, format int16, src []byte,
) (any, error)

func (*EnhancedArrayTextCodec[V]) FormatSupported added in v0.9.0

func (c *EnhancedArrayTextCodec[V]) FormatSupported(
	format int16,
) bool

func (*EnhancedArrayTextCodec[V]) PlanEncode added in v0.9.0

func (c *EnhancedArrayTextCodec[V]) PlanEncode(
	m *pgtype.Map, oid uint32, format int16, value any,
) pgtype.EncodePlan

func (*EnhancedArrayTextCodec[V]) PlanScan added in v0.9.0

func (c *EnhancedArrayTextCodec[V]) PlanScan(
	m *pgtype.Map, oid uint32, format int16, target any,
) pgtype.ScanPlan

func (*EnhancedArrayTextCodec[V]) PreferredFormat added in v0.9.0

func (c *EnhancedArrayTextCodec[V]) PreferredFormat() int16

type Geography added in v0.9.0

type Geography struct {
	Geography geom.T
	Valid     bool
}

func (Geography) MarshalJSON added in v0.9.0

func (g Geography) MarshalJSON() ([]byte, error)

func (Geography) New added in v0.9.0

func (g Geography) New(
	v geom.T,
) Geography

func (Geography) PostGisValue added in v0.9.0

func (g Geography) PostGisValue() (Geography, error)

func (*Geography) Scan added in v0.9.0

func (g *Geography) Scan(
	src any,
) error

func (*Geography) ScanPostGisValue added in v0.9.0

func (g *Geography) ScanPostGisValue(
	v Geography,
) error

func (*Geography) UnmarshalJSON added in v0.9.0

func (g *Geography) UnmarshalJSON(
	b []byte,
) error

func (Geography) Value added in v0.9.0

func (g Geography) Value() (driver.Value, error)

type Geometry added in v0.9.0

type Geometry struct {
	Geometry geom.T
	Valid    bool
}

func (Geometry) MarshalJSON added in v0.9.0

func (g Geometry) MarshalJSON() ([]byte, error)

func (Geometry) New added in v0.9.0

func (g Geometry) New(
	v geom.T,
) Geometry

func (Geometry) PostGisValue added in v0.9.0

func (g Geometry) PostGisValue() (Geometry, error)

func (*Geometry) Scan added in v0.9.0

func (g *Geometry) Scan(
	src any,
) error

func (*Geometry) ScanPostGisValue added in v0.9.0

func (g *Geometry) ScanPostGisValue(
	v Geometry,
) error

func (*Geometry) UnmarshalJSON added in v0.9.0

func (g *Geometry) UnmarshalJSON(
	b []byte,
) error

func (Geometry) Value added in v0.9.0

func (g Geometry) Value() (driver.Value, error)

type InsertMessage

type InsertMessage struct {
	*pglogrepl.InsertMessage
	NewValues map[string]any
}

func (InsertMessage) String added in v0.0.12

func (m InsertMessage) String() string

type LSN

type LSN pglogrepl.LSN

func (LSN) String

func (lsn LSN) String() string

type LogicalReplicationMessage

type LogicalReplicationMessage struct {

	// Flags is either 0 (non-transactional) or 1 (transactional)
	Flags uint8
	// Xid is the transaction id (if transactional logical replication message)
	Xid *uint32
	// LSN is the LSN of the logical replication message
	LSN pglogrepl.LSN
	// Prefix is the prefix of the logical replication message
	Prefix string
	// Content is the content of the logical replication message
	Content []byte
	// contains filtered or unexported fields
}

LogicalReplicationMessage is a logical replication message.

func (*LogicalReplicationMessage) Decode

func (m *LogicalReplicationMessage) Decode(
	src []byte,
) (err error)

func (*LogicalReplicationMessage) IsTransactional

func (m *LogicalReplicationMessage) IsTransactional() bool

func (*LogicalReplicationMessage) SetType

func (m *LogicalReplicationMessage) SetType(
	t pglogrepl.MessageType,
)

func (*LogicalReplicationMessage) String added in v0.0.12

func (m *LogicalReplicationMessage) String() string

func (*LogicalReplicationMessage) Type

func (m *LogicalReplicationMessage) Type() pglogrepl.MessageType

Type returns message type.

type Ltree added in v0.3.1

type Ltree struct {
	Path  string
	Valid bool
}

func (Ltree) LtreeValue added in v0.3.1

func (l Ltree) LtreeValue() (Ltree, error)

func (Ltree) MarshalJSON added in v0.3.1

func (l Ltree) MarshalJSON() ([]byte, error)

func (*Ltree) Scan added in v0.3.1

func (l *Ltree) Scan(
	src any,
) error

func (*Ltree) ScanLtree added in v0.3.1

func (l *Ltree) ScanLtree(
	v Ltree,
) error

func (*Ltree) UnmarshalJSON added in v0.3.1

func (l *Ltree) UnmarshalJSON(
	b []byte,
) error

func (Ltree) Value added in v0.3.1

func (l Ltree) Value() (driver.Value, error)

type LtreeCodec added in v0.3.1

type LtreeCodec struct{}

func (LtreeCodec) DecodeDatabaseSQLValue added in v0.3.1

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

func (LtreeCodec) DecodeValue added in v0.3.1

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

func (LtreeCodec) FormatSupported added in v0.3.1

func (LtreeCodec) FormatSupported(
	format int16,
) bool

func (LtreeCodec) PlanEncode added in v0.3.1

func (LtreeCodec) PlanEncode(
	_ *pgtype.Map, _ uint32, format int16, value any,
) pgtype.EncodePlan

func (LtreeCodec) PlanScan added in v0.3.1

func (LtreeCodec) PlanScan(
	_ *pgtype.Map, _ uint32, format int16, target any,
) pgtype.ScanPlan

func (LtreeCodec) PreferredFormat added in v0.3.1

func (LtreeCodec) PreferredFormat() int16

type LtreeScanner added in v0.3.1

type LtreeScanner interface {
	ScanLtree(
		v Ltree,
	) error
}

type LtreeValuer added in v0.3.1

type LtreeValuer interface {
	LtreeValue() (Ltree, error)
}

type OriginMessage

type OriginMessage pglogrepl.OriginMessage

func (OriginMessage) String added in v0.0.12

func (m OriginMessage) String() string

type PgCategory added in v0.3.1

type PgCategory string
const (
	Array       PgCategory = "A"
	Boolean     PgCategory = "B"
	Composite   PgCategory = "C"
	DateTime    PgCategory = "D"
	Enum        PgCategory = "E"
	Geometric   PgCategory = "G"
	Network     PgCategory = "I"
	Numeric     PgCategory = "N"
	Pseudo      PgCategory = "P"
	Range       PgCategory = "R"
	String      PgCategory = "S"
	Timespan    PgCategory = "T"
	UserDefined PgCategory = "D"
	BitString   PgCategory = "V"
	Unknown     PgCategory = "X"
	InternalUse PgCategory = "Z"
)

type PgKind added in v0.3.1

type PgKind string
const (
	BaseKind       PgKind = "b"
	CompositeKind  PgKind = "c"
	DomainKind     PgKind = "d"
	EnumKind       PgKind = "e"
	PseudoKind     PgKind = "p"
	RangeKind      PgKind = "r"
	MultiRangeKind PgKind = "m"
)

type PgType added in v0.3.1

type PgType interface {
	schema.Buildable
	Namespace() string
	Name() string
	Kind() PgKind
	Oid() uint32
	Category() PgCategory
	IsArray() bool
	IsRecord() bool
	ArrayType() PgType
	ElementType() PgType
	BaseType() PgType
	OidArray() uint32
	OidElement() uint32
	OidBase() uint32
	Modifiers() int
	EnumValues() []string
	Delimiter() string
	CompositeColumns() ([]CompositeColumn, error)
	SchemaType() schema.Type
	Format() string
	Equal(
		other PgType,
	) bool
}

type PostGisCodec added in v0.9.0

type PostGisCodec[V valuer, S PostGisScanner[V], E PostGisValuer[V]] struct{}

func (PostGisCodec[V, S, E]) DecodeDatabaseSQLValue added in v0.9.0

func (c PostGisCodec[V, S, E]) DecodeDatabaseSQLValue(
	m *pgtype.Map, oid uint32, format int16, src []byte,
) (driver.Value, error)

func (PostGisCodec[V, S, E]) DecodeValue added in v0.9.0

func (c PostGisCodec[V, S, E]) DecodeValue(
	m *pgtype.Map, oid uint32, format int16, src []byte,
) (any, error)

func (PostGisCodec[V, S, E]) FormatSupported added in v0.9.0

func (PostGisCodec[V, S, E]) FormatSupported(
	format int16,
) bool

func (PostGisCodec[V, S, E]) PlanEncode added in v0.9.0

func (PostGisCodec[V, S, E]) PlanEncode(
	_ *pgtype.Map, _ uint32, format int16, value any,
) pgtype.EncodePlan

func (PostGisCodec[V, S, E]) PlanScan added in v0.9.0

func (PostGisCodec[V, S, E]) PlanScan(
	_ *pgtype.Map, _ uint32, format int16, target any,
) pgtype.ScanPlan

func (PostGisCodec[V, S, E]) PreferredFormat added in v0.9.0

func (PostGisCodec[V, S, E]) PreferredFormat() int16

type PostGisScanner added in v0.9.0

type PostGisScanner[T any] interface {
	ScanPostGisValue(T) error
	New(value geom.T) T
}

type PostGisValuer added in v0.9.0

type PostGisValuer[T valuer] interface {
	PostGisValue() (T, error)
}

type RelationMessage

type RelationMessage pglogrepl.RelationMessage

func (RelationMessage) String added in v0.0.12

func (m RelationMessage) String() string

type ReplicaIdentity

type ReplicaIdentity string
const (
	NOTHING ReplicaIdentity = "n"
	FULL    ReplicaIdentity = "f"
	DEFAULT ReplicaIdentity = "d"
	INDEX   ReplicaIdentity = "i"
	UNKNOWN ReplicaIdentity = ""
)

func AsReplicaIdentity

func AsReplicaIdentity(
	val string,
) ReplicaIdentity

func (ReplicaIdentity) Description

func (ri ReplicaIdentity) Description() string

Description returns a description of this REPLICA IDENTITY Values are in sync with debezium project: debezium-connector-postgres/src/main/java/io/debezium/connector/postgresql/connection/ServerInfo.java

func (ReplicaIdentity) Name added in v0.11.0

func (ri ReplicaIdentity) Name() string

func (*ReplicaIdentity) Scan

func (ri *ReplicaIdentity) Scan(
	src interface{},
) error

type RowDecoder added in v0.3.1

type RowDecoder interface {
	DecodeRowsMapAndSink(
		rows pgx.Rows, sink func(values map[string]any) error,
	) error
	DecodeRowsAndSink(
		rows pgx.Rows, sink func(values []any) error,
	) error
	Decode(
		rawRow [][]byte,
	) ([]any, error)
	DecodeAndSink(
		rawRow [][]byte, sink func(values []any) error,
	) error
	DecodeMapAndSink(
		rawRow [][]byte, sink func(values map[string]any) error,
	) error
}

type RowDecoderFactory added in v0.4.0

type RowDecoderFactory = func(fields []pgconn.FieldDescription) (RowDecoder, error)

type Timetz added in v0.3.1

type Timetz struct {
	Time  time.Time
	Valid bool
}

func (Timetz) MarshalJSON added in v0.3.1

func (ttz Timetz) MarshalJSON() ([]byte, error)

func (*Timetz) Scan added in v0.3.1

func (ttz *Timetz) Scan(
	src any,
) error

func (*Timetz) ScanTimetz added in v0.3.1

func (ttz *Timetz) ScanTimetz(
	v Timetz,
) error

func (Timetz) TimetzValue added in v0.3.1

func (ttz Timetz) TimetzValue() (Timetz, error)

func (*Timetz) UnmarshalJSON added in v0.3.1

func (ttz *Timetz) UnmarshalJSON(
	b []byte,
) error

func (Timetz) Value added in v0.3.1

func (ttz Timetz) Value() (driver.Value, error)

type TimetzCodec added in v0.3.1

type TimetzCodec struct{}

func (TimetzCodec) DecodeDatabaseSQLValue added in v0.3.1

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

func (TimetzCodec) DecodeValue added in v0.3.1

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

func (TimetzCodec) FormatSupported added in v0.3.1

func (TimetzCodec) FormatSupported(
	format int16,
) bool

func (TimetzCodec) PlanEncode added in v0.3.1

func (TimetzCodec) PlanEncode(
	_ *pgtype.Map, _ uint32, format int16, value any,
) pgtype.EncodePlan

func (TimetzCodec) PlanScan added in v0.3.1

func (TimetzCodec) PlanScan(
	_ *pgtype.Map, _ uint32, format int16, target any,
) pgtype.ScanPlan

func (TimetzCodec) PreferredFormat added in v0.3.1

func (TimetzCodec) PreferredFormat() int16

type TimetzScanner added in v0.3.1

type TimetzScanner interface {
	ScanTimetz(
		v Timetz,
	) error
}

type TimetzValuer added in v0.3.1

type TimetzValuer interface {
	TimetzValue() (Timetz, error)
}

type TruncateMessage

type TruncateMessage pglogrepl.TruncateMessage

func (TruncateMessage) String added in v0.0.12

func (m TruncateMessage) String() string

type TupleDecoderPlan added in v0.4.0

type TupleDecoderPlan interface {
	Decode(tupleData *pglogrepl.TupleData) (map[string]any, error)
}

type TypeConverter added in v0.4.0

type TypeConverter func(oid uint32, value any) (any, error)

TypeConverter represents a conversion function to convert from a PostgreSQL internal OID number and value to a value according to the stream definition

type TypeFactory added in v0.3.1

type TypeFactory func(namespace, name string, kind PgKind, oid uint32, category PgCategory,
	arrayType bool, recordType bool, oidArray uint32, oidElement uint32, oidBase uint32,
	modifiers int, enumValues []string, delimiter string) PgType

type TypeManager added in v0.3.1

type TypeManager interface {
	ResolveDataType(
		oid uint32,
	) (PgType, error)
	ResolveTypeConverter(
		oid uint32,
	) (TypeConverter, error)
	NumKnownTypes() int
	DecodeTuples(
		relation *RelationMessage, tupleData *pglogrepl.TupleData,
	) (map[string]any, error)
	GetOrPlanTupleDecoder(relation *RelationMessage) (TupleDecoderPlan, error)
	GetOrPlanRowDecoder(fields []pgconn.FieldDescription) (RowDecoder, error)
	RegisterColumnType(column schema.ColumnAlike) error
}

type TypeMessage

type TypeMessage pglogrepl.TypeMessage

func (TypeMessage) String added in v0.0.12

func (m TypeMessage) String() string

type UpdateMessage

type UpdateMessage struct {
	*pglogrepl.UpdateMessage
	OldValues map[string]any
	NewValues map[string]any
}

func (UpdateMessage) String added in v0.0.12

func (m UpdateMessage) String() string

type XLogData

type XLogData struct {
	pglogrepl.XLogData

	DatabaseName string
	LastBegin    LSN
	LastCommit   LSN
	Xid          uint32
}

type Xml added in v0.3.1

type Xml struct {
	Xml   string
	Valid bool
}

func (Xml) MarshalJSON added in v0.3.1

func (x Xml) MarshalJSON() ([]byte, error)

func (*Xml) Scan added in v0.3.1

func (x *Xml) Scan(
	src any,
) error

func (*Xml) ScanXml added in v0.3.1

func (x *Xml) ScanXml(
	v Xml,
) error

func (*Xml) UnmarshalJSON added in v0.3.1

func (x *Xml) UnmarshalJSON(
	b []byte,
) error

func (Xml) Value added in v0.3.1

func (x Xml) Value() (driver.Value, error)

func (Xml) XmlValue added in v0.3.1

func (x Xml) XmlValue() (Xml, error)

type XmlCodec added in v0.3.1

type XmlCodec struct{}

func (XmlCodec) DecodeDatabaseSQLValue added in v0.3.1

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

func (XmlCodec) DecodeValue added in v0.3.1

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

func (XmlCodec) FormatSupported added in v0.3.1

func (XmlCodec) FormatSupported(
	format int16,
) bool

func (XmlCodec) PlanEncode added in v0.3.1

func (XmlCodec) PlanEncode(
	_ *pgtype.Map, _ uint32, format int16, value any,
) pgtype.EncodePlan

func (XmlCodec) PlanScan added in v0.3.1

func (XmlCodec) PlanScan(
	_ *pgtype.Map, _ uint32, format int16, target any,
) pgtype.ScanPlan

func (XmlCodec) PreferredFormat added in v0.3.1

func (XmlCodec) PreferredFormat() int16

type XmlScanner added in v0.3.1

type XmlScanner interface {
	ScanXml(
		v Xml,
	) error
}

type XmlValuer added in v0.3.1

type XmlValuer interface {
	XmlValue() (Xml, error)
}

Jump to

Keyboard shortcuts

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