rdsdata

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 23 Imported by: 0

README

RDS Data

Parity grade: A · SDK aws-sdk-go-v2/service/rdsdata@v1.32.19 · last audited 2026-07-23 (9419636f)

Coverage

Metric Value
Operations audited 6 (6 ok)
Feature families 5 (5 ok)
Known gaps 2
Deferred items 0
Resource leaks clean
Known gaps
  • "SqlParameter.typeHint (DATE/DECIMAL/JSON/TIME/TIMESTAMP/UUID) is accepted on the wire but does not change bind behavior -- the mock SQLite engine has no distinct DATE/TIMESTAMP/UUID column types to convert strings into, so a DATE-hinted value binds identically to an unhinted string. Re-examined this pass and deliberately NOT implemented: real AWS's exact behavior for a malformed hinted value (which error class, and whether it's a request-time or DB-execution-time failure) is not independently verifiable without a live Aurora cluster, and inventing that mapping would risk exactly the kind of gopherstack-invented error semantics this audit is supposed to catch. Only matters if a test asserts on hint-driven type coercion or validation."
  • "ColumnMetadata.SchemaName/TableName/IsAutoIncrement/ArrayBaseColumnType are always zero-valued. database/sql's sql.ColumnType (the only introspection the pure-Go modernc.org/sqlite driver exposes) has no origin-table/schema/autoincrement accessor, so there is no real signal to populate them from without a hand-rolled SQL catalog query per column keyed by the column's origin table -- which sql.ColumnType also does not expose. (Contrast with generatedFields/UpdateResult, which needed the origin table but got it for free by parsing it out of the INSERT statement itself; a SELECT's result columns have no such textual anchor in the general case, e.g. SELECT * FROM t JOIN u.)"

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransactionNotFound is returned when a transaction does not exist.
	ErrTransactionNotFound = awserr.New("TransactionNotFoundException", awserr.ErrNotFound)
	// ErrValidation is returned when input validation fails.
	ErrValidation = awserr.New("BadRequestException", awserr.ErrInvalidParameter)
)
View Source
var ErrNilAppContext = errors.New("nil AppContext passed to RDSData Provider.Init")

ErrNilAppContext is returned by Init when a nil AppContext is passed.

Functions

This section is empty.

Types

type ArrayValue added in v1.2.0

type ArrayValue struct {
	ArrayValues   []ArrayValue `json:"arrayValues,omitempty"`
	BooleanValues []bool       `json:"booleanValues,omitempty"`
	DoubleValues  []float64    `json:"doubleValues,omitempty"`
	LongValues    []int64      `json:"longValues,omitempty"`
	StringValues  []string     `json:"stringValues,omitempty"`
}

ArrayValue represents an array of values, mirroring the real API's ArrayValue union (types.ArrayValue in aws-sdk-go-v2/service/rdsdata). Exactly one member is meaningfully populated at a time, matching the real union's shape.

type ColumnMetadata

type ColumnMetadata struct {
	Name                string `json:"name"`
	Label               string `json:"label"`
	TypeName            string `json:"typeName"`
	SchemaName          string `json:"schemaName"`
	TableName           string `json:"tableName"`
	Type                int32  `json:"type"`
	ArrayBaseColumnType int32  `json:"arrayBaseColumnType"`
	Nullable            int32  `json:"nullable"`
	Precision           int32  `json:"precision"`
	Scale               int32  `json:"scale"`
	IsAutoIncrement     bool   `json:"isAutoIncrement"`
	IsCaseSensitive     bool   `json:"isCaseSensitive"`
	IsCurrency          bool   `json:"isCurrency"`
	IsSigned            bool   `json:"isSigned"`
}

ColumnMetadata describes a single column returned by a SQL statement. Field set mirrors the real RDS Data API shape (types.ColumnMetadata in aws-sdk-go-v2/service/rdsdata); see engine.go's columnMetadataFor for how each field is derived from the pure-Go SQLite driver's limited column introspection.

type ExecutedStatement

type ExecutedStatement struct {
	SQL           string `json:"sql"`
	ResourceARN   string `json:"resourceArn"`
	TransactionID string `json:"transactionId,omitempty"`
}

