Documentation
¶
Overview ¶
Package db provides SQL execution against CockroachDB for the MCP server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidConfig = errors.New("invalid adapter configuration")
ErrInvalidConfig marks operator configuration errors that should surface as a clean stderr message rather than a structured log entry.
Functions ¶
func IsInsufficientPrivilege ¶
IsInsufficientPrivilege reports whether err carries SQLSTATE 42501.
func SafeFormat ¶
SafeFormat substitutes %N placeholders with quoted args: SQLStringer values render themselves, strings become SQL literals, int64 renders as decimal. Each placeholder must be preceded by punctuation, whitespace, or '=' so that `col%1` cannot silently become `col'value'`.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter centralizes connection pooling and SQL execution against CockroachDB.
func NewAdapter ¶
NewAdapter creates a new pgxpool-backed adapter and verifies connectivity.
type Config ¶
type Config struct {
DSN string
QueryTimeout time.Duration
// ReadOnly forces every pool session into read-only mode at SQL layer.
ReadOnly bool
// AllowPasswordAuth permits password-based connections when true; rejected
// by default to keep credentials out of the agent host environment.
AllowPasswordAuth bool
MaxConns int32
TxnQoS string
}
Config is the subset of server configuration the adapter needs to open a pool. It is intentionally narrow so the adapter does not depend on the config package.
type Identifier ¶
type Identifier string
Identifier renders as a double-quoted SQL identifier via lexbase.
func (Identifier) SQLString ¶
func (i Identifier) SQLString() string
SQLString implements SQLStringer.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the high-level facade used by MCP tool handlers.
func NewManager ¶
NewManager opens an adapter using the provided server config.
type QualifiedIdentifier ¶
type QualifiedIdentifier []string
QualifiedIdentifier renders as dot-joined quoted identifiers ("db"."schema"."tbl").
func (QualifiedIdentifier) SQLString ¶
func (q QualifiedIdentifier) SQLString() string
SQLString implements SQLStringer.
type QueryResult ¶
QueryResult is the projection of a query result returned to tool handlers.
type SQL ¶
type SQL string
SQL is a raw SQL fragment inlined verbatim. The caller is responsible for the safety of its contents.
type SQLStringer ¶
type SQLStringer interface {
SQLString() string
}
SQLStringer renders itself as a SQL fragment (identifier, literal, or raw SQL).