Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlcallback

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sqlcallback contains application callbacks before SQL inspects errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Argument

func Argument(value any) any

Argument protects SQL's recursive pointer conversion without changing ordinary values.

func Connector

func Connector(source driver.Connector) driver.Connector

Connector shields database/sql's native error inspection from driver callbacks.

func Decode

func Decode[T any](operation string, decode func(any) (T, error), source any, trusted bool) (T, error)

Decode publishes only complete values. The trusted capability is supplied only by the codec owner's private framework constructor, never by applications.

func Destinations

func Destinations(values []any) []any

Destinations intercepts Scanner callbacks, including database/sql's pointer allocation path.

func Invoke

func Invoke(operation string, fn func() error) error

Invoke seals a callback error before a foreign library can inspect its cause.

func NewScanner

func NewScanner[T any](decode func(any) (T, error), destination *T, trusted bool) sql.Scanner

NewScanner retains the codec owner's capability. Its public Scan preserves error identity; its native SQL view seals causes until the database owner regains control. Both views use the same allocation and destination. Keep the destination closure shared across codec call sites. Inlining this constructor replicates generic closures in every column/aggregate adapter.

func Retain

func Retain(foreign, result error) error

Retain restores a source-issued diagnostic hidden by a native SQL wrapper, after execution and outcome classification, preserving every returned cause.

Types

type RowBatch

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

RowBatch lends Next containment to a complete collection. The database owner must hold its stream mutex throughout Run, including callback exit and cleanup. ScanColumn and Close never borrow it: foreign scan/close frames need their own Goexit containment to release locks before returning to the collection owner.

func WithRowBatch

func WithRowBatch(ctx context.Context) (context.Context, *RowBatch)

WithRowBatch delivers a private lease to the connector wrapper. It is removed before calling an application driver, so nested/retained driver contexts cannot borrow another stream's containment.

func (*RowBatch) Run

func (b *RowBatch) Run(operation string, fn func() error) (err error, driverExit bool)

Run contains the whole sequential iteration. A driver Goexit retains the same diagnostic as an individually isolated Next, and is identified separately so the stream owner can classify its outcome before closing rows.

type ScanBuffer

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

ScanBuffer owns adapter scratch for one sequential stream. It never mutates or retains the caller's slice; Reset drops retained destinations on closure.

func (*ScanBuffer) Prepare

func (b *ScanBuffer) Prepare(values []any) []any

func (*ScanBuffer) Reset

func (b *ScanBuffer) Reset()

Jump to

Keyboard shortcuts

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