ExecutedStatement represents a record of an executed SQL statement.

type Field

type Field struct {
	IsNull       *bool       `json:"isNull,omitempty"`
	BooleanValue *bool       `json:"booleanValue,omitempty"`
	LongValue    *int64      `json:"longValue,omitempty"`
	DoubleValue  *float64    `json:"doubleValue,omitempty"`
	StringValue  *string     `json:"stringValue,omitempty"`
	ArrayValue   *ArrayValue `json:"arrayValue,omitempty"`
	BlobValue    []byte      `json:"blobValue,omitempty"`
}

Field represents a single field value in an RDS Data API record.

ArrayValue is modeled for wire completeness (it is a real member of the SDK's Field union -- types.FieldMemberArrayValue) even though this mock can never populate it in a result: real AWS documents "Array parameters are not supported" for ExecuteStatementInput.Parameters (see validateNoArrayParameters in handler.go, which rejects it on the way in), and the pure-Go SQLite driver backing the mock engine never produces an array-typed result column. See PARITY.md.

type Handler

type Handler struct {
	Backend   StorageBackend
	AccountID string
	Region    string
}

Handler is the HTTP handler for the RDS Data REST API.

func NewHandler

func NewHandler(backend StorageBackend) *Handler

NewHandler creates a new RDS Data handler.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the operation name from the request path.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(_ *echo.Context) string

ExtractResource always returns an empty string for the RDS Data API. The resource is identified by a resourceArn in the request body, but parsing the body here would require double-buffering; metrics and logging can rely on ExtractOperation instead.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported RDS Data operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for RDS Data requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all handler and backend state. Useful for test isolation.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches RDS Data API requests. All path-based matches are gated on the SigV4 service name to prevent routing conflicts with other services that share similar REST paths.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

Dead-wiring fix (Phase 3.3): InMemoryBackend already implemented Snapshot/Restore, but Handler never delegated to them, so cli.go's generic setupPersistence (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked RDSData up -- the backend's persistence logic existed but was never invoked. This delegation (matching the mediastore/codecommit/cleanrooms pattern) wires RDSData into persistence for the first time.

type InMemoryBackend

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

InMemoryBackend is an in-memory RDS Data backend.

All resource maps are nested by region (outer key = region) so that same-named resources are isolated across regions. The per-region inner maps / tables are created lazily via the *Store helpers. Callers must hold b.mu while accessing them. See store_setup.go for why transactions is a map[string]*store.Table[Transaction] while executedStatements and txCounter remain plain maps.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new in-memory RDS Data backend.

func (*InMemoryBackend) AccountID

func (b *InMemoryBackend) AccountID() string

AccountID returns the AWS account ID this backend is configured for.

func (*InMemoryBackend) AddTransactionInternal

func (b *InMemoryBackend) AddTransactionInternal(txID string)

AddTransactionInternal directly inserts a transaction into the backend's default region. This is intended only for seeding test data.

func (*InMemoryBackend) BatchExecuteStatement

func (b *InMemoryBackend) BatchExecuteStatement(
	ctx context.Context,
	resourceARN, sql, transactionID string,
	parameterSets [][]SQLParameter,
) ([]UpdateResult, error)

BatchExecuteStatement executes a batch of SQL statements and returns results for each.

func (*InMemoryBackend) BeginTransaction

func (b *InMemoryBackend) BeginTransaction(ctx context.Context, resourceARN string) (string, error)

BeginTransaction starts a new transaction and returns its ID.

func (*InMemoryBackend) CommitTransaction

func (b *InMemoryBackend) CommitTransaction(
	ctx context.Context,
	transactionID string,
) (string, error)

CommitTransaction commits a transaction by ID.

func (*InMemoryBackend) ExecuteSQL

func (b *InMemoryBackend) ExecuteSQL(
	ctx context.Context,
	resourceARN, sqlStatements string,
) ([]SQLStatementResult, error)

ExecuteSQL executes one or more SQL statements against the cluster. This is a deprecated operation; use ExecuteStatement or BatchExecuteStatement instead.

func (*InMemoryBackend) ExecuteStatement

func (b *InMemoryBackend) ExecuteStatement(
	ctx context.Context,
	resourceARN, sql, transactionID string,
	parameters ...SQLParameter,
) ([][]Field, []ColumnMetadata, int64, []Field, error)

ExecuteStatement executes a SQL statement and returns its result set. Named parameters (e.g. ":id") are bound when supplied. The returned generated fields are non-empty only for an INSERT into a table with a single INTEGER PRIMARY KEY column -- see generatedFieldsFor in engine.go.

func (*InMemoryBackend) ListExecutedStatements

func (b *InMemoryBackend) ListExecutedStatements(ctx context.Context) []ExecutedStatement

ListExecutedStatements returns a copy of all executed statements for the request's region.

func (*InMemoryBackend) ListTransactions

func (b *InMemoryBackend) ListTransactions(ctx context.Context) map[string]Transaction

ListTransactions returns a deep copy of all active transactions for the request's region.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all backend state. Useful for test isolation.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot.

func (*InMemoryBackend) RollbackTransaction

func (b *InMemoryBackend) RollbackTransaction(
	ctx context.Context,
	transactionID string,
) (string, error)

RollbackTransaction rolls back a transaction by ID.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON.

type Provider

type Provider struct{}

Provider implements service.Provider for RDS Data.

func (*Provider) Init

Init initializes the RDS Data service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type SQLParameter

type SQLParameter struct {
	Name     string `json:"name"`
	TypeHint string `json:"typeHint,omitempty"`
	Value    Field  `json:"value"`
}

SQLParameter represents a named parameter for a SQL statement. TypeHint mirrors the real API's DATE/DECIMAL/JSON/TIME/TIMESTAMP/UUID hint values; it is accepted on the wire but does not change bind behavior since the mock SQLite engine has no distinct DATE/TIMESTAMP/UUID column types to convert to (see PARITY.md).

type SQLStatementResult

type SQLStatementResult struct {
	NumberOfRecordsUpdated int64 `json:"numberOfRecordsUpdated"`
}

SQLStatementResult represents the result of a single SQL statement in an ExecuteSql call.

type StorageBackend

type StorageBackend interface {
	// Statement execution
	ExecuteStatement(
		ctx context.Context,
		resourceARN, sql, transactionID string,
		parameters ...SQLParameter,
	) ([][]Field, []ColumnMetadata, int64, []Field, error)
	BatchExecuteStatement(
		ctx context.Context,
		resourceARN, sql, transactionID string,
		parameterSets [][]SQLParameter,
	) ([]UpdateResult, error)
	ExecuteSQL(ctx context.Context, resourceARN, sqlStatements string) ([]SQLStatementResult, error)

	// Transaction management
	BeginTransaction(ctx context.Context, resourceARN string) (string, error)
	CommitTransaction(ctx context.Context, transactionID string) (string, error)
	RollbackTransaction(ctx context.Context, transactionID string) (string, error)

	// Introspection helpers (used by tests and dashboard)
	ListExecutedStatements(ctx context.Context) []ExecutedStatement
	ListTransactions(ctx context.Context) map[string]Transaction

	// Lifecycle
	Reset()
	Region() string
	AccountID() string
	Snapshot(ctx context.Context) []byte
	Restore(ctx context.Context, data []byte) error
}

StorageBackend defines the interface for RDS Data backend implementations. All methods must be safe for concurrent use.

type Transaction

type Transaction struct {
	TransactionID string `json:"transactionId"`
	Status        string `json:"status"`
}

Transaction represents an in-progress database transaction.

type UpdateResult

type UpdateResult struct {
	GeneratedFields []Field `json:"generatedFields"`
}

UpdateResult represents the result of a single update in a batch.

GeneratedFields is populated with the rowid-alias INTEGER PRIMARY KEY value assigned by an INSERT, when the target table declares exactly one such column (see generatedFieldsFor in engine.go). It is left empty for every other statement shape, matching real AWS ("generatedFields ... isn't supported by Aurora PostgreSQL").

Jump to

Keyboard shortcuts

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