...

Package pgtype

import "github.com/jackc/pgx/v5/pgtype"
Overview
Index
Examples
Subdirectories

Overview ▾

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.

Base Type Mapping

pgtype maps between all common base types directly between Go and PostgreSQL. In particular:

Go           PostgreSQL
-----------------------
string        varchar
              text

// Integers are automatically be converted to any other integer type if
// it can be done without overflow or underflow.
int8
int16         smallint
int32         int
int64         bigint
int
uint8
uint16
uint32
uint64
uint

// Floats are strict and do not automatically convert like integers.
float32       float4
float64       float8

time.Time     date
              timestamp
              timestamptz

netip.Addr    inet
netip.Prefix  cidr

[]byte        bytea

Null Values

pgtype can map NULLs in two ways. The first is types that can directly represent NULL such as Int4. They work in a similar fashion to database/sql. The second is to use a pointer to a pointer.

var foo pgtype.Text
var bar *string
err := conn.QueryRow("select foo, bar from widgets where id=$1", 42).Scan(&foo, &bar)
if err != nil {
    return err
}

JSON Support

pgtype automatically marshals and unmarshals data from json and jsonb PostgreSQL types.

Extending Existing PostgreSQL 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.

See example_custom_type_test.go for an example of a custom type for the PostgreSQL point type.

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 example integrations.

New PostgreSQL Type Support

pgtype uses the PostgreSQL OID to determine how to encode or decode a value. pgtype supports array, composite, domain, and enum types. However, any type created in PostgreSQL with CREATE TYPE will receive a new OID. This means that the OID of each new PostgreSQL type must be registered for pgtype to handle values of that type with the correct Codec.

The pgx.Conn LoadType method can return a *Type for array, composite, domain, and enum types by inspecting the database metadata. This *Type can then be registered with Map.RegisterType.

For example, the following function could be called after a connection is established:

func RegisterDataTypes(ctx context.Context, conn *pgx.Conn) error {
  dataTypeNames := []string{
    "foo",
    "_foo",
    "bar",
    "_bar",
  }

  for _, typeName := range dataTypeNames {
    dataType, err := conn.LoadType(ctx, typeName)
    if err != nil {
      return err
    }
    conn.TypeMap().RegisterType(dataType)
  }

  return nil
}

A type cannot be registered unless all types it depends on are already registered. e.g. An array type cannot be registered until its element type is registered.

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. In addition, Array[T] type can support multi-dimensional arrays.

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.

Domain types are treated as their underlying type if the underlying type and the domain type are registered.

PostgreSQL enums can usually be treated as text. However, EnumCodec implements support for interning strings which can reduce memory usage.

While pgtype will often still work with unregistered types it is highly recommended that all types be registered due to an improvement in performance and the elimination of certain edge cases.

If an entirely new PostgreSQL type (e.g. PostGIS types) is used then the application or a library can create a new Codec. Then the 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.

Renamed Types

If pgtype does not recognize a type and that type is a renamed simple type simple (e.g. type MyInt32 int32) pgtype acts as if it is the underlying type. It currently cannot automatically detect the underlying type of renamed structs (eg.g. type MyTime time.Time).

Compatibility with database/sql

pgtype also includes support for custom types implementing the database/sql.Scanner and database/sql/driver.Valuer interfaces.

Child Records

pgtype's support for arrays and composite records can be used to load records and their children in a single query. See example_child_records_test.go for an example.

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

Reducing Compiled Binary Size

pgx.QueryExecModeExec and pgx.QueryExecModeSimpleProtocol require the default PostgreSQL type to be registered for each Go type used as a query parameter. By default pgx does this for all supported types and their array variants. If an application does not use those query execution modes or manually registers the default PostgreSQL type for the types it uses as query parameters it can use the build tag nopgxregisterdefaulttypes. This omits the default type registration and reduces the compiled binary size by ~2MB.

Do not edit. Generated from pgtype/int.go.erb

Example (ChildRecords)

This example uses a single query to return parent and child records.

Code:

package pgtype_test

import (
    "context"
    "fmt"
    "os"
    "time"

    "github.com/jackc/pgx/v5"
)

type Player struct {
    Name     string
    Position string
}

type Team struct {
    Name    string
    Players []Player
}

// This example uses a single query to return parent and child records.
func Example_childRecords() {
    ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
    defer cancel()

    conn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
    if err != nil {
        fmt.Printf("Unable to establish connection: %v", err)
        return
    }

    if conn.PgConn().ParameterStatus("crdb_version") != "" {
        // Skip test / example when running on CockroachDB. Since an example can't be skipped fake success instead.
        fmt.Println(`Alpha
  Adam: wing
  Bill: halfback
  Charlie: fullback
Beta
  Don: halfback
  Edgar: halfback
  Frank: fullback`)
        return
    }

    // Setup example schema and data.
    _, err = conn.Exec(ctx, `
create temporary table teams (
    name text primary key
);

create temporary table players (
    name text primary key,
    team_name text,
    position text
);

insert into teams (name) values
    ('Alpha'),
    ('Beta');

insert into players (name, team_name, position) values
    ('Adam', 'Alpha', 'wing'),
    ('Bill', 'Alpha', 'halfback'),
    ('Charlie', 'Alpha', 'fullback'),
    ('Don', 'Beta', 'halfback'),
    ('Edgar', 'Beta', 'halfback'),
    ('Frank', 'Beta', 'fullback')
`)
    if err != nil {
        fmt.Printf("Unable to setup example schema and data: %v", err)
        return
    }

    rows, _ := conn.Query(ctx, `
select t.name,
    (select array_agg(row(p.name, position) order by p.name) from players p where p.team_name = t.name)
from teams t
order by t.name
`)
    teams, err := pgx.CollectRows(rows, pgx.RowToStructByPos[Team])
    if err != nil {
        fmt.Printf("CollectRows error: %v", err)
        return
    }

    for _, team := range teams {
        fmt.Println(team.Name)
        for _, player := range team.Players {
            fmt.Printf("  %s: %s\n", player.Name, player.Position)
        }
    }

    // Output:
    // Alpha
    //   Adam: wing
    //   Bill: halfback
    //   Charlie: fullback
    // Beta
    //   Don: halfback
    //   Edgar: halfback
    //   Frank: fullback
}

Example (CustomType)

Code:

package pgtype_test

import (
    "context"
    "fmt"
    "os"

    "github.com/jackc/pgx/v5"
    "github.com/jackc/pgx/v5/pgtype"
)

// Point represents a point that may be null.
type Point struct {
    X, Y  float32 // Coordinates of point
    Valid bool
}

func (p *Point) ScanPoint(v pgtype.Point) error {
    *p = Point{
        X:     float32(v.P.X),
        Y:     float32(v.P.Y),
        Valid: v.Valid,
    }
    return nil
}

func (p Point) PointValue() (pgtype.Point, error) {
    return pgtype.Point{
        P:     pgtype.Vec2{X: float64(p.X), Y: float64(p.Y)},
        Valid: true,
    }, nil
}

func (src *Point) String() string {
    if !src.Valid {
        return "null point"
    }

    return fmt.Sprintf("%.1f, %.1f", src.X, src.Y)
}

func Example_customType() {
    conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
    if err != nil {
        fmt.Printf("Unable to establish connection: %v", err)
        return
    }
    defer conn.Close(context.Background())

    if conn.PgConn().ParameterStatus("crdb_version") != "" {
        // Skip test / example when running on CockroachDB which doesn't support the point type. Since an example can't be
        // skipped fake success instead.
        fmt.Println("null point")
        fmt.Println("1.5, 2.5")
        return
    }

    p := &Point{}
    err = conn.QueryRow(context.Background(), "select null::point").Scan(p)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(p)

    err = conn.QueryRow(context.Background(), "select point(1.5,2.5)").Scan(p)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(p)
    // Output:
    // null point
    // 1.5, 2.5
}

Example (Json)

Code:

conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
if err != nil {
    fmt.Printf("Unable to establish connection: %v", err)
    return
}

type person struct {
    Name string `json:"name"`
    Age  int    `json:"age"`
}

input := person{
    Name: "John",
    Age:  42,
}

var output person

