query

package
v3.117.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusUnknown = Status(iota)
	StatusIdle
	StatusInUse
	StatusClosing
	StatusClosed
	StatusError
)

Variables

View Source
var (
	ErrTransactionRollingBack = xerrors.Wrap(errors.New("the transaction is rolling back"))

	ErrOptionNotForTxExecute = errors.New("option is not for execute on transaction")
)

Functions

func IsAlive added in v3.99.0

func IsAlive(status Status) bool

func MaterializedResultSet added in v3.77.0

func MaterializedResultSet(
	index int,
	columnNames []string,
	columnTypes []types.Type,
	rows []query.Row,
) *materializedResultSet

func Open added in v3.99.0

func Open(
	ctx context.Context, client Ydb_Query_V1.QueryServiceClient, opts ...Option,
) (_ *sessionCore, finalErr error)

Types

type Client

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

func New

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

func (*Client) Config added in v3.101.4

func (c *Client) Config() *config.Config

func (*Client) Do

func (c *Client) Do(ctx context.Context, op query.Operation, opts ...options.DoOption) (finalErr error)

func (*Client) DoTx

func (c *Client) DoTx(ctx context.Context, op query.TxOperation, opts ...options.DoTxOption) (finalErr error)

func (*Client) Exec added in v3.77.0

func (c *Client) Exec(ctx context.Context, q string, opts ...options.Execute) (finalErr error)

func (*Client) ExecuteScript added in v3.77.0

func (c *Client) ExecuteScript(
	ctx context.Context, q string, ttl time.Duration, opts ...options.Execute,
) (
	op *options.ExecuteScriptOperation, err error,
)

func (*Client) FetchScriptResults added in v3.77.0

func (c *Client) FetchScriptResults(ctx context.Context,
	opID string, opts ...options.FetchScriptOption,
) (*options.FetchScriptResult, error)

func (*Client) Query added in v3.77.0

func (c *Client) Query(ctx context.Context, q string, opts ...options.Execute) (r query.Result, err error)

func (*Client) QueryResultSet added in v3.77.0

func (c *Client) QueryResultSet(
	ctx context.Context, q string, opts ...options.Execute,
) (rs result.ClosableResultSet, finalErr error)

QueryResultSet is a helper which read all rows from first result set in result

func (*Client) QueryRow added in v3.77.0

func (c *Client) QueryRow(ctx context.Context, q string, opts ...options.Execute) (_ query.Row, finalErr error)

QueryRow is a helper which read only one row from first result set in result

type Core added in v3.99.0

type Core interface {
	query.SessionInfo
	closer.Closer
	pool.Item

	Done() <-chan struct{}
	SetStatus(code Status)
}

type Option added in v3.99.0

type Option func(*sessionCore)

func OnChangeStatus added in v3.99.0

func OnChangeStatus(onChangeStatus func(status Status)) Option

func WithConn added in v3.99.0

func WithConn(cc grpc.ClientConnInterface) Option

func WithDeleteTimeout added in v3.99.0

func WithDeleteTimeout(deleteTimeout time.Duration) Option

func WithTrace added in v3.99.0

func WithTrace(t *trace.Query) Option

type ResultCloser added in v3.115.6

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

ResultCloser provides a mechanism to close query results and handle cleanup operations. It tracks the reason for closing, provides a done channel for synchronization, and allows registering cleanup functions to be called on close.

func NewResultCloser added in v3.115.6

func NewResultCloser() *ResultCloser

NewResultCloser creates and returns a new ResultCloser instance.

func (*ResultCloser) Close added in v3.115.6

func (r *ResultCloser) Close(reason error)

Close closes the ResultCloser with the specified reason error. If the ResultCloser is already closed, this method does nothing. If reason is nil, it will be set to io.EOF. All registered onClose functions will be called in LIFO order. After calling Close, the done channel will be closed to signal completion.

func (*ResultCloser) CloseOnContextCancel added in v3.115.6

func (r *ResultCloser) CloseOnContextCancel(ctx context.Context) func() bool

CloseOnContextCancel registers a callback function that closes the ResultCloser when the provided context is cancelled. It returns a function that can be used to stop the callback.

func (*ResultCloser) Done added in v3.115.6

func (r *ResultCloser) Done() <-chan struct{}

Done returns a channel that will be closed when the ResultCloser is closed. This channel can be used to wait for the ResultCloser to be closed.

