query

package
v3.76.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SyntaxYQL        = options.SyntaxYQL
	SyntaxPostgreSQL = options.SyntaxPostgreSQL
)
View Source
const (
	ExecModeParse    = options.ExecModeParse
	ExecModeValidate = options.ExecModeValidate
	ExecModeExplain  = options.ExecModeExplain
	ExecModeExecute  = options.ExecModeExecute
)
View Source
const (
	StatsModeBasic   = options.StatsModeBasic
	StatsModeNone    = options.StatsModeNone
	StatsModeFull    = options.StatsModeFull
	StatsModeProfile = options.StatsModeProfile
)

Variables

This section is empty.

Functions

func BeginTx

func BeginTx(opts ...TransactionOption) tx.ControlOption

BeginTx returns selector transaction control option

func CommitTx

func CommitTx() tx.ControlOption

CommitTx returns commit transaction control option

func Stats deprecated added in v3.59.0

func Stats(client Client) (*pool.Stats, error)

Stats returns stats of query client pool

Deprecated: use client.Stats() method instead Will be removed after Jan 2025. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated

func WithCallOptions

func WithCallOptions(opts ...grpc.CallOption) options.CallOptions

func WithCommit

func WithCommit() options.TxExecuteOption

func WithExecMode

func WithExecMode(mode options.ExecMode) options.ExecModeOption

func WithIdempotent

func WithIdempotent() options.RetryOptionsOption

func WithInconsistentReads

func WithInconsistentReads() tx.OnlineReadOnlyOption

func WithLabel added in v3.57.1

func WithLabel(lbl string) options.RetryOptionsOption

func WithParameters

func WithParameters(parameters *params.Parameters) options.ParametersOption

func WithRetryBudget added in v3.66.0

func WithRetryBudget(b budget.Budget) options.RetryOptionsOption

WithRetryBudget creates option with external budget

Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental

func WithStatsMode

func WithStatsMode(mode options.StatsMode) options.StatsModeOption

func WithSyntax

func WithSyntax(syntax options.Syntax) options.SyntaxOption

func WithTrace

func WithTrace(t *trace.Query) options.TraceOption

func WithTx

func WithTx(t tx.Identifier) tx.ControlOption

func WithTxControl

func WithTxControl(txControl *tx.Control) options.TxControlOption

func WithTxID

func WithTxID(txID string) tx.ControlOption

func WithTxSettings

func WithTxSettings(txSettings tx.Settings) options.DoTxOption

Types

type Client

type Client interface {
	// Do provide the best effort for execute operation.
	//
	// Do implements internal busy loop until one of the following conditions is met:
	// - deadline was canceled or deadlined
	// - retry operation returned nil as error
	//
	// Warning: if context without deadline or cancellation func than Do can run indefinitely.
	Do(ctx context.Context, op Operation, opts ...DoOption) error

	// DoTx provide the best effort for execute transaction.
	//
	// DoTx implements internal busy loop until one of the following conditions is met:
	// - deadline was canceled or deadlined
	// - retry operation returned nil as error
	//
	// DoTx makes auto selector (with TransactionSettings, by default - SerializableReadWrite), commit and
	// rollback (on error) of transaction.
	//
	// If op TxOperation returns nil - transaction will be committed
	// If op TxOperation return non nil - transaction will be rollback
	// Warning: if context without deadline or cancellation func than DoTx can run indefinitely
	DoTx(ctx context.Context, op TxOperation, opts ...DoTxOption) error

	// Execute is a simple executor with retries
	//
	// Execute returns materialized result
	//
	// Warning: large result can lead to "OOM Killed" problem
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	Execute(ctx context.Context, query string, opts ...options.ExecuteOption) (Result, error)

	// ReadResultSet is a helper which read all rows from first result set in result
	//
	// ReadRow returns error if result contains more than one result set
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	ReadResultSet(ctx context.Context, query string, opts ...options.ExecuteOption) (ResultSet, error)

	// ReadRow is a helper which read only one row from first result set in result
	//
	// ReadRow returns error if result contains more than one result set or more than one row
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	ReadRow(ctx context.Context, query string, opts ...options.ExecuteOption) (Row, error)

	// Stats returns stats of session pool
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	Stats() *poolStats.Stats
}

type ClosableSession

type ClosableSession interface {
	closer.Closer

	Session
}

type DoOption

type DoOption = options.DoOption

type DoTxOption

type DoTxOption = options.DoTxOption

type NamedDestination added in v3.73.0

type NamedDestination = scanner.NamedDestination

func Named

func Named(columnName string, destinationValueReference interface{}) (dst NamedDestination)

type Operation

type Operation func(ctx context.Context, s Session) error

Operation is the interface that holds an operation for retry. if Operation returns not nil - operation will retry if Operation returns nil - retry loop will break

type Result

type Result interface {
	closer.Closer

	// NextResultSet returns next result set
	NextResultSet(ctx context.Context) (ResultSet, error)

	// Range is experimental API for range iterators available with Go version 1.22+ and flag `GOEXPERIMENT=rangefunc`.
	Range(ctx context.Context) xiter.Seq2[ResultSet, error]

	Stats() stats.QueryStats

	// Err returns error (if happened) on result
	Err() error
}