err = conn.QueryRow(context.Background(), "select $1::json", input).Scan(&output)
if err != nil {
    fmt.Println(err)
    return
}

fmt.Println(output.Name, output.Age)

Output:

John 42

Index ▾

Constants
Variables
func GetAssignToDstType(dst any) (any, bool)
func NullAssignTo(dst any) error
type Array
    func (a Array[T]) Dimensions() []ArrayDimension
    func (a Array[T]) Index(i int) any
    func (a Array[T]) IndexType() any
    func (a Array[T]) ScanIndex(i int) any
    func (a Array[T]) ScanIndexType() any
    func (a *Array[T]) SetDimensions(dimensions []ArrayDimension) error
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) (any, error)
    func (c *ArrayCodec) FormatSupported(format int16) bool
    func (c *ArrayCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (c *ArrayCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (c *ArrayCodec) PreferredFormat() int16
type ArrayDimension
type ArrayGetter
type ArraySetter
type Bits
    func (b Bits) BitsValue() (Bits, error)
    func (dst *Bits) Scan(src any) 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) (any, error)
    func (BitsCodec) FormatSupported(format int16) bool
    func (BitsCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (BitsCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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 any) 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) (any, error)
    func (BoolCodec) FormatSupported(format int16) bool
    func (BoolCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (BoolCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (BoolCodec) PreferredFormat() int16
type BoolScanner
type BoolValuer
type BoundType
    func (bt BoundType) String() string
type Box
    func (b Box) BoxValue() (Box, error)
    func (dst *Box) Scan(src any) 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) (any, error)
    func (BoxCodec) FormatSupported(format int16) bool
    func (BoxCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (BoxCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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) (any, error)
    func (ByteaCodec) FormatSupported(format int16) bool
    func (ByteaCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (ByteaCodec) PreferredFormat() int16
type BytesScanner
type BytesValuer
type Circle
    func (c Circle) CircleValue() (Circle, error)
    func (dst *Circle) Scan(src any) 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) (any, error)
    func (CircleCodec) FormatSupported(format int16) bool
    func (CircleCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (CircleCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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 any)
    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) (any, error)
    func (c *CompositeCodec) FormatSupported(format int16) bool
    func (c *CompositeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (c *CompositeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (c *CompositeCodec) PreferredFormat() int16
type CompositeCodecField
type CompositeFields
    func (cf CompositeFields) Index(i int) any
    func (cf CompositeFields) IsNull() bool
    func (cf CompositeFields) ScanIndex(i int) any
    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 any)
    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 any) 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) (any, error)
    func (DateCodec) FormatSupported(format int16) bool
    func (DateCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (DateCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (DateCodec) PreferredFormat() int16
type DateScanner
type DateValuer
type DriverBytes
    func (b *DriverBytes) ScanBytes(v []byte) error
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) (any, error)
    func (EnumCodec) FormatSupported(format int16) bool
    func (EnumCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (c *EnumCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (EnumCodec) PreferredFormat() int16
type FlatArray
    func (a FlatArray[T]) Dimensions() []ArrayDimension
    func (a FlatArray[T]) Index(i int) any
    func (a FlatArray[T]) IndexType() any
    func (a FlatArray[T]) ScanIndex(i int) any
    func (a FlatArray[T]) ScanIndexType() any
    func (a *FlatArray[T]) SetDimensions(dimensions []ArrayDimension) error
type Float4
    func (f Float4) Float64Value() (Float8, error)
    func (f Float4) Int64Value() (Int8, error)
    func (f Float4) MarshalJSON() ([]byte, error)
    func (f *Float4) Scan(src any) error
    func (f *Float4) ScanFloat64(n Float8) error
    func (f *Float4) ScanInt64(n Int8) error
    func (f *Float4) UnmarshalJSON(b []byte) 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) (any, error)
    func (Float4Codec) FormatSupported(format int16) bool
    func (Float4Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (Float4Codec) PlanScan(m *Map, oid uint32, format int16, target any) 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) MarshalJSON() ([]byte, error)
    func (f *Float8) Scan(src any) error
    func (f *Float8) ScanFloat64(n Float8) error
    func (f *Float8) ScanInt64(n Int8) error
    func (f *Float8) UnmarshalJSON(b []byte) 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) (any, error)
    func (Float8Codec) FormatSupported(format int16) bool
    func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (Float8Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (Float8Codec) PreferredFormat() int16
type Hstore
    func (h Hstore) HstoreValue() (Hstore, error)
    func (h *Hstore) Scan(src any) 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) (any, error)
    func (HstoreCodec) FormatSupported(format int16) bool
    func (HstoreCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (HstoreCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (HstoreCodec) PreferredFormat() int16
type HstoreScanner
type HstoreValuer
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) (any, error)
    func (InetCodec) FormatSupported(format int16) bool
    func (InetCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (InetCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (InetCodec) PreferredFormat() int16
type InfinityModifier
    func (im InfinityModifier) String() string
type Int2
    func (n Int2) Int64Value() (Int8, error)
    func (src Int2) MarshalJSON() ([]byte, error)
    func (dst *Int2) Scan(src any) 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) (any, error)
    func (Int2Codec) FormatSupported(format int16) bool
    func (Int2Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (Int2Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (Int2Codec) PreferredFormat() int16
type Int4
    func (n Int4) Int64Value() (Int8, error)
    func (src Int4) MarshalJSON() ([]byte, error)
    func (dst *Int4) Scan(src any) 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) (any, error)
    func (Int4Codec) FormatSupported(format int16) bool
    func (Int4Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (Int4Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (Int4Codec) PreferredFormat() int16
type Int64Scanner
type Int64Valuer
type Int8
    func (n Int8) Int64Value() (Int8, error)
    func (src Int8) MarshalJSON() ([]byte, error)
    func (dst *Int8) Scan(src any) 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) (any, error)
    func (Int8Codec) FormatSupported(format int16) bool
    func (Int8Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (Int8Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (Int8Codec) PreferredFormat() int16
type Interval
    func (interval Interval) IntervalValue() (Interval, error)
    func (interval *Interval) Scan(src any) 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) (any, error)
    func (IntervalCodec) FormatSupported(format int16) bool
    func (IntervalCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (IntervalCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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) (any, error)
    func (JSONBCodec) FormatSupported(format int16) bool
    func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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) (any, error)
    func (JSONCodec) FormatSupported(format int16) bool
    func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (JSONCodec) PreferredFormat() int16
type Line
    func (line Line) LineValue() (Line, error)
    func (line *Line) Scan(src any) error
    func (line *Line) ScanLine(v Line) error
    func (line *Line) Set(src any) 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) (any, error)
    func (LineCodec) FormatSupported(format int16) bool
    func (LineCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (LineCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (LineCodec) PreferredFormat() int16
type LineScanner
type LineValuer
type Lseg
    func (lseg Lseg) LsegValue() (Lseg, error)
    func (lseg *Lseg) Scan(src any) 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) (any, error)
    func (LsegCodec) FormatSupported(format int16) bool
    func (LsegCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (LsegCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (LsegCodec) PreferredFormat() int16
type LsegScanner
type LsegValuer
type LtreeCodec
    func (l LtreeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
    func (l LtreeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)
    func (l LtreeCodec) FormatSupported(format int16) bool
    func (l LtreeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (l LtreeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (l LtreeCodec) PreferredFormat() int16
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) (any, error)
    func (MacaddrCodec) FormatSupported(format int16) bool
    func (MacaddrCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (MacaddrCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (MacaddrCodec) PreferredFormat() int16
type Map
    func NewMap() *Map
    func (m *Map) Encode(oid uint32, formatCode int16, value any, buf []byte) (newBuf []byte, err error)
    func (m *Map) FormatCodeForOID(oid uint32) int16
    func (m *Map) PlanEncode(oid uint32, format int16, value any) EncodePlan
    func (m *Map) PlanScan(oid uint32, formatCode int16, target any) ScanPlan
    func (m *Map) RegisterDefaultPgType(value any, name string)
    func (m *Map) RegisterType(t *Type)
    func (m *Map) SQLScanner(v any) sql.Scanner
    func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst any) error
    func (m *Map) TypeForName(name string) (*Type, bool)
    func (m *Map) TypeForOID(oid uint32) (*Type, bool)
    func (m *Map) TypeForValue(v any) (*Type, bool)
type Multirange
    func (r Multirange[T]) Index(i int) any
    func (r Multirange[T]) IndexType() any
    func (r Multirange[T]) IsNull() bool
    func (r Multirange[T]) Len() int
    func (r Multirange[T]) ScanIndex(i int) any
    func (r Multirange[T]) ScanIndexType() any
    func (r *Multirange[T]) ScanNull() error
    func (r *Multirange[T]) SetLen(n int) error
type MultirangeCodec
    func (c *MultirangeCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error)
    func (c *MultirangeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)
    func (c *MultirangeCodec) FormatSupported(format int16) bool
    func (c *MultirangeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (c *MultirangeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (c *MultirangeCodec) PreferredFormat() int16
type MultirangeGetter
type MultirangeSetter
type NetipPrefixScanner
type NetipPrefixValuer
type Numeric
    func (n Numeric) Float64Value() (Float8, error)
    func (n Numeric) Int64Value() (Int8, error)
    func (n Numeric) MarshalJSON() ([]byte, error)
    func (n Numeric) NumericValue() (Numeric, error)
    func (n *Numeric) Scan(src any) error
    func (n *Numeric) ScanInt64(v Int8) error
    func (n *Numeric) ScanNumeric(v Numeric) error
    func (n *Numeric) ScanScientific(src string) error
    func (n *Numeric) UnmarshalJSON(src []byte) 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) (any, error)
    func (NumericCodec) FormatSupported(format int16) bool
    func (NumericCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (NumericCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (NumericCodec) PreferredFormat() int16
type NumericScanner
type NumericValuer
type Path
    func (path Path) PathValue() (Path, error)
    func (path *Path) Scan(src any) 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) (any, error)
    func (PathCodec) FormatSupported(format int16) bool
    func (PathCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (PathCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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 any) 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) (any, error)
    func (PointCodec) FormatSupported(format int16) bool
    func (PointCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (PointCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (PointCodec) PreferredFormat() int16
type PointScanner
type PointValuer
type Polygon
    func (p Polygon) PolygonValue() (Polygon, error)
    func (p *Polygon) Scan(src any) 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) (any, error)
    func (PolygonCodec) FormatSupported(format int16) bool
    func (PolygonCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (PolygonCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (PolygonCodec) PreferredFormat() int16
type PolygonScanner
type PolygonValuer
type PreallocBytes
    func (b *PreallocBytes) ScanBytes(v []byte) error
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) (any, error)
    func (QCharCodec) FormatSupported(format int16) bool
    func (QCharCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (QCharCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (QCharCodec) PreferredFormat() int16
type Range
    func (r Range[T]) BoundTypes() (lower, upper BoundType)
    func (r Range[T]) Bounds() (lower, upper any)
    func (r Range[T]) IsNull() bool
    func (r *Range[T]) ScanBounds() (lowerTarget, upperTarget any)
    func (r *Range[T]) ScanNull() error
    func (r *Range[T]) SetBoundTypes(lower, upper BoundType) error
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) (any, error)
    func (c *RangeCodec) FormatSupported(format int16) bool
    func (c *RangeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (c *RangeCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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) (any, error)
    func (RecordCodec) FormatSupported(format int16) bool
    func (RecordCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (RecordCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (RecordCodec) PreferredFormat() int16
type ScanPlan
type SkipUnderlyingTypePlanner
type TID
    func (dst *TID) Scan(src any) 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) (any, error)
    func (TIDCodec) FormatSupported(format int16) bool
    func (TIDCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (TIDCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (TIDCodec) PreferredFormat() int16
type TIDScanner
type TIDValuer
type Text
    func (src Text) MarshalJSON() ([]byte, error)
    func (dst *Text) Scan(src any) 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) (any, error)
    func (TextCodec) FormatSupported(format int16) bool
    func (TextCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (TextCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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 any) 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) (any, error)
    func (TimeCodec) FormatSupported(format int16) bool
    func (TimeCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (TimeCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (TimeCodec) PreferredFormat() int16
type TimeScanner
type TimeValuer
type Timestamp
    func (ts Timestamp) MarshalJSON() ([]byte, error)
    func (ts *Timestamp) Scan(src any) error
    func (ts *Timestamp) ScanTimestamp(v Timestamp) error
    func (ts Timestamp) TimestampValue() (Timestamp, error)
    func (ts *Timestamp) UnmarshalJSON(b []byte) 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) (any, error)
    func (TimestampCodec) FormatSupported(format int16) bool
    func (TimestampCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (TimestampCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (TimestampCodec) PreferredFormat() int16
type TimestampScanner
type TimestampValuer
type Timestamptz
    func (tstz Timestamptz) MarshalJSON() ([]byte, error)
    func (tstz *Timestamptz) Scan(src any) 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) (any, error)
    func (TimestamptzCodec) FormatSupported(format int16) bool
    func (TimestamptzCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (TimestamptzCodec) PreferredFormat() int16
type TimestamptzScanner
type TimestamptzValuer
type TryWrapEncodePlanFunc
type TryWrapScanPlanFunc
type Type
type UUID
    func (src UUID) MarshalJSON() ([]byte, error)
    func (dst *UUID) Scan(src any) 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) (any, error)
    func (UUIDCodec) FormatSupported(format int16) bool
    func (UUIDCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (UUIDCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (UUIDCodec) PreferredFormat() int16
type UUIDScanner
type UUIDValuer
type Uint32
    func (dst *Uint32) Scan(src any) 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) (any, error)
    func (Uint32Codec) FormatSupported(format int16) bool
    func (Uint32Codec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan
    func (Uint32Codec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
    func (Uint32Codec) PreferredFormat() int16
type Uint32Scanner
type Uint32Valuer
type UndecodedBytes
type Vec2
type WrappedEncodePlanNextSetter
    func TryWrapArrayEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
    func TryWrapBuiltinTypeEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
    func TryWrapDerefPointerEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
    func TryWrapFindUnderlyingTypeEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
    func TryWrapMultiDimSliceEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
    func TryWrapSliceEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
    func TryWrapStructEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)
type WrappedScanPlanNextSetter
    func TryFindUnderlyingTypeScanPlan(dst any) (plan WrappedScanPlanNextSetter, nextDst any, ok bool)
    func TryPointerPointerScanPlan(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool)
    func TryWrapBuiltinTypeScanPlan(target any) (plan WrappedScanPlanNextSetter, nextDst any, ok bool)
    func TryWrapPtrArrayScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)
    func TryWrapPtrMultiDimSliceScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)
    func TryWrapPtrSliceScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)
    func TryWrapStructScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)

Package files

array.go array_codec.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 ltree.go macaddr.go multirange.go numeric.go path.go pgtype.go pgtype_default.go point.go polygon.go qchar.go range.go range_codec.go record_codec.go register_default_pg_types.go text.go text_format_only_codec.go tid.go time.go timestamp.go timestamptz.go uint32.go uuid.go

Constants

PostgreSQL oids for common types

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          = 1002
    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
    TimetzOID              = 1266
    TimetzArrayOID         = 1270
    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
    JSONPathOID            = 4072
    JSONPathArrayOID       = 4073
    Int4multirangeOID      = 4451
    NummultirangeOID       = 4532
    TsmultirangeOID        = 4533
    TstzmultirangeOID      = 4534
    DatemultirangeOID      = 4535
    Int8multirangeOID      = 4536
    Int4multirangeArrayOID = 6150
    NummultirangeArrayOID  = 6151
    TsmultirangeArrayOID   = 6152
    TstzmultirangeArrayOID = 6153
    DatemultirangeArrayOID = 6155
    Int8multirangeArrayOID = 6157
)

PostgreSQL format codes

const (
    TextFormatCode   = 0
    BinaryFormatCode = 1
)
const (
    Inclusive = BoundType('i')
    Exclusive = BoundType('e')
    Unbounded = BoundType('U')
    Empty     = BoundType('E')
)

Variables

var ErrScanTargetTypeChanged = errors.New("scan target type changed")

func GetAssignToDstType

func GetAssignToDstType(dst any) (any, 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 any) error

type Array

Array represents a PostgreSQL array for T. It implements the ArrayGetter and ArraySetter interfaces. It preserves PostgreSQL dimensions and custom lower bounds. Use FlatArray if these are not needed.

type Array[T any] struct {
    Elements []T
    Dims     []ArrayDimension
    Valid    bool
}

func (Array[T]) Dimensions

func (a Array[T]) Dimensions() []ArrayDimension

func (Array[T]) Index

func (a Array[T]) Index(i int) any

func (Array[T]) IndexType

func (a Array[T]) IndexType() any

func (Array[T]) ScanIndex

func (a Array[T]) ScanIndex(i int) any

func (Array[T]) ScanIndexType

func (a Array[T]) ScanIndexType() any

func (*Array[T]) SetDimensions

func (a *Array[T]) SetDimensions(dimensions []ArrayDimension) error

type ArrayCodec

ArrayCodec is a codec for any array type.

type ArrayCodec struct {
    ElementType *Type
}

func (*ArrayCodec) DecodeDatabaseSQLValue

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

func (*ArrayCodec) DecodeValue

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

func (*ArrayCodec) FormatSupported

func (c *ArrayCodec) FormatSupported(format int16) bool

func (*ArrayCodec) PlanEncode

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

func (*ArrayCodec) PlanScan

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

func (*ArrayCodec) PreferredFormat

func (c *ArrayCodec) PreferredFormat() int16

type ArrayDimension

type ArrayDimension struct {
    Length     int32
    LowerBound int32
}

type ArrayGetter

ArrayGetter is a type that can be converted into a PostgreSQL array.

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) any

    // IndexType returns a non-nil scan target of the type Index will return. This is used by ArrayCodec.PlanEncode.
    IndexType() any
}

type ArraySetter

ArraySetter is a type can be set from a PostgreSQL array.

type ArraySetter interface {
    // SetDimensions prepares the value such that ScanIndex can be called for each element. This will remove any existing
    // elements. 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) any

    // ScanIndexType returns a non-nil scan target of the type ScanIndex will return. This is used by
    // ArrayCodec.PlanScan.
    ScanIndexType() any
}

type Bits

Bits represents the PostgreSQL bit and varbit types.

type Bits struct {
    Bytes []byte
    Len   int32 // Number of bits
    Valid bool
}

func (Bits) BitsValue

func (b Bits) BitsValue() (Bits, error)

func (*Bits) Scan

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

Scan implements the database/sql Scanner interface.

func (*Bits) ScanBits

func (b *Bits) ScanBits(v Bits) error

func (Bits) Value

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

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 (c BitsCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (BitsCodec) FormatSupported

func (BitsCodec) FormatSupported(format int16) bool

func (BitsCodec) PlanEncode

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

func (BitsCodec) PlanScan

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

func (BitsCodec) PreferredFormat

func (BitsCodec) PreferredFormat() int16

type BitsScanner

type BitsScanner interface {
    ScanBits(v Bits) error
}

type BitsValuer

type BitsValuer interface {
    BitsValue() (Bits, error)
}

type Bool

type Bool struct {
    Bool  bool
    Valid bool
}

func (Bool) BoolValue

func (b Bool) BoolValue() (Bool, error)

func (Bool) MarshalJSON

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

func (*Bool) Scan

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

Scan implements the database/sql Scanner interface.

func (*Bool) ScanBool

func (b *Bool) ScanBool(v Bool) error

func (*Bool) UnmarshalJSON

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

func (Bool) Value

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

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 (c BoolCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (BoolCodec) FormatSupported

func (BoolCodec) FormatSupported(format int16) bool

func (BoolCodec) PlanEncode

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

func (BoolCodec) PlanScan

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

func (BoolCodec) PreferredFormat

func (BoolCodec) PreferredFormat() int16

type BoolScanner

type BoolScanner interface {
    ScanBool(v Bool) error
}

type BoolValuer

type BoolValuer interface {
    BoolValue() (Bool, error)
}

type BoundType

type BoundType byte

func (BoundType) String

func (bt BoundType) String() string

type Box

type Box struct {
    P     [2]Vec2
    Valid bool
}

func (Box) BoxValue

func (b Box) BoxValue() (Box, error)

func (*Box) Scan

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

Scan implements the database/sql Scanner interface.

func (*Box) ScanBox

func (b *Box) ScanBox(v Box) error

func (Box) Value

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

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 (c BoxCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (BoxCodec) FormatSupported

func (BoxCodec) FormatSupported(format int16) bool

func (BoxCodec) PlanEncode

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

func (BoxCodec) PlanScan

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

func (BoxCodec) PreferredFormat

func (BoxCodec) PreferredFormat() int16

type BoxScanner

type BoxScanner interface {
    ScanBox(v Box) error
}

type BoxValuer

type BoxValuer interface {
    BoxValue() (Box, error)
}

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 (c ByteaCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (ByteaCodec) FormatSupported

func (ByteaCodec) FormatSupported(format int16) bool

func (ByteaCodec) PlanEncode

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

func (ByteaCodec) PlanScan

func (ByteaCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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

type Circle struct {
    P     Vec2
    R     float64
    Valid bool
}

func (Circle) CircleValue

func (c Circle) CircleValue() (Circle, error)

func (*Circle) Scan

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

Scan implements the database/sql Scanner interface.

func (*Circle) ScanCircle

func (c *Circle) ScanCircle(v Circle) error

func (Circle) Value

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

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 (c CircleCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (CircleCodec) FormatSupported

func (CircleCodec) FormatSupported(format int16) bool

func (CircleCodec) PlanEncode

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

func (CircleCodec) PlanScan

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

func (CircleCodec) PreferredFormat

func (CircleCodec) PreferredFormat() int16

type CircleScanner

type CircleScanner interface {
    ScanCircle(v Circle) error
}

type CircleValuer

type CircleValuer interface {
    CircleValue() (Circle, error)
}

type Codec

A Codec converts between Go and PostgreSQL values. A Codec must not be mutated after it is registered with a Map.

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 any) 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 any) 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) (any, error)
}

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 any)

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) (any, 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 any) EncodePlan

func (*CompositeCodec) PlanScan

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

func (*CompositeCodec) PreferredFormat

func (c *CompositeCodec) PreferredFormat() int16

type CompositeCodecField

type CompositeCodecField struct {
    Name string
    Type *Type
}

type CompositeFields

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.

type CompositeFields []any

func (CompositeFields) Index

func (cf CompositeFields) Index(i int) any

func (CompositeFields) IsNull

func (cf CompositeFields) IsNull() bool

func (CompositeFields) ScanIndex

func (cf CompositeFields) ScanIndex(i int) any

func (CompositeFields) ScanNull

func (cf CompositeFields) ScanNull() error

func (CompositeFields) SkipUnderlyingTypePlan

func (cf CompositeFields) SkipUnderlyingTypePlan()

type CompositeIndexGetter

CompositeIndexGetter is a type accessed by index that can be converted into a PostgreSQL composite.

type CompositeIndexGetter interface {
    // IsNull returns true if the value is SQL NULL.
    IsNull() bool

    // Index returns the element at i.
    Index(i int) any
}

type CompositeIndexScanner

CompositeIndexScanner is a type accessed by index that can be scanned from a PostgreSQL composite.

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) any
}

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 any)

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 (d Date) DateValue() (Date, error)

func (Date) MarshalJSON

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

func (*Date) Scan

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

Scan implements the database/sql Scanner interface.

func (*Date) ScanDate

func (d *Date) ScanDate(v Date) error

func (*Date) UnmarshalJSON

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

func (Date) Value

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

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 (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (DateCodec) FormatSupported

func (DateCodec) FormatSupported(format int16) bool

func (DateCodec) PlanEncode

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

func (DateCodec) PlanScan

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

func (DateCodec) PreferredFormat

func (DateCodec) PreferredFormat() int16

type DateScanner

type DateScanner interface {
    ScanDate(v Date) error
}

type DateValuer

type DateValuer interface {
    DateValue() (Date, error)
}

type DriverBytes

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 never safe to use DriverBytes with QueryRow as Row.Scan internally calls Rows.Close before returning.

type DriverBytes []byte

func (*DriverBytes) ScanBytes

func (b *DriverBytes) ScanBytes(v []byte) error

type EncodePlan

EncodePlan is a precompiled plan to encode a particular type into a particular OID and format.

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 any, buf []byte) (newBuf []byte, err error)
}

type EnumCodec

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.

type EnumCodec struct {
    // contains filtered or unexported fields
}

func (*EnumCodec) DecodeDatabaseSQLValue

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

func (*EnumCodec) DecodeValue

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

func (EnumCodec) FormatSupported

func (EnumCodec) FormatSupported(format int16) bool

func (EnumCodec) PlanEncode

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

func (*EnumCodec) PlanScan

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

func (EnumCodec) PreferredFormat

func (EnumCodec) PreferredFormat() int16

type FlatArray

FlatArray implements the ArrayGetter and ArraySetter interfaces for any slice of T. It ignores PostgreSQL dimensions and custom lower bounds. Use Array to preserve these.

type FlatArray[T any] []T

func (FlatArray[T]) Dimensions

func (a FlatArray[T]) Dimensions() []ArrayDimension

func (FlatArray[T]) Index

func (a FlatArray[T]) Index(i int) any

func (FlatArray[T]) IndexType

func (a FlatArray[T]) IndexType() any

func (FlatArray[T]) ScanIndex

func (a FlatArray[T]) ScanIndex(i int) any

func (FlatArray[T]) ScanIndexType

func (a FlatArray[T]) ScanIndexType() any

func (*FlatArray[T]) SetDimensions

func (a *FlatArray[T]) SetDimensions(dimensions []ArrayDimension) error

type Float4

type Float4 struct {
    Float32 float32
    Valid   bool
}

func (Float4) Float64Value

func (f Float4) Float64Value() (Float8, error)

func (Float4) Int64Value

func (f Float4) Int64Value() (Int8, error)

func (Float4) MarshalJSON

func (f Float4) MarshalJSON() ([]byte, error)

func (*Float4) Scan

func (f *Float4) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Float4) ScanFloat64

func (f *Float4) ScanFloat64(n Float8) error

ScanFloat64 implements the Float64Scanner interface.

func (*Float4) ScanInt64

func (f *Float4) ScanInt64(n Int8) error

func (*Float4) UnmarshalJSON

func (f *Float4) UnmarshalJSON(b []byte) error

func (Float4) Value

func (f Float4) Value() (driver.Value, error)

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 (c Float4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Float4Codec) FormatSupported

func (Float4Codec) FormatSupported(format int16) bool

func (Float4Codec) PlanEncode

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

func (Float4Codec) PlanScan

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

func (Float4Codec) PreferredFormat

func (Float4Codec) PreferredFormat() int16

type Float64Scanner

type Float64Scanner interface {
    ScanFloat64(Float8) error
}

type Float64Valuer

type Float64Valuer interface {
    Float64Value() (Float8, error)
}

type Float8

type Float8 struct {
    Float64 float64
    Valid   bool
}

func (Float8) Float64Value

func (f Float8) Float64Value() (Float8, error)

func (Float8) Int64Value

func (f Float8) Int64Value() (Int8, error)

func (Float8) MarshalJSON

func (f Float8) MarshalJSON() ([]byte, error)

func (*Float8) Scan

func (f *Float8) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Float8) ScanFloat64

func (f *Float8) ScanFloat64(n Float8) error

ScanFloat64 implements the Float64Scanner interface.

func (*Float8) ScanInt64

func (f *Float8) ScanInt64(n Int8) error

func (*Float8) UnmarshalJSON

func (f *Float8) UnmarshalJSON(b []byte) error

func (Float8) Value

func (f Float8) Value() (driver.Value, error)

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 (c Float8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Float8Codec) FormatSupported

func (Float8Codec) FormatSupported(format int16) bool

func (Float8Codec) PlanEncode

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

func (Float8Codec) PlanScan

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

func (Float8Codec) PreferredFormat

func (Float8Codec) PreferredFormat() int16

type Hstore

Hstore represents an hstore column that can be null or have null values associated with its keys.

type Hstore map[string]*string

func (Hstore) HstoreValue

func (h Hstore) HstoreValue() (Hstore, error)

func (*Hstore) Scan

func (h *Hstore) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Hstore) ScanHstore

func (h *Hstore) ScanHstore(v Hstore) error

func (Hstore) Value

func (h Hstore) Value() (driver.Value, error)

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 (c HstoreCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (HstoreCodec) FormatSupported

func (HstoreCodec) FormatSupported(format int16) bool

func (HstoreCodec) PlanEncode

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

func (HstoreCodec) PlanScan

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

func (HstoreCodec) PreferredFormat

func (HstoreCodec) PreferredFormat() int16

type HstoreScanner

type HstoreScanner interface {
    ScanHstore(v Hstore) error
}

type HstoreValuer

type HstoreValuer interface {
    HstoreValue() (Hstore, error)
}

type InetCodec

InetCodec handles both inet and cidr PostgreSQL types. The preferred Go types are netip.Prefix and netip.Addr. If IsValid() is false then they are treated as SQL NULL.

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 (c InetCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (InetCodec) FormatSupported

func (InetCodec) FormatSupported(format int16) bool

func (InetCodec) PlanEncode

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

func (InetCodec) PlanScan

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

func (InetCodec) PreferredFormat

func (InetCodec) PreferredFormat() int16

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

type Int2 struct {
    Int16 int16
    Valid bool
}

func (Int2) Int64Value

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

func (Int2) MarshalJSON

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

func (*Int2) Scan

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

Scan implements the database/sql Scanner interface.

func (*Int2) ScanInt64

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

ScanInt64 implements the Int64Scanner interface.

func (*Int2) UnmarshalJSON

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

func (Int2) Value

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

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 (c Int2Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Int2Codec) FormatSupported

func (Int2Codec) FormatSupported(format int16) bool

func (Int2Codec) PlanEncode

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

func (Int2Codec) PlanScan

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

func (Int2Codec) PreferredFormat

func (Int2Codec) PreferredFormat() int16

type Int4

type Int4 struct {
    Int32 int32
    Valid bool
}

func (Int4) Int64Value

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

func (Int4) MarshalJSON

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

func (*Int4) Scan

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

Scan implements the database/sql Scanner interface.

func (*Int4) ScanInt64

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

ScanInt64 implements the Int64Scanner interface.

func (*Int4) UnmarshalJSON

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

func (Int4) Value

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

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 (c Int4Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Int4Codec) FormatSupported

func (Int4Codec) FormatSupported(format int16) bool

func (Int4Codec) PlanEncode

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

func (Int4Codec) PlanScan

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

func (Int4Codec) PreferredFormat

func (Int4Codec) PreferredFormat() int16

type Int64Scanner

type Int64Scanner interface {
    ScanInt64(Int8) error
}

type Int64Valuer

type Int64Valuer interface {
    Int64Value() (Int8, error)
}

type Int8

type Int8 struct {
    Int64 int64
    Valid bool
}

func (Int8) Int64Value

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

func (Int8) MarshalJSON

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

func (*Int8) Scan

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

Scan implements the database/sql Scanner interface.

func (*Int8) ScanInt64

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

ScanInt64 implements the Int64Scanner interface.

func (*Int8) UnmarshalJSON

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

func (Int8) Value

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

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 (c Int8Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Int8Codec) FormatSupported

func (Int8Codec) FormatSupported(format int16) bool

func (Int8Codec) PlanEncode

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

func (Int8Codec) PlanScan

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

func (Int8Codec) PreferredFormat

func (Int8Codec) PreferredFormat() int16

type Interval

type Interval struct {
    Microseconds int64
    Days         int32
    Months       int32
    Valid        bool
}

func (Interval) IntervalValue

func (interval Interval) IntervalValue() (Interval, error)

func (*Interval) Scan

func (interval *Interval) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Interval) ScanInterval

func (interval *Interval) ScanInterval(v Interval) error

func (Interval) Value

func (interval Interval) Value() (driver.Value, error)

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) (any, error)

func (IntervalCodec) FormatSupported

func (IntervalCodec) FormatSupported(format int16) bool

func (IntervalCodec) PlanEncode

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

func (IntervalCodec) PlanScan

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

func (IntervalCodec) PreferredFormat

func (IntervalCodec) PreferredFormat() int16

type IntervalScanner

type IntervalScanner interface {
    ScanInterval(v Interval) error
}

type IntervalValuer

type IntervalValuer interface {
    IntervalValue() (Interval, error)
}

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 (c JSONBCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (JSONBCodec) FormatSupported

func (JSONBCodec) FormatSupported(format int16) bool

func (JSONBCodec) PlanEncode

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

func (JSONBCodec) PlanScan

func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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 (c JSONCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (JSONCodec) FormatSupported

func (JSONCodec) FormatSupported(format int16) bool

func (JSONCodec) PlanEncode

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

func (JSONCodec) PlanScan

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

func (JSONCodec) PreferredFormat

func (JSONCodec) PreferredFormat() int16

type Line

type Line struct {
    A, B, C float64
    Valid   bool
}

func (Line) LineValue

func (line Line) LineValue() (Line, error)

func (*Line) Scan

func (line *Line) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Line) ScanLine

func (line *Line) ScanLine(v Line) error

func (*Line) Set

func (line *Line) Set(src any) error

func (Line) Value

func (line Line) Value() (driver.Value, error)

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 (c LineCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (LineCodec) FormatSupported

func (LineCodec) FormatSupported(format int16) bool

func (LineCodec) PlanEncode

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

func (LineCodec) PlanScan

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

func (LineCodec) PreferredFormat

func (LineCodec) PreferredFormat() int16

type LineScanner

type LineScanner interface {
    ScanLine(v Line) error
}

type LineValuer

type LineValuer interface {
    LineValue() (Line, error)
}

type Lseg

type Lseg struct {
    P     [2]Vec2
    Valid bool
}

func (Lseg) LsegValue

func (lseg Lseg) LsegValue() (Lseg, error)

func (*Lseg) Scan

func (lseg *Lseg) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Lseg) ScanLseg

func (lseg *Lseg) ScanLseg(v Lseg) error

func (Lseg) Value

func (lseg Lseg) Value() (driver.Value, error)

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 (c LsegCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (LsegCodec) FormatSupported

func (LsegCodec) FormatSupported(format int16) bool

func (LsegCodec) PlanEncode

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

func (LsegCodec) PlanScan

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

func (LsegCodec) PreferredFormat

func (LsegCodec) PreferredFormat() int16

type LsegScanner

type LsegScanner interface {
    ScanLseg(v Lseg) error
}

type LsegValuer

type LsegValuer interface {
    LsegValue() (Lseg, error)
}

type LtreeCodec

type LtreeCodec struct{}

func (LtreeCodec) DecodeDatabaseSQLValue

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

DecodeDatabaseSQLValue returns src decoded into a value compatible with the sql.Scanner interface.

func (LtreeCodec) DecodeValue

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

DecodeValue returns src decoded into its default format.

func (LtreeCodec) FormatSupported

func (l LtreeCodec) FormatSupported(format int16) bool

func (LtreeCodec) PlanEncode

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

PlanEncode returns an EncodePlan for encoding value into PostgreSQL format for oid and format. If no plan can be found then nil is returned.

func (LtreeCodec) PlanScan

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

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.

func (LtreeCodec) PreferredFormat

func (l LtreeCodec) PreferredFormat() int16

PreferredFormat returns the preferred format.

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) (any, error)

func (MacaddrCodec) FormatSupported

func (MacaddrCodec) FormatSupported(format int16) bool

func (MacaddrCodec) PlanEncode

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

func (MacaddrCodec) PlanScan

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

func (MacaddrCodec) PreferredFormat

func (MacaddrCodec) PreferredFormat() int16

type Map

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.

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
}

func NewMap

func NewMap() *Map

func (*Map) Encode

func (m *Map) Encode(oid uint32, formatCode int16, value any, 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

func (m *Map) FormatCodeForOID(oid uint32) int16

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 any) 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

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

PlanScan prepares a plan to scan a value into target.

func (*Map) RegisterDefaultPgType

func (m *Map) RegisterDefaultPgType(value any, name string)

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 (m *Map) RegisterType(t *Type)

RegisterType registers a data type with the Map. t must not be mutated after it is registered.

func (*Map) SQLScanner

func (m *Map) SQLScanner(v any) sql.Scanner

SQLScanner returns a database/sql.Scanner for v. This is necessary for types like Array[T] and Range[T] where the type needs assistance from Map to implement the sql.Scanner interface. It is not necessary for types like Box that implement sql.Scanner directly.

This uses the type of v to look up the PostgreSQL OID that v presumably came from. This means v must be registered with m by calling RegisterDefaultPgType.

func (*Map) Scan

func (m *Map) Scan(oid uint32, formatCode int16, src []byte, dst any) error

func (*Map) TypeForName

func (m *Map) TypeForName(name string) (*Type, bool)

TypeForName returns the Type registered for the given name. The returned Type must not be mutated.

func (*Map) TypeForOID

func (m *Map) TypeForOID(oid uint32) (*Type, bool)

TypeForOID returns the Type registered for the given OID. The returned Type must not be mutated.

func (*Map) TypeForValue

func (m *Map) TypeForValue(v any) (*Type, bool)

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. The returned Type must not be mutated.

type Multirange

Multirange is a generic multirange type.

T should implement RangeValuer and *T should implement RangeScanner. However, there does not appear to be a way to enforce the RangeScanner constraint.

type Multirange[T RangeValuer] []T

func (Multirange[T]) Index

func (r Multirange[T]) Index(i int) any

func (Multirange[T]) IndexType

func (r Multirange[T]) IndexType() any

func (Multirange[T]) IsNull

func (r Multirange[T]) IsNull() bool

func (Multirange[T]) Len

func (r Multirange[T]) Len() int

func (Multirange[T]) ScanIndex

func (r Multirange[T]) ScanIndex(i int) any

func (Multirange[T]) ScanIndexType

func (r Multirange[T]) ScanIndexType() any

func (*Multirange[T]) ScanNull

func (r *Multirange[T]) ScanNull() error

func (*Multirange[T]) SetLen

func (r *Multirange[T]) SetLen(n int) error

type MultirangeCodec

MultirangeCodec is a codec for any multirange type.

type MultirangeCodec struct {
    ElementType *Type
}

func (*MultirangeCodec) DecodeDatabaseSQLValue

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

func (*MultirangeCodec) DecodeValue

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

func (*MultirangeCodec) FormatSupported

func (c *MultirangeCodec) FormatSupported(format int16) bool

func (*MultirangeCodec) PlanEncode

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

func (*MultirangeCodec) PlanScan

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

func (*MultirangeCodec) PreferredFormat

func (c *MultirangeCodec) PreferredFormat() int16

type MultirangeGetter

MultirangeGetter is a type that can be converted into a PostgreSQL multirange.

type MultirangeGetter interface {
    // IsNull returns true if the value is SQL NULL.
    IsNull() bool

    // Len returns the number of elements in the multirange.
    Len() int

    // Index returns the element at i.
    Index(i int) any

    // IndexType returns a non-nil scan target of the type Index will return. This is used by MultirangeCodec.PlanEncode.
    IndexType() any
}

type MultirangeSetter

MultirangeSetter is a type can be set from a PostgreSQL multirange.

type MultirangeSetter interface {
    // ScanNull sets the value to SQL NULL.
    ScanNull() error

    // SetLen prepares the value such that ScanIndex can be called for each element. This will remove any existing
    // elements.
    SetLen(n int) error

    // ScanIndex returns a value usable as a scan target for i. SetLen must be called before ScanIndex.
    ScanIndex(i int) any

    // ScanIndexType returns a non-nil scan target of the type ScanIndex will return. This is used by
    // MultirangeCodec.PlanScan.
    ScanIndexType() any
}

type NetipPrefixScanner

type NetipPrefixScanner interface {
    ScanNetipPrefix(v netip.Prefix) error
}

type NetipPrefixValuer

type NetipPrefixValuer interface {
    NetipPrefixValue() (netip.Prefix, error)
}

type Numeric

type Numeric struct {
    Int              *big.Int
    Exp              int32
    NaN              bool
    InfinityModifier InfinityModifier
    Valid            bool
}

func (Numeric) Float64Value

func (n Numeric) Float64Value() (Float8, error)

func (Numeric) Int64Value

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

func (Numeric) MarshalJSON

func (n Numeric) MarshalJSON() ([]byte, error)

func (Numeric) NumericValue

func (n Numeric) NumericValue() (Numeric, error)

func (*Numeric) Scan

func (n *Numeric) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Numeric) ScanInt64

func (n *Numeric) ScanInt64(v Int8) error

func (*Numeric) ScanNumeric

func (n *Numeric) ScanNumeric(v Numeric) error

func (*Numeric) ScanScientific

func (n *Numeric) ScanScientific(src string) error

func (*Numeric) UnmarshalJSON

func (n *Numeric) UnmarshalJSON(src []byte) error

func (Numeric) Value

func (n Numeric) Value() (driver.Value, error)

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) (any, error)

func (NumericCodec) FormatSupported

func (NumericCodec) FormatSupported(format int16) bool

func (NumericCodec) PlanEncode

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

func (NumericCodec) PlanScan

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

func (NumericCodec) PreferredFormat

func (NumericCodec) PreferredFormat() int16

type NumericScanner

type NumericScanner interface {
    ScanNumeric(v Numeric) error
}

type NumericValuer

type NumericValuer interface {
    NumericValue() (Numeric, error)
}

type Path

type Path struct {
    P      []Vec2
    Closed bool
    Valid  bool
}

func (Path) PathValue

func (path Path) PathValue() (Path, error)

func (*Path) Scan

func (path *Path) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Path) ScanPath

func (path *Path) ScanPath(v Path) error

func (Path) Value

func (path Path) Value() (driver.Value, error)

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 (c PathCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (PathCodec) FormatSupported

func (PathCodec) FormatSupported(format int16) bool

func (PathCodec) PlanEncode

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

func (PathCodec) PlanScan

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

func (PathCodec) PreferredFormat

func (PathCodec) PreferredFormat() int16

type PathScanner

type PathScanner interface {
    ScanPath(v Path) error
}

type PathValuer

type PathValuer interface {
    PathValue() (Path, error)
}

type Point

type Point struct {
    P     Vec2
    Valid bool
}

func (Point) MarshalJSON

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

func (Point) PointValue

func (p Point) PointValue() (Point, error)

func (*Point) Scan

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

Scan implements the database/sql Scanner interface.

func (*Point) ScanPoint

func (p *Point) ScanPoint(v Point) error

func (*Point) UnmarshalJSON

func (dst *Point) UnmarshalJSON(point []byte) error

func (Point) Value

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

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 (c PointCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (PointCodec) FormatSupported

func (PointCodec) FormatSupported(format int16) bool

func (PointCodec) PlanEncode

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

func (PointCodec) PlanScan

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

func (PointCodec) PreferredFormat

func (PointCodec) PreferredFormat() int16

type PointScanner

type PointScanner interface {
    ScanPoint(v Point) error
}

type PointValuer

type PointValuer interface {
    PointValue() (Point, error)
}

type Polygon

type Polygon struct {
    P     []Vec2
    Valid bool
}

func (Polygon) PolygonValue

func (p Polygon) PolygonValue() (Polygon, error)

func (*Polygon) Scan

func (p *Polygon) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Polygon) ScanPolygon

func (p *Polygon) ScanPolygon(v Polygon) error

func (Polygon) Value

func (p Polygon) Value() (driver.Value, error)

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) (any, error)

func (PolygonCodec) FormatSupported

func (PolygonCodec) FormatSupported(format int16) bool

func (PolygonCodec) PlanEncode

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

func (PolygonCodec) PlanScan

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

func (PolygonCodec) PreferredFormat

func (PolygonCodec) PreferredFormat() int16

type PolygonScanner

type PolygonScanner interface {
    ScanPolygon(v Polygon) error
}

type PolygonValuer

type PolygonValuer interface {
    PolygonValue() (Polygon, error)
}

type PreallocBytes

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.

type PreallocBytes []byte

func (*PreallocBytes) ScanBytes

func (b *PreallocBytes) ScanBytes(v []byte) error

type QCharCodec

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.

type QCharCodec struct{}

func (QCharCodec) DecodeDatabaseSQLValue

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

func (QCharCodec) DecodeValue

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

func (QCharCodec) FormatSupported

func (QCharCodec) FormatSupported(format int16) bool

func (QCharCodec) PlanEncode

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

func (QCharCodec) PlanScan

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

func (QCharCodec) PreferredFormat

func (QCharCodec) PreferredFormat() int16

type Range

Range is a generic range type.

type Range[T any] struct {
    Lower     T
    Upper     T
    LowerType BoundType
    UpperType BoundType
    Valid     bool
}

func (Range[T]) BoundTypes

func (r Range[T]) BoundTypes() (lower, upper BoundType)

func (Range[T]) Bounds

func (r Range[T]) Bounds() (lower, upper any)

func (Range[T]) IsNull

func (r Range[T]) IsNull() bool

func (*Range[T]) ScanBounds

func (r *Range[T]) ScanBounds() (lowerTarget, upperTarget any)

func (*Range[T]) ScanNull

func (r *Range[T]) ScanNull() error

func (*Range[T]) SetBoundTypes

func (r *Range[T]) SetBoundTypes(lower, upper BoundType) error

type RangeCodec

RangeCodec is a codec for any range type.

type RangeCodec struct {
    ElementType *Type
}

func (*RangeCodec) DecodeDatabaseSQLValue

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

func (*RangeCodec) DecodeValue

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

func (*RangeCodec) FormatSupported

func (c *RangeCodec) FormatSupported(format int16) bool

func (*RangeCodec) PlanEncode

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

func (*RangeCodec) PlanScan

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

func (*RangeCodec) PreferredFormat

func (c *RangeCodec) PreferredFormat() int16

type RangeScanner

RangeScanner is a type can be scanned from a PostgreSQL range.

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 any)

    // 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
}

type RangeValuer

RangeValuer is a type that can be converted into a PostgreSQL range.

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 any)
}

type RecordCodec

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.

type RecordCodec struct{}

func (RecordCodec) DecodeDatabaseSQLValue

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

func (RecordCodec) DecodeValue

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

func (RecordCodec) FormatSupported

func (RecordCodec) FormatSupported(format int16) bool

func (RecordCodec) PlanEncode

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

func (RecordCodec) PlanScan

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

func (RecordCodec) PreferredFormat

func (RecordCodec) PreferredFormat() int16

type ScanPlan

ScanPlan is a precompiled plan to scan into a type of destination.

type ScanPlan interface {
    // Scan scans src into target. src is only valid during the call to Scan. The ScanPlan must not retain a reference to
    // src.
    Scan(src []byte, target any) error
}

type SkipUnderlyingTypePlanner

SkipUnderlyingTypePlanner prevents PlanScan and PlanDecode from trying to use the underlying type.

type SkipUnderlyingTypePlanner interface {
    SkipUnderlyingTypePlan()
}

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.

type TID struct {
    BlockNumber  uint32
    OffsetNumber uint16
    Valid        bool
}

func (*TID) Scan

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

Scan implements the database/sql Scanner interface.

func (*TID) ScanTID

func (b *TID) ScanTID(v TID) error

func (TID) TIDValue

func (b TID) TIDValue() (TID, error)

func (TID) Value

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

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 (c TIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (TIDCodec) FormatSupported

func (TIDCodec) FormatSupported(format int16) bool

func (TIDCodec) PlanEncode

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

func (TIDCodec) PlanScan

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

func (TIDCodec) PreferredFormat

func (TIDCodec) PreferredFormat() int16

type TIDScanner

type TIDScanner interface {
    ScanTID(v TID) error
}

type TIDValuer

type TIDValuer interface {
    TIDValue() (TID, error)
}

type Text

type Text struct {
    String string
    Valid  bool
}

func (Text) MarshalJSON

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

func (*Text) Scan

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

Scan implements the database/sql Scanner interface.

func (*Text) ScanText

func (t *Text) ScanText(v Text) error

func (Text) TextValue

func (t Text) TextValue() (Text, error)

func (*Text) UnmarshalJSON

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

func (Text) Value

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

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 (c TextCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (TextCodec) FormatSupported

func (TextCodec) FormatSupported(format int16) bool

func (TextCodec) PlanEncode

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

func (TextCodec) PlanScan

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

func (TextCodec) PreferredFormat

func (TextCodec) PreferredFormat() int16

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 TextScanner interface {
    ScanText(v Text) error
}

type TextValuer

type TextValuer interface {
    TextValue() (Text, error)
}

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.

type Time struct {
    Microseconds int64 // Number of microseconds since midnight
    Valid        bool
}

func (*Time) Scan

func (t *Time) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Time) ScanTime

func (t *Time) ScanTime(v Time) error

func (Time) TimeValue

func (t Time) TimeValue() (Time, error)

func (Time) Value

func (t Time) Value() (driver.Value, error)

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 (c TimeCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (TimeCodec) FormatSupported

func (TimeCodec) FormatSupported(format int16) bool

func (TimeCodec) PlanEncode

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

func (TimeCodec) PlanScan

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

func (TimeCodec) PreferredFormat

func (TimeCodec) PreferredFormat() int16

type TimeScanner

type TimeScanner interface {
    ScanTime(v Time) error
}

type TimeValuer

type TimeValuer interface {
    TimeValue() (Time, error)
}

type Timestamp

Timestamp represents the PostgreSQL timestamp type.

type Timestamp struct {
    Time             time.Time // Time zone will be ignored when encoding to PostgreSQL.
    InfinityModifier InfinityModifier
    Valid            bool
}

func (Timestamp) MarshalJSON

func (ts Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) Scan

func (ts *Timestamp) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Timestamp) ScanTimestamp

func (ts *Timestamp) ScanTimestamp(v Timestamp) error

func (Timestamp) TimestampValue

func (ts Timestamp) TimestampValue() (Timestamp, error)

func (*Timestamp) UnmarshalJSON

func (ts *Timestamp) UnmarshalJSON(b []byte) error

func (Timestamp) Value

func (ts Timestamp) Value() (driver.Value, error)

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) (any, error)

func (TimestampCodec) FormatSupported

func (TimestampCodec) FormatSupported(format int16) bool

func (TimestampCodec) PlanEncode

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

func (TimestampCodec) PlanScan

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

func (TimestampCodec) PreferredFormat

func (TimestampCodec) PreferredFormat() int16

type TimestampScanner

type TimestampScanner interface {
    ScanTimestamp(v Timestamp) error
}

type TimestampValuer

type TimestampValuer interface {
    TimestampValue() (Timestamp, error)
}

type Timestamptz

Timestamptz represents the PostgreSQL timestamptz type.

type Timestamptz struct {
    Time             time.Time
    InfinityModifier InfinityModifier
    Valid            bool
}

func (Timestamptz) MarshalJSON

func (tstz Timestamptz) MarshalJSON() ([]byte, error)

func (*Timestamptz) Scan

func (tstz *Timestamptz) Scan(src any) 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) (any, error)

func (TimestamptzCodec) FormatSupported

func (TimestamptzCodec) FormatSupported(format int16) bool

func (TimestamptzCodec) PlanEncode

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

func (TimestamptzCodec) PlanScan

func (TimestamptzCodec) PlanScan(m *Map, oid uint32, format int16, target any) 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

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 TryWrapEncodePlanFunc func(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)

type TryWrapScanPlanFunc

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 TryWrapScanPlanFunc func(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool)

type Type

Type represents a PostgreSQL data type. It must not be mutated after it is registered with a Map.

type Type struct {
    Codec Codec
    Name  string
    OID   uint32
}

type UUID

type UUID struct {
    Bytes [16]byte
    Valid bool
}

func (UUID) MarshalJSON

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

func (*UUID) Scan

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

Scan implements the database/sql Scanner interface.

func (*UUID) ScanUUID

func (b *UUID) ScanUUID(v UUID) error

func (UUID) UUIDValue

func (b UUID) UUIDValue() (UUID, error)

func (*UUID) UnmarshalJSON

func (dst *UUID) UnmarshalJSON(src []byte) error

func (UUID) Value

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

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 (c UUIDCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (UUIDCodec) FormatSupported

func (UUIDCodec) FormatSupported(format int16) bool

func (UUIDCodec) PlanEncode

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

func (UUIDCodec) PlanScan

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

func (UUIDCodec) PreferredFormat

func (UUIDCodec) PreferredFormat() int16

type UUIDScanner

type UUIDScanner interface {
    ScanUUID(v UUID) error
}

type UUIDValuer

type UUIDValuer interface {
    UUIDValue() (UUID, error)
}

type Uint32

Uint32 is the core type that is used to represent PostgreSQL types such as OID, CID, and XID.

type Uint32 struct {
    Uint32 uint32
    Valid  bool
}

func (*Uint32) Scan

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

Scan implements the database/sql Scanner interface.

func (*Uint32) ScanUint32

func (n *Uint32) ScanUint32(v Uint32) error

func (Uint32) Uint32Value

func (n Uint32) Uint32Value() (Uint32, error)

func (Uint32) Value

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

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 (c Uint32Codec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (any, error)

func (Uint32Codec) FormatSupported

func (Uint32Codec) FormatSupported(format int16) bool

func (Uint32Codec) PlanEncode

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

func (Uint32Codec) PlanScan

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

func (Uint32Codec) PreferredFormat

func (Uint32Codec) PreferredFormat() int16

type Uint32Scanner

type Uint32Scanner interface {
    ScanUint32(v Uint32) error
}

type Uint32Valuer

type Uint32Valuer interface {
    Uint32Value() (Uint32, error)
}

type UndecodedBytes

UndecodedBytes can be used as a scan target to get the raw bytes from PostgreSQL without any decoding.

type UndecodedBytes []byte

type Vec2

type Vec2 struct {
    X float64
    Y float64
}

type WrappedEncodePlanNextSetter

type WrappedEncodePlanNextSetter interface {
    SetNext(EncodePlan)
    EncodePlan
}

func TryWrapArrayEncodePlan

func TryWrapArrayEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)

func TryWrapBuiltinTypeEncodePlan

func TryWrapBuiltinTypeEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, 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 any) (plan WrappedEncodePlanNextSetter, nextValue any, 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 any) (plan WrappedEncodePlanNextSetter, nextValue any, 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 any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)

func TryWrapSliceEncodePlan

func TryWrapSliceEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)

func TryWrapStructEncodePlan

func TryWrapStructEncodePlan(value any) (plan WrappedEncodePlanNextSetter, nextValue any, ok bool)

TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter.

type WrappedScanPlanNextSetter

type WrappedScanPlanNextSetter interface {
    SetNext(ScanPlan)
    ScanPlan
}

func TryFindUnderlyingTypeScanPlan

func TryFindUnderlyingTypeScanPlan(dst any) (plan WrappedScanPlanNextSetter, nextDst any, 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 any) (plan WrappedScanPlanNextSetter, nextTarget any, 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 any) (plan WrappedScanPlanNextSetter, nextDst any, 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 TryWrapPtrArrayScanPlan

func TryWrapPtrArrayScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)

TryWrapPtrArrayScanPlan tries to wrap a pointer to a single dimension array.

func TryWrapPtrMultiDimSliceScanPlan

func TryWrapPtrMultiDimSliceScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)

TryWrapPtrMultiDimSliceScanPlan tries to wrap a pointer to a multi-dimension slice.

func TryWrapPtrSliceScanPlan

func TryWrapPtrSliceScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)

TryWrapPtrSliceScanPlan tries to wrap a pointer to a single dimension slice.

func TryWrapStructScanPlan

func TryWrapStructScanPlan(target any) (plan WrappedScanPlanNextSetter, nextValue any, ok bool)

TryWrapStructPlan tries to wrap a struct with a wrapper that implements CompositeIndexGetter.

Subdirectories

Name Synopsis
..
zeronull Package zeronull contains types that automatically convert between database NULLs and Go zero values.