package pgtype
import "github.com/jackc/pgx/v5/pgtype"
Do not edit. Generated from pgtype/array_getter_setter.go.erb
Package pgtype converts between Go and PostgreSQL values.
The primary type is the Map type. It is a map of PostgreSQL types identified by OID (object ID) to a Codec. A Codec is responsible for converting between Go and PostgreSQL values. NewMap creates a Map with all supported standard PostgreSQL types already registered. Additional types can be registered with Map.RegisterType.
Use Map.Scan and Map.Encode to decode PostgreSQL values to Go and encode Go values to PostgreSQL respectively.
JSON Support
pgtype automatically marshals and unmarshals data from json and jsonb PostgreSQL types.
Array Support
ArrayCodec implements support for arrays. If pgtype supports type T then it can easily support []T by registering an ArrayCodec for the appropriate PostgreSQL OID.
Composite Support
CompositeCodec implements support for PostgreSQL composite types. Go structs can be scanned into if the public fields of the struct are in the exact order and type of the PostgreSQL type or by implementing CompositeIndexScanner and CompositeIndexGetter.
Enum Support
PostgreSQL enums can usually be treated as text. However, EnumCodec implements support for interning strings which can reduce memory usage.
Array, Composite, and Enum Type Registration
Array, composite, and enum types can be easily registered from a pgx.Conn with the LoadType method.
Extending Existing Type Support
Generally, all Codecs will support interfaces that can be implemented to enable scanning and encoding. For example, PointCodec can use any Go type that implements the PointScanner and PointValuer interfaces. So rather than use pgtype.Point and application can directly use its own point type with pgtype as long as it implements those interfaces.
Sometimes pgx supports a PostgreSQL type such as numeric but the Go type is in an external package that does not have pgx support such as github.com/shopspring/decimal. These types can be registered with pgtype with custom conversion logic. See https://github.com/jackc/pgx-shopspring-decimal and https://github.com/jackc/pgx-gofrs-uuid for a example integrations.
Entirely New Type Support
If the PostgreSQL type is not already supported then an OID / Codec mapping can be registered with Map.RegisterType. There is no difference between a Codec defined and registered by the application and a Codec built in to pgtype. See any of the Codecs in pgtype for Codec examples and for examples of type registration.
Encoding Unknown Types
pgtype works best when the OID of the PostgreSQL type is known. But in some cases such as using the simple protocol the OID is unknown. In this case Map.RegisterDefaultPgType can be used to register an assumed OID for a particular Go type.
Overview of Scanning Implementation
The first step is to use the OID to lookup the correct Codec. If the OID is unavailable, Map will try to find the OID from previous calls of Map.RegisterDefaultPgType. The Map will call the Codec's PlanScan method to get a plan for scanning into the Go value. A Codec will support scanning into one or more Go types. Oftentime these Go types are interfaces rather than explicit types. For example, PointCodec can use any Go type that implments the PointScanner and PointValuer interfaces.
If a Go value is not supported directly by a Codec then Map will try wrapping it with additional logic and try again. For example, Int8Codec does not support scanning into a renamed type (e.g. type myInt64 int64). But Map will detect that myInt64 is a renamed type and create a plan that converts the value to the underlying int64 type and then passes that to the Codec (see TryFindUnderlyingTypeScanPlan).
These plan wrappers are contained in Map.TryWrapScanPlanFuncs. By default these contain shared logic to handle renamed types, pointers to pointers, slices, composite types, etc. Additional plan wrappers can be added to seamlessly integrate types that do not support pgx directly. For example, the before mentioned https://github.com/jackc/pgx-shopspring-decimal package detects decimal.Decimal values, wraps them in something implementing NumericScanner and passes that to the Codec.
Map.Scan and Map.Encode are convenience methods that wrap Map.PlanScan and Map.PlanEncode. Determining how to scan or encode a particular type may be a time consuming operation. Hence the planning and execution steps of a conversion are internally separated.
Do not edit. Generated from pgtype/int.go.erb
Do not edit. Generated from pgtype/range_types.go.erb
Index ¶
- Constants
- Variables
- func EncodeTextArrayDimensions(buf []byte, dimensions []ArrayDimension) []byte
- func GetAssignToDstType(dst interface{}) (interface{}, bool)
- func NullAssignTo(dst interface{}) error
- func QuoteArrayElementIfNeeded(src string) string
- type ArrayCodec
- func (c *ArrayCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c *ArrayCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (c *ArrayCodec) FormatSupported(format int16) bool
- func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (c *ArrayCodec) PreferredFormat() int16
- type ArrayDimension
- type ArrayGetter
- type ArrayHeader
- func (dst *ArrayHeader) DecodeBinary(m *Map, src []byte) (int, error)
- func (src ArrayHeader) EncodeBinary(buf []byte) []byte
- type ArraySetter
- type Bits
- func (b Bits) BitsValue() (Bits, error)
- func (dst *Bits) Scan(src interface{}) error
- func (b *Bits) ScanBits(v Bits) error
- func (src Bits) Value() (driver.Value, error)
- type BitsCodec
- func (c BitsCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c BitsCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (BitsCodec) FormatSupported(format int16) bool
- func (BitsCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (BitsCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (BitsCodec) PreferredFormat() int16
- type BitsScanner
- type BitsValuer
- type Bool
- func (b Bool) BoolValue() (Bool, error)
- func (src Bool) MarshalJSON() ([]byte, error)
- func (dst *Bool) Scan(src interface{}) error
- func (b *Bool) ScanBool(v Bool) error
- func (dst *Bool) UnmarshalJSON(b []byte) error
- func (src Bool) Value() (driver.Value, error)
- type BoolCodec
- func (c BoolCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c BoolCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (BoolCodec) FormatSupported(format int16) bool
- func (BoolCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (BoolCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (BoolCodec) PreferredFormat() int16
- type BoolScanner
- type BoolValuer
- type BoundType
- type Box
- func (b Box) BoxValue() (Box, error)
- func (dst *Box) Scan(src interface{}) error
- func (b *Box) ScanBox(v Box) error
- func (src Box) Value() (driver.Value, error)
- type BoxCodec
- func (c BoxCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c BoxCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (BoxCodec) FormatSupported(format int16) bool
- func (BoxCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (BoxCodec) PreferredFormat() int16
- type BoxScanner
- type BoxValuer
- type ByteaCodec
- func (c ByteaCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c ByteaCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (ByteaCodec) FormatSupported(format int16) bool
- func (ByteaCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (ByteaCodec) PreferredFormat() int16
- type BytesScanner
- type BytesValuer
- type Circle
- func (c Circle) CircleValue() (Circle, error)
- func (dst *Circle) Scan(src interface{}) error
- func (c *Circle) ScanCircle(v Circle) error
- func (src Circle) Value() (driver.Value, error)
- type CircleCodec
- func (c CircleCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c CircleCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (CircleCodec) FormatSupported(format int16) bool
- func (CircleCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (CircleCodec) PreferredFormat() int16
- type CircleScanner
- type CircleValuer
- type Codec
- type CompositeBinaryBuilder
- func NewCompositeBinaryBuilder(m *Map, buf []byte) *CompositeBinaryBuilder
- func (b *CompositeBinaryBuilder) AppendValue(oid uint32, field interface{})
- func (b *CompositeBinaryBuilder) Finish() ([]byte, error)
- type CompositeBinaryScanner
- func NewCompositeBinaryScanner(m *Map, src []byte) *CompositeBinaryScanner
- func (cfs *CompositeBinaryScanner) Bytes() []byte
- func (cfs *CompositeBinaryScanner) Err() error
- func (cfs *CompositeBinaryScanner) FieldCount() int
- func (cfs *CompositeBinaryScanner) Next() bool
- func (cfs *CompositeBinaryScanner) OID() uint32
- type CompositeCodec
- func (c *CompositeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (c *CompositeCodec) FormatSupported(format int16) bool
- func (c *CompositeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (c *CompositeCodec) PreferredFormat() int16
- type CompositeCodecField
- type CompositeFields
- func (cf CompositeFields) Index(i int) interface{}
- func (cf CompositeFields) IsNull() bool
- func (cf CompositeFields) ScanIndex(i int) interface{}
- func (cf CompositeFields) ScanNull() error
- func (cf CompositeFields) SkipUnderlyingTypePlan()
- type CompositeIndexGetter
- type CompositeIndexScanner
- type CompositeTextBuilder
- func NewCompositeTextBuilder(m *Map, buf []byte) *CompositeTextBuilder
- func (b *CompositeTextBuilder) AppendValue(oid uint32, field interface{})
- func (b *CompositeTextBuilder) Finish() ([]byte, error)
- type CompositeTextScanner
- func NewCompositeTextScanner(m *Map, src []byte) *CompositeTextScanner
- func (cfs *CompositeTextScanner) Bytes() []byte
- func (cfs *CompositeTextScanner) Err() error
- func (cfs *CompositeTextScanner) Next() bool
- type Date
- func (d Date) DateValue() (Date, error)
- func (src Date) MarshalJSON() ([]byte, error)
- func (dst *Date) Scan(src interface{}) error
- func (d *Date) ScanDate(v Date) error
- func (dst *Date) UnmarshalJSON(b []byte) error
- func (src Date) Value() (driver.Value, error)
- type DateCodec
- func (c DateCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (DateCodec) FormatSupported(format int16) bool
- func (DateCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (DateCodec) PreferredFormat() int16
- type DateScanner
- type DateValuer
- type Daterange
- func (r Daterange) BoundTypes() (lower, upper BoundType)
- func (r Daterange) Bounds() (lower, upper interface{})
- func (r Daterange) IsNull() bool
- func (r *Daterange) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Daterange) ScanNull() error
- func (r *Daterange) SetBoundTypes(lower, upper BoundType) error
- type DriverBytes
- type EncodePlan
- type EnumCodec
- func (c *EnumCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c *EnumCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (EnumCodec) FormatSupported(format int16) bool
- func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (c *EnumCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (EnumCodec) PreferredFormat() int16
- type Float4
- func (f Float4) Float64Value() (Float8, error)
- func (f Float4) Int64Value() (Int8, error)
- func (f *Float4) Scan(src interface{}) error
- func (f *Float4) ScanFloat64(n Float8) error
- func (f *Float4) ScanInt64(n Int8) error
- func (f Float4) Value() (driver.Value, error)
- type Float4Codec
- func (c Float4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c Float4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (Float4Codec) FormatSupported(format int16) bool
- func (Float4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (Float4Codec) PreferredFormat() int16
- type Float64Scanner
- type Float64Valuer
- type Float8
- func (f Float8) Float64Value() (Float8, error)
- func (f Float8) Int64Value() (Int8, error)
- func (f *Float8) Scan(src interface{}) error
- func (f *Float8) ScanFloat64(n Float8) error
- func (f *Float8) ScanInt64(n Int8) error
- func (f Float8) Value() (driver.Value, error)
- type Float8Codec
- func (c Float8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c Float8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (Float8Codec) FormatSupported(format int16) bool
- func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (Float8Codec) PreferredFormat() int16
- type Float8range
- func (r Float8range) BoundTypes() (lower, upper BoundType)
- func (r Float8range) Bounds() (lower, upper interface{})
- func (r Float8range) IsNull() bool
- func (r *Float8range) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Float8range) ScanNull() error
- func (r *Float8range) SetBoundTypes(lower, upper BoundType) error
- type GenericRange
- func (r GenericRange) BoundTypes() (lower, upper BoundType)
- func (r GenericRange) Bounds() (lower, upper interface{})
- func (r GenericRange) IsNull() bool
- func (r *GenericRange) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *GenericRange) ScanNull() error
- func (r *GenericRange) SetBoundTypes(lower, upper BoundType) error
- type Hstore
- func (h Hstore) HstoreValue() (Hstore, error)
- func (h *Hstore) Scan(src interface{}) error
- func (h *Hstore) ScanHstore(v Hstore) error
- func (h Hstore) Value() (driver.Value, error)
- type HstoreCodec
- func (c HstoreCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c HstoreCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (HstoreCodec) FormatSupported(format int16) bool
- func (HstoreCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (HstoreCodec) PreferredFormat() int16
- type HstoreScanner
- type HstoreValuer
- type Inet
- func (inet Inet) InetValue() (Inet, error)
- func (dst *Inet) Scan(src interface{}) error
- func (inet *Inet) ScanInet(v Inet) error
- func (src Inet) Value() (driver.Value, error)
- type InetCodec
- func (c InetCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c InetCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (InetCodec) FormatSupported(format int16) bool
- func (InetCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (InetCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (InetCodec) PreferredFormat() int16
- type InetScanner
- type InetValuer
- type InfinityModifier
- type Int2
- func (n Int2) Int64Value() (Int8, error)
- func (src Int2) MarshalJSON() ([]byte, error)
- func (dst *Int2) Scan(src interface{}) error
- func (dst *Int2) ScanInt64(n Int8) error
- func (dst *Int2) UnmarshalJSON(b []byte) error
- func (src Int2) Value() (driver.Value, error)
- type Int2Codec
- func (c Int2Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c Int2Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (Int2Codec) FormatSupported(format int16) bool
- func (Int2Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (Int2Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (Int2Codec) PreferredFormat() int16
- type Int4
- func (n Int4) Int64Value() (Int8, error)
- func (src Int4) MarshalJSON() ([]byte, error)
- func (dst *Int4) Scan(src interface{}) error
- func (dst *Int4) ScanInt64(n Int8) error
- func (dst *Int4) UnmarshalJSON(b []byte) error
- func (src Int4) Value() (driver.Value, error)
- type Int4Codec
- func (c Int4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c Int4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (Int4Codec) FormatSupported(format int16) bool
- func (Int4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (Int4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (Int4Codec) PreferredFormat() int16
- type Int4range
- func (r Int4range) BoundTypes() (lower, upper BoundType)
- func (r Int4range) Bounds() (lower, upper interface{})
- func (r Int4range) IsNull() bool
- func (r *Int4range) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Int4range) ScanNull() error
- func (r *Int4range) SetBoundTypes(lower, upper BoundType) error
- type Int64Scanner
- type Int64Valuer
- type Int8
- func (n Int8) Int64Value() (Int8, error)
- func (src Int8) MarshalJSON() ([]byte, error)
- func (dst *Int8) Scan(src interface{}) error
- func (dst *Int8) ScanInt64(n Int8) error
- func (dst *Int8) UnmarshalJSON(b []byte) error
- func (src Int8) Value() (driver.Value, error)
- type Int8Codec
- func (c Int8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c Int8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (Int8Codec) FormatSupported(format int16) bool
- func (Int8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (Int8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (Int8Codec) PreferredFormat() int16
- type Int8range
- func (r Int8range) BoundTypes() (lower, upper BoundType)
- func (r Int8range) Bounds() (lower, upper interface{})
- func (r Int8range) IsNull() bool
- func (r *Int8range) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Int8range) ScanNull() error
- func (r *Int8range) SetBoundTypes(lower, upper BoundType) error
- type Interval
- func (interval Interval) IntervalValue() (Interval, error)
- func (interval *Interval) Scan(src interface{}) error
- func (interval *Interval) ScanInterval(v Interval) error
- func (interval Interval) Value() (driver.Value, error)
- type IntervalCodec
- func (c IntervalCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c IntervalCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (IntervalCodec) FormatSupported(format int16) bool
- func (IntervalCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (IntervalCodec) PreferredFormat() int16
- type IntervalScanner
- type IntervalValuer
- type JSONBCodec
- func (c JSONBCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c JSONBCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (JSONBCodec) FormatSupported(format int16) bool
- func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (JSONBCodec) PreferredFormat() int16
- type JSONCodec
- func (c JSONCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c JSONCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (JSONCodec) FormatSupported(format int16) bool
- func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (JSONCodec) PreferredFormat() int16
- type Line
- func (line Line) LineValue() (Line, error)
- func (line *Line) Scan(src interface{}) error
- func (line *Line) ScanLine(v Line) error
- func (line *Line) Set(src interface{}) error
- func (line Line) Value() (driver.Value, error)
- type LineCodec
- func (c LineCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c LineCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (LineCodec) FormatSupported(format int16) bool
- func (LineCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (LineCodec) PreferredFormat() int16
- type LineScanner
- type LineValuer
- type Lseg
- func (lseg Lseg) LsegValue() (Lseg, error)
- func (lseg *Lseg) Scan(src interface{}) error
- func (lseg *Lseg) ScanLseg(v Lseg) error
- func (lseg Lseg) Value() (driver.Value, error)
- type LsegCodec
- func (c LsegCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c LsegCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (LsegCodec) FormatSupported(format int16) bool
- func (LsegCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (LsegCodec) PreferredFormat() int16
- type LsegScanner
- type LsegValuer
- type MacaddrCodec
- func (c MacaddrCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c MacaddrCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (MacaddrCodec) FormatSupported(format int16) bool
- func (MacaddrCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (MacaddrCodec) PreferredFormat() int16
- type Map
- func NewMap() *Map
- func (m *Map) Encode(oid uint32, formatCode int16, value interface{}, buf []byte) (newBuf []byte, err error)
- func (m *Map) FormatCodeForOID(oid uint32) int16
- func (m *Map) PlanEncode(oid uint32, format int16, value interface{}) EncodePlan
- func (m *Map) PlanScan(oid uint32, formatCode int16, target interface{}) ScanPlan
- func (m *Map) RegisterDefaultPgType(value interface{}, name string)
- func (m *Map) RegisterType(t *Type)
- func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst interface{}) error
- func (m *Map) TypeForName(name string) (*Type, bool)
- func (m *Map) TypeForOID(oid uint32) (*Type, bool)
- func (m *Map) TypeForValue(v interface{}) (*Type, bool)
- type Numeric
- func (n Numeric) Float64Value() (Float8, error)
- func (n Numeric) MarshalJSON() ([]byte, error)
- func (n Numeric) NumericValue() (Numeric, error)
- func (n *Numeric) Scan(src interface{}) error
- func (n *Numeric) ScanNumeric(v Numeric) error
- func (n Numeric) Value() (driver.Value, error)
- type NumericCodec
- func (c NumericCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c NumericCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (NumericCodec) FormatSupported(format int16) bool
- func (NumericCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (NumericCodec) PreferredFormat() int16
- type NumericScanner
- type NumericValuer
- type Numrange
- func (r Numrange) BoundTypes() (lower, upper BoundType)
- func (r Numrange) Bounds() (lower, upper interface{})
- func (r Numrange) IsNull() bool
- func (r *Numrange) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Numrange) ScanNull() error
- func (r *Numrange) SetBoundTypes(lower, upper BoundType) error
- type Path
- func (path Path) PathValue() (Path, error)
- func (path *Path) Scan(src interface{}) error
- func (path *Path) ScanPath(v Path) error
- func (path Path) Value() (driver.Value, error)
- type PathCodec
- func (c PathCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c PathCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (PathCodec) FormatSupported(format int16) bool
- func (PathCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (PathCodec) PreferredFormat() int16
- type PathScanner
- type PathValuer
- type Point
- func (src Point) MarshalJSON() ([]byte, error)
- func (p Point) PointValue() (Point, error)
- func (dst *Point) Scan(src interface{}) error
- func (p *Point) ScanPoint(v Point) error
- func (dst *Point) UnmarshalJSON(point []byte) error
- func (src Point) Value() (driver.Value, error)
- type PointCodec
- func (c PointCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c PointCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (PointCodec) FormatSupported(format int16) bool
- func (PointCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (PointCodec) PreferredFormat() int16
- type PointScanner
- type PointValuer
- type Polygon
- func (p Polygon) PolygonValue() (Polygon, error)
- func (p *Polygon) Scan(src interface{}) error
- func (p *Polygon) ScanPolygon(v Polygon) error
- func (p Polygon) Value() (driver.Value, error)
- type PolygonCodec
- func (c PolygonCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c PolygonCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (PolygonCodec) FormatSupported(format int16) bool
- func (PolygonCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (PolygonCodec) PreferredFormat() int16
- type PolygonScanner
- type PolygonValuer
- type PreallocBytes
- type QCharCodec
- func (c QCharCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c QCharCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (QCharCodec) FormatSupported(format int16) bool
- func (QCharCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (QCharCodec) PreferredFormat() int16
- type RangeCodec
- func (c *RangeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c *RangeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (c *RangeCodec) FormatSupported(format int16) bool
- func (c *RangeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (c *RangeCodec) PreferredFormat() int16
- type RangeScanner
- type RangeValuer
- type RecordCodec
- func (RecordCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (RecordCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (RecordCodec) FormatSupported(format int16) bool
- func (RecordCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (RecordCodec) PreferredFormat() int16
- type ScanPlan
- type SkipUnderlyingTypePlanner
- type TID
- func (dst *TID) Scan(src interface{}) error
- func (b *TID) ScanTID(v TID) error
- func (b TID) TIDValue() (TID, error)
- func (src TID) Value() (driver.Value, error)
- type TIDCodec
- func (c TIDCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c TIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (TIDCodec) FormatSupported(format int16) bool
- func (TIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (TIDCodec) PreferredFormat() int16
- type TIDScanner
- type TIDValuer
- type Text
- func (src Text) MarshalJSON() ([]byte, error)
- func (dst *Text) Scan(src interface{}) error
- func (t *Text) ScanText(v Text) error
- func (t Text) TextValue() (Text, error)
- func (dst *Text) UnmarshalJSON(b []byte) error
- func (src Text) Value() (driver.Value, error)
- type TextCodec
- func (c TextCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c TextCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (TextCodec) FormatSupported(format int16) bool
- func (TextCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (TextCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (TextCodec) PreferredFormat() int16
- type TextFormatOnlyCodec
- func (c *TextFormatOnlyCodec) FormatSupported(format int16) bool
- func (TextFormatOnlyCodec) PreferredFormat() int16
- type TextScanner
- type TextValuer
- type Time
- func (t *Time) Scan(src interface{}) error
- func (t *Time) ScanTime(v Time) error
- func (t Time) TimeValue() (Time, error)
- func (t Time) Value() (driver.Value, error)
- type TimeCodec
- func (c TimeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c TimeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (TimeCodec) FormatSupported(format int16) bool
- func (TimeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (TimeCodec) PreferredFormat() int16
- type TimeScanner
- type TimeValuer
- type Timestamp
- func (ts *Timestamp) Scan(src interface{}) error
- func (ts *Timestamp) ScanTimestamp(v Timestamp) error
- func (ts Timestamp) TimestampValue() (Timestamp, error)
- func (ts Timestamp) Value() (driver.Value, error)
- type TimestampCodec
- func (c TimestampCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c TimestampCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (TimestampCodec) FormatSupported(format int16) bool
- func (TimestampCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (TimestampCodec) PreferredFormat() int16
- type TimestampScanner
- type TimestampValuer
- type Timestamptz
- func (tstz Timestamptz) MarshalJSON() ([]byte, error)
- func (tstz *Timestamptz) Scan(src interface{}) error
- func (tstz *Timestamptz) ScanTimestamptz(v Timestamptz) error
- func (tstz Timestamptz) TimestamptzValue() (Timestamptz, error)
- func (tstz *Timestamptz) UnmarshalJSON(b []byte) error
- func (tstz Timestamptz) Value() (driver.Value, error)
- type TimestamptzCodec
- func (c TimestamptzCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c TimestamptzCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (TimestamptzCodec) FormatSupported(format int16) bool
- func (TimestamptzCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (TimestamptzCodec) PreferredFormat() int16
- type TimestamptzScanner
- type TimestamptzValuer
- type TryWrapEncodePlanFunc
- type TryWrapScanPlanFunc
- type Tsrange
- func (r Tsrange) BoundTypes() (lower, upper BoundType)
- func (r Tsrange) Bounds() (lower, upper interface{})
- func (r Tsrange) IsNull() bool
- func (r *Tsrange) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Tsrange) ScanNull() error
- func (r *Tsrange) SetBoundTypes(lower, upper BoundType) error
- type Tstzrange
- func (r Tstzrange) BoundTypes() (lower, upper BoundType)
- func (r Tstzrange) Bounds() (lower, upper interface{})
- func (r Tstzrange) IsNull() bool
- func (r *Tstzrange) ScanBounds() (lowerTarget, upperTarget interface{})
- func (r *Tstzrange) ScanNull() error
- func (r *Tstzrange) SetBoundTypes(lower, upper BoundType) error
- type Type
- type UUID
- func (src UUID) MarshalJSON() ([]byte, error)
- func (dst *UUID) Scan(src interface{}) error
- func (b *UUID) ScanUUID(v UUID) error
- func (b UUID) UUIDValue() (UUID, error)
- func (dst *UUID) UnmarshalJSON(src []byte) error
- func (src UUID) Value() (driver.Value, error)
- type UUIDCodec
- func (c UUIDCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c UUIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (UUIDCodec) FormatSupported(format int16) bool
- func (UUIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (UUIDCodec) PreferredFormat() int16
- type UUIDScanner
- type UUIDValuer
- type Uint32
- func (dst *Uint32) Scan(src interface{}) error
- func (n *Uint32) ScanUint32(v Uint32) error
- func (n Uint32) Uint32Value() (Uint32, error)
- func (src Uint32) Value() (driver.Value, error)
- type Uint32Codec
- func (c Uint32Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
- func (c Uint32Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
- func (Uint32Codec) FormatSupported(format int16) bool
- func (Uint32Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
- func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
- func (Uint32Codec) PreferredFormat() int16
- type Uint32Scanner
- type Uint32Valuer
- type UndecodedBytes
- type UntypedBinaryRange
- type UntypedTextArray
- type UntypedTextRange
- type Vec2
- type WrappedEncodePlanNextSetter
- func TryWrapBuiltinTypeEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapDerefPointerEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapFindUnderlyingTypeEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapMultiDimSliceEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapSliceEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapStructEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
- type WrappedScanPlanNextSetter
- func TryFindUnderlyingTypeScanPlan(dst interface{}) (plan WrappedScanPlanNextSetter, nextDst interface{}, ok bool)
- func TryPointerPointerScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextTarget interface{}, ok bool)
- func TryWrapBuiltinTypeScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextDst interface{}, ok bool)
- func TryWrapPtrMultiDimSliceScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapPtrSliceScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool)
- func TryWrapStructScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool)
Constants ¶
const ( BoolOID = 16 ByteaOID = 17 QCharOID = 18 NameOID = 19 Int8OID = 20 Int2OID = 21 Int4OID = 23 TextOID = 25 OIDOID = 26 TIDOID = 27 XIDOID = 28 CIDOID = 29 JSONOID = 114 JSONArrayOID = 199 PointOID = 600 LsegOID = 601 PathOID = 602 BoxOID = 603 PolygonOID = 604 LineOID = 628 LineArrayOID = 629 CIDROID = 650 CIDRArrayOID = 651 Float4OID = 700 Float8OID = 701 CircleOID = 718 CircleArrayOID = 719 UnknownOID = 705 MacaddrOID = 829 InetOID = 869 BoolArrayOID = 1000 QCharArrayOID = 1003 NameArrayOID = 1003 Int2ArrayOID = 1005 Int4ArrayOID = 1007 TextArrayOID = 1009 TIDArrayOID = 1010 ByteaArrayOID = 1001 XIDArrayOID = 1011 CIDArrayOID = 1012 BPCharArrayOID = 1014 VarcharArrayOID = 1015 Int8ArrayOID = 1016 PointArrayOID = 1017 LsegArrayOID = 1018 PathArrayOID = 1019 BoxArrayOID = 1020 Float4ArrayOID = 1021 Float8ArrayOID = 1022 PolygonArrayOID = 1027 OIDArrayOID = 1028 ACLItemOID = 1033 ACLItemArrayOID = 1034 MacaddrArrayOID = 1040 InetArrayOID = 1041 BPCharOID = 1042 VarcharOID = 1043 DateOID = 1082 TimeOID = 1083 TimestampOID = 1114 TimestampArrayOID = 1115 DateArrayOID = 1182 TimeArrayOID = 1183 TimestamptzOID = 1184 TimestamptzArrayOID = 1185 IntervalOID = 1186 IntervalArrayOID = 1187 NumericArrayOID = 1231 BitOID = 1560 BitArrayOID = 1561 VarbitOID = 1562 VarbitArrayOID = 1563 NumericOID = 1700 RecordOID = 2249 RecordArrayOID = 2287 UUIDOID = 2950 UUIDArrayOID = 2951 JSONBOID = 3802 JSONBArrayOID = 3807 DaterangeOID = 3912 DaterangeArrayOID = 3913 Int4rangeOID = 3904 Int4rangeArrayOID = 3905 NumrangeOID = 3906 NumrangeArrayOID = 3907 TsrangeOID = 3908 TsrangeArrayOID = 3909 TstzrangeOID = 3910 TstzrangeArrayOID = 3911 Int8rangeOID = 3926 Int8rangeArrayOID = 3927 )
PostgreSQL oids for common types
const ( TextFormatCode = 0 BinaryFormatCode = 1 )
PostgreSQL format codes
const ( Inclusive = BoundType('i') Exclusive = BoundType('e') Unbounded = BoundType('U') Empty = BoundType('E') )
Variables ¶
Functions ¶
func EncodeTextArrayDimensions ¶
func EncodeTextArrayDimensions(buf []byte, dimensions []ArrayDimension) []byte
func GetAssignToDstType ¶
func GetAssignToDstType(dst interface{}) (interface{}, bool)
GetAssignToDstType attempts to convert dst to something AssignTo can assign to. If dst is a pointer to pointer it allocates a value and returns the dereferences pointer. If dst is a named type such as *Foo where Foo is type Foo int16, it converts dst to *int16.
GetAssignToDstType returns the converted dst and a bool representing if any change was made.
func NullAssignTo ¶
func NullAssignTo(dst interface{}) error
func QuoteArrayElementIfNeeded ¶
Types ¶
type ArrayCodec ¶
type ArrayCodec struct { ElementType *Type }
ArrayCodec is a codec for any array type.
func (*ArrayCodec) DecodeDatabaseSQLValue ¶
func (c *ArrayCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (*ArrayCodec) DecodeValue ¶
func (*ArrayCodec) FormatSupported ¶
func (c *ArrayCodec) FormatSupported(format int16) bool
func (*ArrayCodec) PlanEncode ¶
func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (*ArrayCodec) PlanScan ¶
func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (*ArrayCodec) PreferredFormat ¶
func (c *ArrayCodec) PreferredFormat() int16
type ArrayDimension ¶
type ArrayGetter ¶
type ArrayGetter interface { // Dimensions returns the array dimensions. If array is nil then nil is returned. Dimensions() []ArrayDimension // Index returns the element at i. Index(i int) interface{} // IndexType returns a non-nil scan target of the type Index will return. This is used by ArrayCodec.PlanEncode. IndexType() interface{} }
ArrayGetter is a type that can be converted into a PostgreSQL array.
type ArrayHeader ¶
type ArrayHeader struct { ContainsNull bool ElementOID uint32 Dimensions []ArrayDimension }
func (*ArrayHeader) DecodeBinary ¶
func (dst *ArrayHeader) DecodeBinary(m *Map, src []byte) (int, error)
func (ArrayHeader) EncodeBinary ¶
func (src ArrayHeader) EncodeBinary(buf []byte) []byte
type ArraySetter ¶
type ArraySetter interface { // SetDimensions prepares the value such that ScanIndex can be called for each element. dimensions may be nil to // indicate a NULL array. If unable to exactly preserve dimensions SetDimensions may return an error or silently // flatten the array dimensions. SetDimensions(dimensions []ArrayDimension) error // ScanIndex returns a value usable as a scan target for i. SetDimensions must be called before ScanIndex. ScanIndex(i int) interface{} // ScanIndexType returns a non-nil scan target of the type ScanIndex will return. This is used by // ArrayCodec.PlanScan. ScanIndexType() interface{} }
ArraySetter is a type can be set from a PostgreSQL array.
type Bits ¶
Bits represents the PostgreSQL bit and varbit types.
func (Bits) BitsValue ¶
func (*Bits) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Bits) ScanBits ¶
func (Bits) Value ¶
Value implements the database/sql/driver Valuer interface.
type BitsCodec ¶
type BitsCodec struct{}
func (BitsCodec) DecodeDatabaseSQLValue ¶
func (c BitsCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (BitsCodec) DecodeValue ¶
func (BitsCodec) FormatSupported ¶
func (BitsCodec) PlanEncode ¶
func (BitsCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (BitsCodec) PlanScan ¶
func (BitsCodec) PreferredFormat ¶
type BitsScanner ¶
type BitsValuer ¶
type Bool ¶
func (Bool) BoolValue ¶
func (Bool) MarshalJSON ¶
func (*Bool) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Bool) ScanBool ¶
func (*Bool) UnmarshalJSON ¶
func (Bool) Value ¶
Value implements the database/sql/driver Valuer interface.
type BoolCodec ¶
type BoolCodec struct{}
func (BoolCodec) DecodeDatabaseSQLValue ¶
func (c BoolCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (BoolCodec) DecodeValue ¶
func (BoolCodec) FormatSupported ¶
func (BoolCodec) PlanEncode ¶
func (BoolCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (BoolCodec) PlanScan ¶
func (BoolCodec) PreferredFormat ¶
type BoolScanner ¶
type BoolValuer ¶
type BoundType ¶
type BoundType byte
func (BoundType) String ¶
type Box ¶
func (Box) BoxValue ¶
func (*Box) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Box) ScanBox ¶
func (Box) Value ¶
Value implements the database/sql/driver Valuer interface.
type BoxCodec ¶
type BoxCodec struct{}
func (BoxCodec) DecodeDatabaseSQLValue ¶
func (c BoxCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (BoxCodec) DecodeValue ¶
func (BoxCodec) FormatSupported ¶
func (BoxCodec) PlanEncode ¶
func (BoxCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (BoxCodec) PlanScan ¶
func (BoxCodec) PreferredFormat ¶
type BoxScanner ¶
type BoxValuer ¶
type ByteaCodec ¶
type ByteaCodec struct{}
func (ByteaCodec) DecodeDatabaseSQLValue ¶
func (c ByteaCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (ByteaCodec) DecodeValue ¶
func (ByteaCodec) FormatSupported ¶
func (ByteaCodec) FormatSupported(format int16) bool
func (ByteaCodec) PlanEncode ¶
func (ByteaCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (ByteaCodec) PlanScan ¶
func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (ByteaCodec) PreferredFormat ¶
func (ByteaCodec) PreferredFormat() int16
type BytesScanner ¶
type BytesScanner interface { // ScanBytes receives a byte slice of driver memory that is only valid until the next database method call. ScanBytes(v []byte) error }
type BytesValuer ¶
type BytesValuer interface { // BytesValue returns a byte slice of the byte data. The caller must not change the returned slice. BytesValue() ([]byte, error) }
type Circle ¶
func (Circle) CircleValue ¶
func (*Circle) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Circle) ScanCircle ¶
func (Circle) Value ¶
Value implements the database/sql/driver Valuer interface.
type CircleCodec ¶
type CircleCodec struct{}
func (CircleCodec) DecodeDatabaseSQLValue ¶
func (c CircleCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (CircleCodec) DecodeValue ¶
func (CircleCodec) FormatSupported ¶
func (CircleCodec) FormatSupported(format int16) bool
func (CircleCodec) PlanEncode ¶
func (CircleCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (CircleCodec) PlanScan ¶
func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (CircleCodec) PreferredFormat ¶
func (CircleCodec) PreferredFormat() int16
type CircleScanner ¶
type CircleValuer ¶
type Codec ¶
type Codec interface { // FormatSupported returns true if the format is supported. FormatSupported(int16) bool // PreferredFormat returns the preferred format. PreferredFormat() int16 // PlanEncode returns an EncodePlan for encoding value into PostgreSQL format for oid and format. If no plan can be // found then nil is returned. PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan // PlanScan returns a ScanPlan for scanning a PostgreSQL value into a destination with the same type as target. If // no plan can be found then nil is returned. PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan // DecodeDatabaseSQLValue returns src decoded into a value compatible with the sql.Scanner interface. DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) // DecodeValue returns src decoded into its default format. DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error) }
A Codec converts between Go and PostgreSQL values.
type CompositeBinaryBuilder ¶
type CompositeBinaryBuilder struct {
// contains filtered or unexported fields
}
func NewCompositeBinaryBuilder ¶
func NewCompositeBinaryBuilder(m *Map, buf []byte) *CompositeBinaryBuilder
func (*CompositeBinaryBuilder) AppendValue ¶
func (b *CompositeBinaryBuilder) AppendValue(oid uint32, field interface{})
func (*CompositeBinaryBuilder) Finish ¶
func (b *CompositeBinaryBuilder) Finish() ([]byte, error)
type CompositeBinaryScanner ¶
type CompositeBinaryScanner struct {
// contains filtered or unexported fields
}
func NewCompositeBinaryScanner ¶
func NewCompositeBinaryScanner(m *Map, src []byte) *CompositeBinaryScanner
NewCompositeBinaryScanner a scanner over a binary encoded composite balue.
func (*CompositeBinaryScanner) Bytes ¶
func (cfs *CompositeBinaryScanner) Bytes() []byte
Bytes returns the bytes of the field most recently read by Scan().
func (*CompositeBinaryScanner) Err ¶
func (cfs *CompositeBinaryScanner) Err() error
Err returns any error encountered by the scanner.
func (*CompositeBinaryScanner) FieldCount ¶
func (cfs *CompositeBinaryScanner) FieldCount() int
func (*CompositeBinaryScanner) Next ¶
func (cfs *CompositeBinaryScanner) Next() bool
Next advances the scanner to the next field. It returns false after the last field is read or an error occurs. After Next returns false, the Err method can be called to check if any errors occurred.
func (*CompositeBinaryScanner) OID ¶
func (cfs *CompositeBinaryScanner) OID() uint32
OID returns the OID of the field most recently read by Scan().
type CompositeCodec ¶
type CompositeCodec struct { Fields []CompositeCodecField }
func (*CompositeCodec) DecodeDatabaseSQLValue ¶
func (c *CompositeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (*CompositeCodec) DecodeValue ¶
func (c *CompositeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (*CompositeCodec) FormatSupported ¶
func (c *CompositeCodec) FormatSupported(format int16) bool
func (*CompositeCodec) PlanEncode ¶
func (c *CompositeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (*CompositeCodec) PlanScan ¶
func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (*CompositeCodec) PreferredFormat ¶
func (c *CompositeCodec) PreferredFormat() int16
type CompositeCodecField ¶
type CompositeFields ¶
type CompositeFields []interface{}
CompositeFields represents the values of a composite value. It can be used as an encoding source or as a scan target. It cannot scan a NULL, but the composite fields can be NULL.
func (CompositeFields) Index ¶
func (cf CompositeFields) Index(i int) interface{}
func (CompositeFields) IsNull ¶
func (cf CompositeFields) IsNull() bool
func (CompositeFields) ScanIndex ¶
func (cf CompositeFields) ScanIndex(i int) interface{}
func (CompositeFields) ScanNull ¶
func (cf CompositeFields) ScanNull() error
func (CompositeFields) SkipUnderlyingTypePlan ¶
func (cf CompositeFields) SkipUnderlyingTypePlan()
type CompositeIndexGetter ¶
type CompositeIndexGetter interface { // IsNull returns true if the value is SQL NULL. IsNull() bool // Index returns the element at i. Index(i int) interface{} }
CompositeIndexGetter is a type accessed by index that can be converted into a PostgreSQL composite.
type CompositeIndexScanner ¶
type CompositeIndexScanner interface { // ScanNull sets the value to SQL NULL. ScanNull() error // ScanIndex returns a value usable as a scan target for i. ScanIndex(i int) interface{} }
CompositeIndexScanner is a type accessed by index that can be scanned from a PostgreSQL composite.
type CompositeTextBuilder ¶
type CompositeTextBuilder struct {
// contains filtered or unexported fields
}
func NewCompositeTextBuilder ¶
func NewCompositeTextBuilder(m *Map, buf []byte) *CompositeTextBuilder
func (*CompositeTextBuilder) AppendValue ¶
func (b *CompositeTextBuilder) AppendValue(oid uint32, field interface{})
func (*CompositeTextBuilder) Finish ¶
func (b *CompositeTextBuilder) Finish() ([]byte, error)
type CompositeTextScanner ¶
type CompositeTextScanner struct {
// contains filtered or unexported fields
}
func NewCompositeTextScanner ¶
func NewCompositeTextScanner(m *Map, src []byte) *CompositeTextScanner
NewCompositeTextScanner a scanner over a text encoded composite value.
func (*CompositeTextScanner) Bytes ¶
func (cfs *CompositeTextScanner) Bytes() []byte
Bytes returns the bytes of the field most recently read by Scan().
func (*CompositeTextScanner) Err ¶
func (cfs *CompositeTextScanner) Err() error
Err returns any error encountered by the scanner.
func (*CompositeTextScanner) Next ¶
func (cfs *CompositeTextScanner) Next() bool
Next advances the scanner to the next field. It returns false after the last field is read or an error occurs. After Next returns false, the Err method can be called to check if any errors occurred.
type Date ¶
type Date struct { Time time.Time InfinityModifier InfinityModifier Valid bool }
func (Date) DateValue ¶
func (Date) MarshalJSON ¶
func (*Date) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Date) ScanDate ¶
func (*Date) UnmarshalJSON ¶
func (Date) Value ¶
Value implements the database/sql/driver Valuer interface.
type DateCodec ¶
type DateCodec struct{}
func (DateCodec) DecodeDatabaseSQLValue ¶
func (c DateCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (DateCodec) DecodeValue ¶
func (DateCodec) FormatSupported ¶
func (DateCodec) PlanEncode ¶
func (DateCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (DateCodec) PlanScan ¶
func (DateCodec) PreferredFormat ¶
type DateScanner ¶
type DateValuer ¶
type Daterange ¶
func (Daterange) BoundTypes ¶
func (Daterange) Bounds ¶
func (r Daterange) Bounds() (lower, upper interface{})
func (Daterange) IsNull ¶
func (*Daterange) ScanBounds ¶
func (r *Daterange) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Daterange) ScanNull ¶
func (*Daterange) SetBoundTypes ¶
type DriverBytes ¶
type DriverBytes []byte
DriverBytes is a byte slice that holds a reference to memory owned by the driver. It is only valid from the time it is scanned until Rows.Next or Rows.Close is called. It is safe to use in a function passed to QueryFunc. It is never safe to use DriverBytes with QueryRow as Row.Scan internally calls Rows.Close before returning.
func (*DriverBytes) ScanBytes ¶
func (b *DriverBytes) ScanBytes(v []byte) error
type EncodePlan ¶
type EncodePlan interface { // Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return // (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data // written. Encode(value interface{}, buf []byte) (newBuf []byte, err error) }
EncodePlan is a precompiled plan to encode a particular type into a particular OID and format.
type EnumCodec ¶
type EnumCodec struct {
// contains filtered or unexported fields
}
EnumCodec is a codec that caches the strings it decodes. If the same string is read multiple times only one copy is allocated. These strings are only garbage collected when the EnumCodec is garbage collected. EnumCodec can be used for any text type not only enums, but it should only be used when there are a small number of possible values.
func (*EnumCodec) DecodeDatabaseSQLValue ¶
func (c *EnumCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (*EnumCodec) DecodeValue ¶
func (EnumCodec) FormatSupported ¶
func (EnumCodec) PlanEncode ¶
func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (*EnumCodec) PlanScan ¶
func (EnumCodec) PreferredFormat ¶
type Float4 ¶
func (Float4) Float64Value ¶
func (Float4) Int64Value ¶
func (*Float4) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Float4) ScanFloat64 ¶
ScanFloat64 implements the Float64Scanner interface.
func (*Float4) ScanInt64 ¶
func (Float4) Value ¶
Value implements the database/sql/driver Valuer interface.
type Float4Codec ¶
type Float4Codec struct{}
func (Float4Codec) DecodeDatabaseSQLValue ¶
func (c Float4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (Float4Codec) DecodeValue ¶
func (Float4Codec) FormatSupported ¶
func (Float4Codec) FormatSupported(format int16) bool
func (Float4Codec) PlanEncode ¶
func (Float4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (Float4Codec) PlanScan ¶
func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (Float4Codec) PreferredFormat ¶
func (Float4Codec) PreferredFormat() int16
type Float64Scanner ¶
type Float64Valuer ¶
type Float8 ¶
func (Float8) Float64Value ¶
func (Float8) Int64Value ¶
func (*Float8) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Float8) ScanFloat64 ¶
ScanFloat64 implements the Float64Scanner interface.
func (*Float8) ScanInt64 ¶
func (Float8) Value ¶
Value implements the database/sql/driver Valuer interface.
type Float8Codec ¶
type Float8Codec struct{}
func (Float8Codec) DecodeDatabaseSQLValue ¶
func (c Float8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (Float8Codec) DecodeValue ¶
func (Float8Codec) FormatSupported ¶
func (Float8Codec) FormatSupported(format int16) bool
func (Float8Codec) PlanEncode ¶
func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (Float8Codec) PlanScan ¶
func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (Float8Codec) PreferredFormat ¶
func (Float8Codec) PreferredFormat() int16
type Float8range ¶
type Float8range struct { Lower Float8 Upper Float8 LowerType BoundType UpperType BoundType Valid bool }
func (Float8range) BoundTypes ¶
func (r Float8range) BoundTypes() (lower, upper BoundType)
func (Float8range) Bounds ¶
func (r Float8range) Bounds() (lower, upper interface{})
func (Float8range) IsNull ¶
func (r Float8range) IsNull() bool
func (*Float8range) ScanBounds ¶
func (r *Float8range) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Float8range) ScanNull ¶
func (r *Float8range) ScanNull() error
func (*Float8range) SetBoundTypes ¶
func (r *Float8range) SetBoundTypes(lower, upper BoundType) error
type GenericRange ¶
type GenericRange struct { Lower interface{} Upper interface{} LowerType BoundType UpperType BoundType Valid bool }
func (GenericRange) BoundTypes ¶
func (r GenericRange) BoundTypes() (lower, upper BoundType)
func (GenericRange) Bounds ¶
func (r GenericRange) Bounds() (lower, upper interface{})
func (GenericRange) IsNull ¶
func (r GenericRange) IsNull() bool
func (*GenericRange) ScanBounds ¶
func (r *GenericRange) ScanBounds() (lowerTarget, upperTarget interface{})
func (*GenericRange) ScanNull ¶
func (r *GenericRange) ScanNull() error
func (*GenericRange) SetBoundTypes ¶
func (r *GenericRange) SetBoundTypes(lower, upper BoundType) error
type Hstore ¶
Hstore represents an hstore column that can be null or have null values associated with its keys.
func (Hstore) HstoreValue ¶
func (*Hstore) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Hstore) ScanHstore ¶
func (Hstore) Value ¶
Value implements the database/sql/driver Valuer interface.
type HstoreCodec ¶
type HstoreCodec struct{}
func (HstoreCodec) DecodeDatabaseSQLValue ¶
func (c HstoreCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (HstoreCodec) DecodeValue ¶
func (HstoreCodec) FormatSupported ¶
func (HstoreCodec) FormatSupported(format int16) bool
func (HstoreCodec) PlanEncode ¶
func (HstoreCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (HstoreCodec) PlanScan ¶
func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (HstoreCodec) PreferredFormat ¶
func (HstoreCodec) PreferredFormat() int16
type HstoreScanner ¶
type HstoreValuer ¶
type Inet ¶
Inet represents both inet and cidr PostgreSQL types.
func (Inet) InetValue ¶
func (*Inet) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Inet) ScanInet ¶
func (Inet) Value ¶
Value implements the database/sql/driver Valuer interface.
type InetCodec ¶
type InetCodec struct{}
func (InetCodec) DecodeDatabaseSQLValue ¶
func (c InetCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (InetCodec) DecodeValue ¶
func (InetCodec) FormatSupported ¶
func (InetCodec) PlanEncode ¶
func (InetCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (InetCodec) PlanScan ¶
func (InetCodec) PreferredFormat ¶
type InetScanner ¶
type InetValuer ¶
type InfinityModifier ¶
type InfinityModifier int8
const ( Infinity InfinityModifier = 1 Finite InfinityModifier = 0 NegativeInfinity InfinityModifier = -Infinity )
func (InfinityModifier) String ¶
func (im InfinityModifier) String() string
type Int2 ¶
func (Int2) Int64Value ¶
func (Int2) MarshalJSON ¶
func (*Int2) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Int2) ScanInt64 ¶
ScanInt64 implements the Int64Scanner interface.
func (*Int2) UnmarshalJSON ¶
func (Int2) Value ¶
Value implements the database/sql/driver Valuer interface.
type Int2Codec ¶
type Int2Codec struct{}
func (Int2Codec) DecodeDatabaseSQLValue ¶
func (c Int2Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (Int2Codec) DecodeValue ¶
func (Int2Codec) FormatSupported ¶
func (Int2Codec) PlanEncode ¶
func (Int2Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (Int2Codec) PlanScan ¶
func (Int2Codec) PreferredFormat ¶
type Int4 ¶
func (Int4) Int64Value ¶
func (Int4) MarshalJSON ¶
func (*Int4) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Int4) ScanInt64 ¶
ScanInt64 implements the Int64Scanner interface.
func (*Int4) UnmarshalJSON ¶
func (Int4) Value ¶
Value implements the database/sql/driver Valuer interface.
type Int4Codec ¶
type Int4Codec struct{}
func (Int4Codec) DecodeDatabaseSQLValue ¶
func (c Int4Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (Int4Codec) DecodeValue ¶
func (Int4Codec) FormatSupported ¶
func (Int4Codec) PlanEncode ¶
func (Int4Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (Int4Codec) PlanScan ¶
func (Int4Codec) PreferredFormat ¶
type Int4range ¶
func (Int4range) BoundTypes ¶
func (Int4range) Bounds ¶
func (r Int4range) Bounds() (lower, upper interface{})
func (Int4range) IsNull ¶
func (*Int4range) ScanBounds ¶
func (r *Int4range) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Int4range) ScanNull ¶
func (*Int4range) SetBoundTypes ¶
type Int64Scanner ¶
type Int64Valuer ¶
type Int8 ¶
func (Int8) Int64Value ¶
func (Int8) MarshalJSON ¶
func (*Int8) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Int8) ScanInt64 ¶
ScanInt64 implements the Int64Scanner interface.
func (*Int8) UnmarshalJSON ¶
func (Int8) Value ¶
Value implements the database/sql/driver Valuer interface.
type Int8Codec ¶
type Int8Codec struct{}
func (Int8Codec) DecodeDatabaseSQLValue ¶
func (c Int8Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (Int8Codec) DecodeValue ¶
func (Int8Codec) FormatSupported ¶
func (Int8Codec) PlanEncode ¶
func (Int8Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (Int8Codec) PlanScan ¶
func (Int8Codec) PreferredFormat ¶
type Int8range ¶
func (Int8range) BoundTypes ¶
func (Int8range) Bounds ¶
func (r Int8range) Bounds() (lower, upper interface{})
func (Int8range) IsNull ¶
func (*Int8range) ScanBounds ¶
func (r *Int8range) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Int8range) ScanNull ¶
func (*Int8range) SetBoundTypes ¶
type Interval ¶
func (Interval) IntervalValue ¶
func (*Interval) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Interval) ScanInterval ¶
func (Interval) Value ¶
Value implements the database/sql/driver Valuer interface.
type IntervalCodec ¶
type IntervalCodec struct{}
func (IntervalCodec) DecodeDatabaseSQLValue ¶
func (c IntervalCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (IntervalCodec) DecodeValue ¶
func (c IntervalCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (IntervalCodec) FormatSupported ¶
func (IntervalCodec) FormatSupported(format int16) bool
func (IntervalCodec) PlanEncode ¶
func (IntervalCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (IntervalCodec) PlanScan ¶
func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (IntervalCodec) PreferredFormat ¶
func (IntervalCodec) PreferredFormat() int16
type IntervalScanner ¶
type IntervalValuer ¶
type JSONBCodec ¶
type JSONBCodec struct{}
func (JSONBCodec) DecodeDatabaseSQLValue ¶
func (c JSONBCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (JSONBCodec) DecodeValue ¶
func (JSONBCodec) FormatSupported ¶
func (JSONBCodec) FormatSupported(format int16) bool
func (JSONBCodec) PlanEncode ¶
func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (JSONBCodec) PlanScan ¶
func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (JSONBCodec) PreferredFormat ¶
func (JSONBCodec) PreferredFormat() int16
type JSONCodec ¶
type JSONCodec struct{}
func (JSONCodec) DecodeDatabaseSQLValue ¶
func (c JSONCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (JSONCodec) DecodeValue ¶
func (JSONCodec) FormatSupported ¶
func (JSONCodec) PlanEncode ¶
func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (JSONCodec) PlanScan ¶
func (JSONCodec) PreferredFormat ¶
type Line ¶
func (Line) LineValue ¶
func (*Line) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Line) ScanLine ¶
func (*Line) Set ¶
func (Line) Value ¶
Value implements the database/sql/driver Valuer interface.
type LineCodec ¶
type LineCodec struct{}
func (LineCodec) DecodeDatabaseSQLValue ¶
func (c LineCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (LineCodec) DecodeValue ¶
func (LineCodec) FormatSupported ¶
func (LineCodec) PlanEncode ¶
func (LineCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (LineCodec) PlanScan ¶
func (LineCodec) PreferredFormat ¶
type LineScanner ¶
type LineValuer ¶
type Lseg ¶
func (Lseg) LsegValue ¶
func (*Lseg) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Lseg) ScanLseg ¶
func (Lseg) Value ¶
Value implements the database/sql/driver Valuer interface.
type LsegCodec ¶
type LsegCodec struct{}
func (LsegCodec) DecodeDatabaseSQLValue ¶
func (c LsegCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (LsegCodec) DecodeValue ¶
func (LsegCodec) FormatSupported ¶
func (LsegCodec) PlanEncode ¶
func (LsegCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (LsegCodec) PlanScan ¶
func (LsegCodec) PreferredFormat ¶
type LsegScanner ¶
type LsegValuer ¶
type MacaddrCodec ¶
type MacaddrCodec struct{}
func (MacaddrCodec) DecodeDatabaseSQLValue ¶
func (c MacaddrCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (MacaddrCodec) DecodeValue ¶
func (c MacaddrCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (MacaddrCodec) FormatSupported ¶
func (MacaddrCodec) FormatSupported(format int16) bool
func (MacaddrCodec) PlanEncode ¶
func (MacaddrCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (MacaddrCodec) PlanScan ¶
func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (MacaddrCodec) PreferredFormat ¶
func (MacaddrCodec) PreferredFormat() int16
type Map ¶
type Map struct { // TryWrapEncodePlanFuncs is a slice of functions that will wrap a value that cannot be encoded by the Codec. Every // time a wrapper is found the PlanEncode method will be recursively called with the new value. This allows several layers of wrappers // to be built up. There are default functions placed in this slice by NewMap(). In most cases these functions // should run last. i.e. Additional functions should typically be prepended not appended. TryWrapEncodePlanFuncs []TryWrapEncodePlanFunc // TryWrapScanPlanFuncs is a slice of functions that will wrap a target that cannot be scanned into by the Codec. Every // time a wrapper is found the PlanScan method will be recursively called with the new target. This allows several layers of wrappers // to be built up. There are default functions placed in this slice by NewMap(). In most cases these functions // should run last. i.e. Additional functions should typically be prepended not appended. TryWrapScanPlanFuncs []TryWrapScanPlanFunc // contains filtered or unexported fields }
Map is the mapping between PostgreSQL server types and Go type handling logic. It can encode values for transmission to a PostgreSQL server and scan received values.
func NewMap ¶
func NewMap() *Map
func (*Map) Encode ¶
func (m *Map) Encode(oid uint32, formatCode int16, value interface{}, buf []byte) (newBuf []byte, err error)
Encode appends the encoded bytes of value to buf. If value is the SQL value NULL then append nothing and return (nil, nil). The caller of Encode is responsible for writing the correct NULL value or the length of the data written.
func (*Map) FormatCodeForOID ¶
FormatCodeForOID returns the preferred format code for type oid. If the type is not registered it returns the text format code.
func (*Map) PlanEncode ¶
func (m *Map) PlanEncode(oid uint32, format int16, value interface{}) EncodePlan
PlanEncode returns an Encode plan for encoding value into PostgreSQL format for oid and format. If no plan can be found then nil is returned.
func (*Map) PlanScan ¶
PlanScan prepares a plan to scan a value into target.
func (*Map) RegisterDefaultPgType ¶
RegisterDefaultPgType registers a mapping of a Go type to a PostgreSQL type name. Typically the data type to be encoded or decoded is determined by the PostgreSQL OID. But if the OID of a value to be encoded or decoded is unknown, this additional mapping will be used by TypeForValue to determine a suitable data type.
func (*Map) RegisterType ¶
func (*Map) Scan ¶
func (*Map) TypeForName ¶
func (*Map) TypeForOID ¶
func (*Map) TypeForValue ¶
TypeForValue finds a data type suitable for v. Use RegisterType to register types that can encode and decode themselves. Use RegisterDefaultPgType to register that can be handled by a registered data type.
type Numeric ¶
type Numeric struct { Int *big.Int Exp int32 NaN bool InfinityModifier InfinityModifier Valid bool }
func (Numeric) Float64Value ¶
func (Numeric) MarshalJSON ¶
func (Numeric) NumericValue ¶
func (*Numeric) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Numeric) ScanNumeric ¶
func (Numeric) Value ¶
Value implements the database/sql/driver Valuer interface.
type NumericCodec ¶
type NumericCodec struct{}
func (NumericCodec) DecodeDatabaseSQLValue ¶
func (c NumericCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (NumericCodec) DecodeValue ¶
func (c NumericCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (NumericCodec) FormatSupported ¶
func (NumericCodec) FormatSupported(format int16) bool
func (NumericCodec) PlanEncode ¶
func (NumericCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (NumericCodec) PlanScan ¶
func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (NumericCodec) PreferredFormat ¶
func (NumericCodec) PreferredFormat() int16
type NumericScanner ¶
type NumericValuer ¶
type Numrange ¶
type Numrange struct { Lower Numeric Upper Numeric LowerType BoundType UpperType BoundType Valid bool }
func (Numrange) BoundTypes ¶
func (Numrange) Bounds ¶
func (r Numrange) Bounds() (lower, upper interface{})
func (Numrange) IsNull ¶
func (*Numrange) ScanBounds ¶
func (r *Numrange) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Numrange) ScanNull ¶
func (*Numrange) SetBoundTypes ¶
type Path ¶
func (Path) PathValue ¶
func (*Path) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Path) ScanPath ¶
func (Path) Value ¶
Value implements the database/sql/driver Valuer interface.
type PathCodec ¶
type PathCodec struct{}
func (PathCodec) DecodeDatabaseSQLValue ¶
func (c PathCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (PathCodec) DecodeValue ¶
func (PathCodec) FormatSupported ¶
func (PathCodec) PlanEncode ¶
func (PathCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (PathCodec) PlanScan ¶
func (PathCodec) PreferredFormat ¶
type PathScanner ¶
type PathValuer ¶
type Point ¶
func (Point) MarshalJSON ¶
func (Point) PointValue ¶
func (*Point) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Point) ScanPoint ¶
func (*Point) UnmarshalJSON ¶
func (Point) Value ¶
Value implements the database/sql/driver Valuer interface.
type PointCodec ¶
type PointCodec struct{}
func (PointCodec) DecodeDatabaseSQLValue ¶
func (c PointCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (PointCodec) DecodeValue ¶
func (PointCodec) FormatSupported ¶
func (PointCodec) FormatSupported(format int16) bool
func (PointCodec) PlanEncode ¶
func (PointCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (PointCodec) PlanScan ¶
func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (PointCodec) PreferredFormat ¶
func (PointCodec) PreferredFormat() int16
type PointScanner ¶
type PointValuer ¶
type Polygon ¶
func (Polygon) PolygonValue ¶
func (*Polygon) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Polygon) ScanPolygon ¶
func (Polygon) Value ¶
Value implements the database/sql/driver Valuer interface.
type PolygonCodec ¶
type PolygonCodec struct{}
func (PolygonCodec) DecodeDatabaseSQLValue ¶
func (c PolygonCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (PolygonCodec) DecodeValue ¶
func (c PolygonCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (PolygonCodec) FormatSupported ¶
func (PolygonCodec) FormatSupported(format int16) bool
func (PolygonCodec) PlanEncode ¶
func (PolygonCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (PolygonCodec) PlanScan ¶
func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (PolygonCodec) PreferredFormat ¶
func (PolygonCodec) PreferredFormat() int16
type PolygonScanner ¶
type PolygonValuer ¶
type PreallocBytes ¶
type PreallocBytes []byte
PreallocBytes is a byte slice of preallocated memory that scanned bytes will be copied to. If it is too small a new slice will be allocated.
func (*PreallocBytes) ScanBytes ¶
func (b *PreallocBytes) ScanBytes(v []byte) error
type QCharCodec ¶
type QCharCodec struct{}
QCharCodec is for PostgreSQL's special 8-bit-only "char" type more akin to the C language's char type, or Go's byte type. (Note that the name in PostgreSQL itself is "char", in double-quotes, and not char.) It gets used a lot in PostgreSQL's system tables to hold a single ASCII character value (eg pg_class.relkind). It is named Qchar for quoted char to disambiguate from SQL standard type char.
func (QCharCodec) DecodeDatabaseSQLValue ¶
func (c QCharCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (QCharCodec) DecodeValue ¶
func (QCharCodec) FormatSupported ¶
func (QCharCodec) FormatSupported(format int16) bool
func (QCharCodec) PlanEncode ¶
func (QCharCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (QCharCodec) PlanScan ¶
func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (QCharCodec) PreferredFormat ¶
func (QCharCodec) PreferredFormat() int16
type RangeCodec ¶
type RangeCodec struct { ElementType *Type }
RangeCodec is a codec for any range type.
func (*RangeCodec) DecodeDatabaseSQLValue ¶
func (c *RangeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (*RangeCodec) DecodeValue ¶
func (*RangeCodec) FormatSupported ¶
func (c *RangeCodec) FormatSupported(format int16) bool
func (*RangeCodec) PlanEncode ¶
func (c *RangeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (*RangeCodec) PlanScan ¶
func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (*RangeCodec) PreferredFormat ¶
func (c *RangeCodec) PreferredFormat() int16
type RangeScanner ¶
type RangeScanner interface { // ScanNull sets the value to SQL NULL. ScanNull() error // ScanBounds returns values usable as a scan target. The returned values may not be scanned if the range is empty or // the bound type is unbounded. ScanBounds() (lowerTarget, upperTarget interface{}) // SetBoundTypes sets the lower and upper bound types. ScanBounds will be called and the returned values scanned // (if appropriate) before SetBoundTypes is called. If the bound types are unbounded or empty this method must // also set the bound values. SetBoundTypes(lower, upper BoundType) error }
RangeScanner is a type can be scanned from a PostgreSQL range.
type RangeValuer ¶
type RangeValuer interface { // IsNull returns true if the value is SQL NULL. IsNull() bool // BoundTypes returns the lower and upper bound types. BoundTypes() (lower, upper BoundType) // Bounds returns the lower and upper range values. Bounds() (lower, upper interface{}) }
RangeValuer is a type that can be converted into a PostgreSQL range.
type RecordCodec ¶
type RecordCodec struct{}
RecordCodec is a codec for the generic PostgreSQL record type such as is created with the "row" function. Record can only decode the binary format. The text format output format from PostgreSQL does not include type information and is therefore impossible to decode. Encoding is impossible because PostgreSQL does not support input of generic records.
func (RecordCodec) DecodeDatabaseSQLValue ¶
func (RecordCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (RecordCodec) DecodeValue ¶
func (RecordCodec) FormatSupported ¶
func (RecordCodec) FormatSupported(format int16) bool
func (RecordCodec) PlanEncode ¶
func (RecordCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (RecordCodec) PlanScan ¶
func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (RecordCodec) PreferredFormat ¶
func (RecordCodec) PreferredFormat() int16
type ScanPlan ¶
type ScanPlan interface { // Scan scans src into target. Scan(src []byte, target interface{}) error }
ScanPlan is a precompiled plan to scan into a type of destination.
type SkipUnderlyingTypePlanner ¶
type SkipUnderlyingTypePlanner interface {
SkipUnderlyingTypePlan()
}
SkipUnderlyingTypePlanner prevents PlanScan and PlanDecode from trying to use the underlying type.
type TID ¶
TID is PostgreSQL's Tuple Identifier type.
When one does
select ctid, * from some_table;
it is the data type of the ctid hidden system column.
It is currently implemented as a pair unsigned two byte integers. Its conversion functions can be found in src/backend/utils/adt/tid.c in the PostgreSQL sources.
func (*TID) Scan ¶
Scan implements the database/sql Scanner interface.
func (*TID) ScanTID ¶
func (TID) TIDValue ¶
func (TID) Value ¶
Value implements the database/sql/driver Valuer interface.
type TIDCodec ¶
type TIDCodec struct{}
func (TIDCodec) DecodeDatabaseSQLValue ¶
func (c TIDCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (TIDCodec) DecodeValue ¶
func (TIDCodec) FormatSupported ¶
func (TIDCodec) PlanEncode ¶
func (TIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (TIDCodec) PlanScan ¶
func (TIDCodec) PreferredFormat ¶
type TIDScanner ¶
type TIDValuer ¶
type Text ¶
func (Text) MarshalJSON ¶
func (*Text) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Text) ScanText ¶
func (Text) TextValue ¶
func (*Text) UnmarshalJSON ¶
func (Text) Value ¶
Value implements the database/sql/driver Valuer interface.
type TextCodec ¶
type TextCodec struct{}
func (TextCodec) DecodeDatabaseSQLValue ¶
func (c TextCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (TextCodec) DecodeValue ¶
func (TextCodec) FormatSupported ¶
func (TextCodec) PlanEncode ¶
func (TextCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (TextCodec) PlanScan ¶
func (TextCodec) PreferredFormat ¶
type TextFormatOnlyCodec ¶
type TextFormatOnlyCodec struct { Codec }
func (*TextFormatOnlyCodec) FormatSupported ¶
func (c *TextFormatOnlyCodec) FormatSupported(format int16) bool
func (TextFormatOnlyCodec) PreferredFormat ¶
func (TextFormatOnlyCodec) PreferredFormat() int16
type TextScanner ¶
type TextValuer ¶
type Time ¶
Time represents the PostgreSQL time type. The PostgreSQL time is a time of day without time zone.
Time is represented as the number of microseconds since midnight in the same way that PostgreSQL does. Other time and date types in pgtype can use time.Time as the underlying representation. However, pgtype.Time type cannot due to needing to handle 24:00:00. time.Time converts that to 00:00:00 on the following day.
func (*Time) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Time) ScanTime ¶
func (Time) TimeValue ¶
func (Time) Value ¶
Value implements the database/sql/driver Valuer interface.
type TimeCodec ¶
type TimeCodec struct{}
func (TimeCodec) DecodeDatabaseSQLValue ¶
func (c TimeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (TimeCodec) DecodeValue ¶
func (TimeCodec) FormatSupported ¶
func (TimeCodec) PlanEncode ¶
func (TimeCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (TimeCodec) PlanScan ¶
func (TimeCodec) PreferredFormat ¶
type TimeScanner ¶
type TimeValuer ¶
type Timestamp ¶
type Timestamp struct { Time time.Time // Time zone will be ignored when encoding to PostgreSQL. InfinityModifier InfinityModifier Valid bool }
Timestamp represents the PostgreSQL timestamp type.
func (*Timestamp) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Timestamp) ScanTimestamp ¶
func (Timestamp) TimestampValue ¶
func (Timestamp) Value ¶
Value implements the database/sql/driver Valuer interface.
type TimestampCodec ¶
type TimestampCodec struct{}
func (TimestampCodec) DecodeDatabaseSQLValue ¶
func (c TimestampCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (TimestampCodec) DecodeValue ¶
func (c TimestampCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (TimestampCodec) FormatSupported ¶
func (TimestampCodec) FormatSupported(format int16) bool
func (TimestampCodec) PlanEncode ¶
func (TimestampCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (TimestampCodec) PlanScan ¶
func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (TimestampCodec) PreferredFormat ¶
func (TimestampCodec) PreferredFormat() int16
type TimestampScanner ¶
type TimestampValuer ¶
type Timestamptz ¶
type Timestamptz struct { Time time.Time InfinityModifier InfinityModifier Valid bool }
Timestamptz represents the PostgreSQL timestamptz type.
func (Timestamptz) MarshalJSON ¶
func (tstz Timestamptz) MarshalJSON() ([]byte, error)
func (*Timestamptz) Scan ¶
func (tstz *Timestamptz) Scan(src interface{}) error
Scan implements the database/sql Scanner interface.
func (*Timestamptz) ScanTimestamptz ¶
func (tstz *Timestamptz) ScanTimestamptz(v Timestamptz) error
func (Timestamptz) TimestamptzValue ¶
func (tstz Timestamptz) TimestamptzValue() (Timestamptz, error)
func (*Timestamptz) UnmarshalJSON ¶
func (tstz *Timestamptz) UnmarshalJSON(b []byte) error
func (Timestamptz) Value ¶
func (tstz Timestamptz) Value() (driver.Value, error)
Value implements the database/sql/driver Valuer interface.
type TimestamptzCodec ¶
type TimestamptzCodec struct{}
func (TimestamptzCodec) DecodeDatabaseSQLValue ¶
func (c TimestamptzCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (TimestamptzCodec) DecodeValue ¶
func (c TimestamptzCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (interface{}, error)
func (TimestamptzCodec) FormatSupported ¶
func (TimestamptzCodec) FormatSupported(format int16) bool
func (TimestamptzCodec) PlanEncode ¶
func (TimestamptzCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (TimestamptzCodec) PlanScan ¶
func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (TimestamptzCodec) PreferredFormat ¶
func (TimestamptzCodec) PreferredFormat() int16
type TimestamptzScanner ¶
type TimestamptzScanner interface { ScanTimestamptz(v Timestamptz) error }
type TimestamptzValuer ¶
type TimestamptzValuer interface { TimestamptzValue() (Timestamptz, error) }
type TryWrapEncodePlanFunc ¶
type TryWrapEncodePlanFunc func(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
TryWrapEncodePlanFunc is a function that tries to create a wrapper plan for value. If successful it returns a plan that will convert the value passed to Encode and then call the next plan. nextValue is value as it will be converted by plan. It must be used to find another suitable EncodePlan. When it is found SetNext must be called on plan for it to be usabled. ok indicates if a suitable wrapper was found.
type TryWrapScanPlanFunc ¶
type TryWrapScanPlanFunc func(target interface{}) (plan WrappedScanPlanNextSetter, nextTarget interface{}, ok bool)
TryWrapScanPlanFunc is a function that tries to create a wrapper plan for target. If successful it returns a plan that will convert the target passed to Scan and then call the next plan. nextTarget is target as it will be converted by plan. It must be used to find another suitable ScanPlan. When it is found SetNext must be called on plan for it to be usabled. ok indicates if a suitable wrapper was found.
type Tsrange ¶
type Tsrange struct { Lower Timestamp Upper Timestamp LowerType BoundType UpperType BoundType Valid bool }
func (Tsrange) BoundTypes ¶
func (Tsrange) Bounds ¶
func (r Tsrange) Bounds() (lower, upper interface{})
func (Tsrange) IsNull ¶
func (*Tsrange) ScanBounds ¶
func (r *Tsrange) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Tsrange) ScanNull ¶
func (*Tsrange) SetBoundTypes ¶
type Tstzrange ¶
type Tstzrange struct { Lower Timestamptz Upper Timestamptz LowerType BoundType UpperType BoundType Valid bool }
func (Tstzrange) BoundTypes ¶
func (Tstzrange) Bounds ¶
func (r Tstzrange) Bounds() (lower, upper interface{})
func (Tstzrange) IsNull ¶
func (*Tstzrange) ScanBounds ¶
func (r *Tstzrange) ScanBounds() (lowerTarget, upperTarget interface{})
func (*Tstzrange) ScanNull ¶
func (*Tstzrange) SetBoundTypes ¶
type Type ¶
type UUID ¶
func (UUID) MarshalJSON ¶
func (*UUID) Scan ¶
Scan implements the database/sql Scanner interface.
func (*UUID) ScanUUID ¶
func (UUID) UUIDValue ¶
func (*UUID) UnmarshalJSON ¶
func (UUID) Value ¶
Value implements the database/sql/driver Valuer interface.
type UUIDCodec ¶
type UUIDCodec struct{}
func (UUIDCodec) DecodeDatabaseSQLValue ¶
func (c UUIDCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (UUIDCodec) DecodeValue ¶
func (UUIDCodec) FormatSupported ¶
func (UUIDCodec) PlanEncode ¶
func (UUIDCodec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (UUIDCodec) PlanScan ¶
func (UUIDCodec) PreferredFormat ¶
type UUIDScanner ¶
type UUIDValuer ¶
type Uint32 ¶
Uint32 is the core type that is used to represent PostgreSQL types such as OID, CID, and XID.
func (*Uint32) Scan ¶
Scan implements the database/sql Scanner interface.
func (*Uint32) ScanUint32 ¶
func (Uint32) Uint32Value ¶
func (Uint32) Value ¶
Value implements the database/sql/driver Valuer interface.
type Uint32Codec ¶
type Uint32Codec struct{}
func (Uint32Codec) DecodeDatabaseSQLValue ¶
func (c Uint32Codec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
func (Uint32Codec) DecodeValue ¶
func (Uint32Codec) FormatSupported ¶
func (Uint32Codec) FormatSupported(format int16) bool
func (Uint32Codec) PlanEncode ¶
func (Uint32Codec) PlanEncode(m *Map, oid uint32, format int16, value interface{}) EncodePlan
func (Uint32Codec) PlanScan ¶
func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target interface{}) ScanPlan
func (Uint32Codec) PreferredFormat ¶
func (Uint32Codec) PreferredFormat() int16
type Uint32Scanner ¶
type Uint32Valuer ¶
type UndecodedBytes ¶
type UndecodedBytes []byte
UndecodedBytes can be used as a scan target to get the raw bytes from PostgreSQL without any decoding.
type UntypedBinaryRange ¶
type UntypedBinaryRange struct { Lower []byte Upper []byte LowerType BoundType UpperType BoundType }
func ParseUntypedBinaryRange ¶
func ParseUntypedBinaryRange(src []byte) (*UntypedBinaryRange, error)
type UntypedTextArray ¶
type UntypedTextArray struct { Elements []string Quoted []bool Dimensions []ArrayDimension }
func ParseUntypedTextArray ¶
func ParseUntypedTextArray(src string) (*UntypedTextArray, error)
type UntypedTextRange ¶
func ParseUntypedTextRange ¶
func ParseUntypedTextRange(src string) (*UntypedTextRange, error)
type Vec2 ¶
type WrappedEncodePlanNextSetter ¶
type WrappedEncodePlanNextSetter interface { SetNext(EncodePlan) EncodePlan }
func TryWrapBuiltinTypeEncodePlan ¶
func TryWrapBuiltinTypeEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
TryWrapBuiltinTypeEncodePlan tries to wrap a builtin type with a wrapper that provides additional methods. e.g. If value was of type int32 then a wrapper plan would be returned that converts value to a type that implements Int64Valuer.
func TryWrapDerefPointerEncodePlan ¶
func TryWrapDerefPointerEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
TryWrapDerefPointerEncodePlan tries to dereference a pointer. e.g. If value was of type *string then a wrapper plan would be returned that derefences the value.
func TryWrapFindUnderlyingTypeEncodePlan ¶
func TryWrapFindUnderlyingTypeEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
TryWrapFindUnderlyingTypeEncodePlan tries to convert to a Go builtin type. e.g. If value was of type MyString and MyString was defined as a string then a wrapper plan would be returned that converts MyString to string.
func TryWrapMultiDimSliceEncodePlan ¶
func TryWrapMultiDimSliceEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
func TryWrapSliceEncodePlan ¶
func TryWrapSliceEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
func TryWrapStructEncodePlan ¶
func TryWrapStructEncodePlan(value interface{}) (plan WrappedEncodePlanNextSetter, nextValue interface{}, ok bool)
TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter.
type WrappedScanPlanNextSetter ¶
func TryFindUnderlyingTypeScanPlan ¶
func TryFindUnderlyingTypeScanPlan(dst interface{}) (plan WrappedScanPlanNextSetter, nextDst interface{}, ok bool)
TryFindUnderlyingTypeScanPlan tries to convert to a Go builtin type. e.g. If value was of type MyString and MyString was defined as a string then a wrapper plan would be returned that converts MyString to string.
func TryPointerPointerScanPlan ¶
func TryPointerPointerScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextTarget interface{}, ok bool)
TryPointerPointerScanPlan handles a pointer to a pointer by setting the target to nil for SQL NULL and allocating and scanning for non-NULL.
func TryWrapBuiltinTypeScanPlan ¶
func TryWrapBuiltinTypeScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextDst interface{}, ok bool)
TryWrapBuiltinTypeScanPlan tries to wrap a builtin type with a wrapper that provides additional methods. e.g. If value was of type int32 then a wrapper plan would be returned that converts target to a value that implements Int64Scanner.
func TryWrapPtrMultiDimSliceScanPlan ¶
func TryWrapPtrMultiDimSliceScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool)
TryWrapPtrMultiDimSliceScanPlan tries to wrap a pointer to a multi-dimension slice.
func TryWrapPtrSliceScanPlan ¶
func TryWrapPtrSliceScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool)
TryWrapPtrSliceScanPlan tries to wrap a pointer to a single dimension slice.
func TryWrapStructScanPlan ¶
func TryWrapStructScanPlan(target interface{}) (plan WrappedScanPlanNextSetter, nextValue interface{}, ok bool)
TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter.
Source Files ¶
array.go array_codec.go array_getter_setter.go bits.go bool.go box.go builtin_wrappers.go bytea.go circle.go composite.go convert.go date.go doc.go enum_codec.go float4.go float8.go hstore.go inet.go int.go interval.go json.go jsonb.go line.go lseg.go macaddr.go numeric.go path.go pgtype.go point.go polygon.go qchar.go range.go range_codec.go range_types.go record_codec.go text.go text_format_only_codec.go tid.go time.go timestamp.go timestamptz.go uint32.go uuid.go
Directories ¶
Path | Synopsis |
---|---|
pgtype/testutil | |
pgtype/zeronull | Package zeronull contains types that automatically convert between database NULLs and Go zero values. |
- Version
- v5.0.0-alpha.1
- Published
- Mar 19, 2022
- Platform
- darwin/amd64
- Imports
- 19 packages
- Last checked
- 1 day ago –
Tools for package owners.