stdsql

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CellInt64 added in v0.16.0

func CellInt64(v any) (int64, bool)

CellInt64 coerces a raw driver cell to int64, handling the signed/unsigned/ float/text shapes different drivers use for EXPLAIN numeric columns.

func CellString added in v0.16.0

func CellString(v any) (string, bool)

CellString renders a raw driver cell (string, []byte, fmt.Stringer, ...) as a string. Used to pull JSON text out of a single EXPLAIN result cell.

func ExplainRows added in v0.16.0

func ExplainRows(ctx context.Context, db RowQuerier, sql string) (columns []string, rows [][]any, err error)

ExplainRows runs an EXPLAIN-style statement and returns the result column names plus every row as a slice of raw driver values. It is the shared plumbing behind the per-dialect EstimateQuery implementations that read an EXPLAIN result set.

The caller is responsible for passing a statement that only plans the query (EXPLAIN / EXPLAIN ESTIMATE / EXPLAIN USING JSON) and never one that executes it (no EXPLAIN ANALYZE) — EstimateQuery must not run the user's query.

func QueryCustomMetrics

func QueryCustomMetrics(ctx context.Context, db RowQuerier, sqlQuery string, args ...any) ([]*scrapper.CustomMetricsRow, error)

func QueryShape added in v0.8.3

func QueryShape(ctx context.Context, db RowQuerier, sql string) ([]*scrapper.QueryShapeColumn, error)

func RunRawQuery added in v0.13.7

func RunRawQuery(ctx context.Context, db RowQuerier, sqlQuery string) (scrapper.RawQueryRowIterator, error)

RunRawQuery executes sqlQuery and returns an iterator over typed rows. The iterator must be Close()'d by the caller; it also auto-closes on io.EOF.

Unlike QueryCustomMetrics this path preserves every column: segment* names are not sidelined, and string columns come back as StringValue rather than being re-parsed and collapsed to IgnoredValue. Unknown driver types fall back to StringValue(fmt.Sprint(v)) so nothing is silently dropped.

Types

type RawDB added in v0.11.0

type RawDB struct{ DB *sqlx.DB }

RawDB wraps a *sqlx.DB to satisfy RowQuerier without any enrichment. Use this only in tests; production code should pass an executor.

func (*RawDB) QueryRows added in v0.11.0

func (r *RawDB) QueryRows(ctx context.Context, q string, args ...interface{}) (*sqlx.Rows, error)

type RowQuerier added in v0.11.0

type RowQuerier interface {
	QueryRows(ctx context.Context, q string, args ...interface{}) (*sqlx.Rows, error)
}

RowQuerier is the minimal interface for executing queries that return rows. It is satisfied by all StdSqlExecutor implementations (which add SQL comment enrichment, query tagging, and stats collection) and by RawDB for tests.

Jump to

Keyboard shortcuts

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