type ResultSet

type ResultSet interface {
	Index() int
	Columns() []string
	ColumnTypes() []Type
	NextRow(ctx context.Context) (Row, error)

	// Range is experimental API for range iterators available with Go version 1.22+ and flag `GOEXPERIMENT=rangefunc`.
	Range(ctx context.Context) xiter.Seq2[Row, error]
}

type Row

type Row interface {
	Scan(dst ...interface{}) error
	ScanNamed(dst ...NamedDestination) error
	ScanStruct(dst interface{}, opts ...ScanStructOption) error
}

type ScanStructOption added in v3.73.0

type ScanStructOption = scanner.ScanStructOption

func WithScanStructAllowMissingColumnsFromSelect

func WithScanStructAllowMissingColumnsFromSelect() ScanStructOption

func WithScanStructAllowMissingFieldsInStruct

func WithScanStructAllowMissingFieldsInStruct() ScanStructOption

func WithScanStructTagName

func WithScanStructTagName(name string) ScanStructOption

type Session

type Session interface {
	SessionInfo

	// Execute executes query.
	//
	// Execute used by default:
	// - DefaultTxControl (NoTx)
	// - flag WithKeepInCache(true) if params is not empty.
	Execute(ctx context.Context, query string, opts ...options.ExecuteOption) (tx Transaction, r Result, err error)

	Begin(ctx context.Context, txSettings TransactionSettings) (Transaction, error)

	// ReadRow is a helper which read only one row from first result set in result
	//
	// ReadRow returns error if result contains more than one result set or more than one row
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	ReadRow(ctx context.Context, query string, opts ...options.ExecuteOption) (Row, error)

	// ReadResultSet is a helper which read all rows from first result set in result
	//
	// ReadRow returns error if result contains more than one result set
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	ReadResultSet(ctx context.Context, query string, opts ...options.ExecuteOption) (ResultSet, error)
}

type SessionInfo

type SessionInfo interface {
	ID() string
	NodeID() int64
	Status() string
}

type Transaction

type Transaction interface {
	TxActor

	CommitTx(ctx context.Context) (err error)
	Rollback(ctx context.Context) (err error)
}

type TransactionControl

type TransactionControl = tx.Control

func DefaultTxControl

func DefaultTxControl() *TransactionControl

DefaultTxControl returns default transaction control for use default tx control on server-side

func NoTx

func NoTx() *TransactionControl

func OnlineReadOnlyTxControl

func OnlineReadOnlyTxControl(opts ...tx.OnlineReadOnlyOption) *TransactionControl

OnlineReadOnlyTxControl returns online read-only transaction control

func SerializableReadWriteTxControl

func SerializableReadWriteTxControl(opts ...tx.ControlOption) *TransactionControl

SerializableReadWriteTxControl returns transaction control with serializable read-write isolation mode

func SnapshotReadOnlyTxControl

func SnapshotReadOnlyTxControl() *TransactionControl

SnapshotReadOnlyTxControl returns snapshot read-only transaction control

func StaleReadOnlyTxControl

func StaleReadOnlyTxControl() *TransactionControl

StaleReadOnlyTxControl returns stale read-only transaction control

func TxControl

func TxControl(opts ...tx.ControlOption) *TransactionControl

TxControl makes transaction control from given options

type TransactionOption added in v3.74.0

type TransactionOption = tx.Option

func WithDefaultTxMode

func WithDefaultTxMode() TransactionOption

func WithOnlineReadOnly

func WithOnlineReadOnly(opts ...tx.OnlineReadOnlyOption) TransactionOption

func WithSerializableReadWrite

func WithSerializableReadWrite() TransactionOption

func WithSnapshotReadOnly

func WithSnapshotReadOnly() TransactionOption

func WithStaleReadOnly

func WithStaleReadOnly() TransactionOption

type TransactionSettings

type TransactionSettings = tx.Settings

func TxSettings

func TxSettings(opts ...tx.Option) TransactionSettings

TxSettings returns transaction settings

type TxActor

type TxActor interface {
	tx.Identifier

	// Execute executes query.
	//
	// Execute used by default:
	// - DefaultTxControl
	// - flag WithKeepInCache(true) if params is not empty.
	Execute(ctx context.Context, query string, opts ...options.TxExecuteOption) (r Result, err error)

	// ReadRow is a helper which read only one row from first result set in result
	//
	// ReadRow returns error if result contains more than one result set or more than one row
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	ReadRow(ctx context.Context, query string, opts ...options.TxExecuteOption) (Row, error)

	// ReadResultSet is a helper which read all rows from first result set in result
	//
	// ReadRow returns error if result contains more than one result set
	//
	// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
	ReadResultSet(ctx context.Context, query string, opts ...options.TxExecuteOption) (ResultSet, error)
}

type TxOperation

type TxOperation func(ctx context.Context, tx TxActor) error

TxOperation is the interface that holds an operation for retry. if TxOperation returns not nil - operation will retry if TxOperation returns nil - retry loop will break

type Type added in v3.73.0

type Type = types.Type

Jump to

Keyboard shortcuts

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