func (*ResultCloser) Err added in v3.115.6

func (r *ResultCloser) Err() error

Err returns the reason error that was passed to Close. If Close has not been called yet, it returns nil.

func (*ResultCloser) OnClose added in v3.115.6

func (r *ResultCloser) OnClose(f func())

OnClose registers a function to be called when the ResultCloser is closed. Multiple functions can be registered and they will be called in LIFO order when Close is called.

type Row added in v3.80.8

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

func NewRow added in v3.69.0

func NewRow(columns []*Ydb.Column, v *Ydb.Value) *Row

func (Row) Scan added in v3.80.8

func (r Row) Scan(dst ...interface{}) error

func (Row) ScanNamed added in v3.80.8

func (r Row) ScanNamed(dst ...scanner.NamedDestination) error

func (Row) ScanStruct added in v3.80.8

func (r Row) ScanStruct(dst interface{}, opts ...scanner.ScanStructOption) error

func (Row) Values added in v3.114.0

func (r Row) Values() []value.Value

type Session

type Session struct {
	Core
	// contains filtered or unexported fields
}

func CreateSession added in v3.89.6

func CreateSession(ctx context.Context, client Ydb_Query_V1.QueryServiceClient, cfg *config.Config) (*Session, error)

func (*Session) Begin

func (s *Session) Begin(
	ctx context.Context,
	txSettings query.TransactionSettings,
) (
	tx query.Transaction, finalErr error,
)

func (*Session) Exec added in v3.77.0

func (s *Session) Exec(ctx context.Context, q string, opts ...options.Execute) (finalErr error)

func (*Session) Query added in v3.77.0

func (s *Session) Query(ctx context.Context, q string, opts ...options.Execute) (_ query.Result, finalErr error)

func (*Session) QueryArrow added in v3.116.0

func (s *Session) QueryArrow(ctx context.Context, q string, opts ...options.Execute) (_ arrow.Result, finalErr error)

QueryArrow like *Session.Query but returns results in Apache Arrow format. Each part of the result implements io.Reader and contains the data in Arrow IPC format.

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

func (*Session) QueryResultSet added in v3.77.0

func (s *Session) QueryResultSet(
	ctx context.Context, q string, opts ...options.Execute,
) (rs result.ClosableResultSet, finalErr error)

func (*Session) QueryRow added in v3.77.0

func (s *Session) QueryRow(ctx context.Context, q string, opts ...options.Execute) (_ query.Row, finalErr error)

type Status added in v3.99.0

type Status uint32

func StatusFromErr added in v3.99.0

func StatusFromErr(err error) Status

func (Status) String added in v3.99.0

func (s Status) String() string

type Transaction added in v3.76.2

type Transaction struct {
	baseTx.LazyID
	// contains filtered or unexported fields
}

func (*Transaction) CommitTx added in v3.76.2

func (tx *Transaction) CommitTx(ctx context.Context) (finalErr error)

func (*Transaction) Exec added in v3.77.0

func (tx *Transaction) Exec(ctx context.Context, q string, opts ...options.Execute) (finalErr error)

func (*Transaction) NodeID added in v3.116.1

func (tx *Transaction) NodeID() uint32

func (*Transaction) OnBeforeCommit added in v3.81.0

func (tx *Transaction) OnBeforeCommit(f baseTx.OnTransactionBeforeCommit)

func (*Transaction) OnCompleted added in v3.76.4

func (tx *Transaction) OnCompleted(f baseTx.OnTransactionCompletedFunc)

func (*Transaction) Query added in v3.77.0

func (tx *Transaction) Query(ctx context.Context, q string, opts ...options.Execute) (_ query.Result, finalErr error)

func (*Transaction) QueryResultSet added in v3.77.0

func (tx *Transaction) QueryResultSet(
	ctx context.Context, q string, opts ...options.Execute,
) (rs result.ClosableResultSet, finalErr error)

func (*Transaction) QueryRow added in v3.77.0

func (tx *Transaction) QueryRow(
	ctx context.Context, q string, opts ...options.Execute,
) (row query.Row, finalErr error)

func (*Transaction) Rollback added in v3.76.2

func (tx *Transaction) Rollback(ctx context.Context) (finalErr error)

func (*Transaction) SessionID added in v3.76.4

func (tx *Transaction) SessionID() string

func (*Transaction) UnLazy added in v3.77.0

func (tx *Transaction) UnLazy(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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