Documentation
¶
Overview ¶
Package sqlcore holds the duckgres-internal SQL/result interfaces that span the wire-protocol/server layer and the Arrow Flight client. It also hosts a couple of small helpers (IsEmptyQuery, OTELGRPCClientHandler) shared between those layers.
The package has no dependency on github.com/duckdb/duckdb-go, so any caller that wants to operate against duckgres without linking libduckdb (notably the Flight client and a future control-plane-only binary) can import this package without dragging the DuckDB driver in.
Index ¶
- func CatalogFromSearchPath(searchPath string) string
- func IsEmptyQuery(query string) bool
- func OTELGRPCClientHandler() grpc.DialOption
- func ParseQualifiedIdentifier(ref string) ([]string, bool)
- func QuoteIdentifier(s string) string
- func StripLeadingComments(query string) string
- type ColumnTyper
- type CopyFromStdinExecutor
- type ExecResult
- type QueryExecutor
- type RawConn
- type RowSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatalogFromSearchPath ¶
CatalogFromSearchPath returns the catalog from the first search_path entry, or "" when the first entry is an unqualified schema.
func IsEmptyQuery ¶
IsEmptyQuery checks if a query contains only semicolons, whitespace, and/or SQL comments. PostgreSQL returns EmptyQueryResponse for queries like ";", "-- ping", "/* */", etc.
func OTELGRPCClientHandler ¶
func OTELGRPCClientHandler() grpc.DialOption
OTELGRPCClientHandler returns a gRPC StatsHandler that creates spans only for query-related Flight SQL RPCs (GetFlightInfo, DoGet, DoPut), filtering out noisy control-plane calls (DoAction for health checks, session management). DoPut covers ExecuteUpdate (non-result-returning queries: CTAS, INSERT, UPDATE, DELETE, DDL) — without it those queries had no Flight wall-time visibility in traces.
func ParseQualifiedIdentifier ¶
ParseQualifiedIdentifier splits a one-or-more-part SQL identifier, preserving quoted identifier case and lowercasing unquoted identifiers.
func QuoteIdentifier ¶
func StripLeadingComments ¶
StripLeadingComments removes leading SQL comments from a query. Handles both block comments /* ... */ and line comments -- ...
Types ¶
type ColumnTyper ¶
type ColumnTyper interface {
DatabaseTypeName() string
}
ColumnTyper provides type name information for a database column. *sql.ColumnType satisfies this interface.
type CopyFromStdinExecutor ¶
type CopyFromStdinExecutor interface {
CopyFromStdin(ctx context.Context, copySQLTemplate string, csv io.Reader) (rowCount int64, err error)
}
CopyFromStdinExecutor is an optional capability implemented by executors that need the CSV bytes shipped to a different filesystem than the one the COPY FROM STDIN handler is running on. The remote (Flight) executor implements this to spool the bytes onto the worker pod, where the worker can then run COPY FROM <path>. Local executors do not need to implement it; the standard local-tempfile path works for them since the executor and the COPY FROM SQL run in the same process / host.
copySQLTemplate must contain a path placeholder that the receiver substitutes with the destination spool path before executing. The placeholder string is defined alongside the implementation (flightclient.CopyFromStdinPathPlaceholder).
type ExecResult ¶
ExecResult represents the result of a non-query execution.
type QueryExecutor ¶
type QueryExecutor interface {
QueryContext(ctx context.Context, query string, args ...any) (RowSet, error)
ExecContext(ctx context.Context, query string, args ...any) (ExecResult, error)
Query(query string, args ...any) (RowSet, error)
Exec(query string, args ...any) (ExecResult, error)
ConnContext(ctx context.Context) (RawConn, error)
PingContext(ctx context.Context) error
Close() error
// LastProfilingOutput returns the JSON profiling output from the last
// executed query, or "" if profiling is not enabled or not available
// (e.g. Flight SQL mode where the query ran on a remote worker).
LastProfilingOutput() string
}
QueryExecutor abstracts database query execution, allowing both local (*sql.DB) and remote (Arrow Flight SQL) backends.