infrastructure

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package infrastructure provides enterprise-grade JDBC compatibility for Porter.

Package infrastructure provides enterprise-grade infrastructure services for Porter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnhancedSQLInfoProvider

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

EnhancedSQLInfoProvider provides comprehensive SQL information for enterprise JDBC clients.

func NewEnhancedSQLInfoProvider

func NewEnhancedSQLInfoProvider(allocator memory.Allocator) *EnhancedSQLInfoProvider

NewEnhancedSQLInfoProvider creates a new enhanced SQL info provider.

func (*EnhancedSQLInfoProvider) GetSQLInfo

func (p *EnhancedSQLInfoProvider) GetSQLInfo(infoTypes []uint32) (arrow.Record, error)

GetSQLInfo returns SQL information for the given info types.

type JDBCCompatibilityLayer

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

JDBCCompatibilityLayer provides enterprise-grade JDBC compatibility features.

func NewJDBCCompatibilityLayer

func NewJDBCCompatibilityLayer(
	allocator memory.Allocator,
	logger zerolog.Logger,
	config JDBCConfig,
	metrics JDBCMetrics,
) *JDBCCompatibilityLayer

NewJDBCCompatibilityLayer creates a new enterprise-grade JDBC compatibility layer.

func (*JDBCCompatibilityLayer) ClassifyStatementForJDBC

func (j *JDBCCompatibilityLayer) ClassifyStatementForJDBC(sql string) (services.StatementType, JDBCStatementInfo, error)

ClassifyStatementForJDBC classifies SQL statements with JDBC-specific handling.

func (*JDBCCompatibilityLayer) CreateJDBCCompatibleFlightInfo

func (j *JDBCCompatibilityLayer) CreateJDBCCompatibleFlightInfo(
	ctx context.Context,
	sql string,
	schema *arrow.Schema,
	stmtType services.StatementType,
) (*flight.FlightInfo, error)

CreateJDBCCompatibleFlightInfo creates FlightInfo with JDBC-compatible metadata.

func (*JDBCCompatibilityLayer) CreateUpdateCountResult

func (j *JDBCCompatibilityLayer) CreateUpdateCountResult(rowsAffected int64) (*arrow.Schema, <-chan flight.StreamChunk, error)

CreateUpdateCountResult creates a JDBC-compatible update count result.

func (*JDBCCompatibilityLayer) GetEnhancedSQLInfo

func (j *JDBCCompatibilityLayer) GetEnhancedSQLInfo(infoTypes []uint32) (arrow.Record, error)

GetEnhancedSQLInfo returns comprehensive SQL information for JDBC clients.

func (*JDBCCompatibilityLayer) ValidateStatement

func (j *JDBCCompatibilityLayer) ValidateStatement(ctx context.Context, sql string) error

ValidateStatement performs enterprise-grade SQL statement validation.

type JDBCConfig

type JDBCConfig struct {
	StrictCompliance        bool          `yaml:"strict_compliance"`
	EnableStatementCaching  bool          `yaml:"enable_statement_caching"`
	StatementCacheSize      int           `yaml:"statement_cache_size"`
	StatementTimeout        time.Duration `yaml:"statement_timeout"`
	MaxStatementLength      int           `yaml:"max_statement_length"`
	EnableQueryValidation   bool          `yaml:"enable_query_validation"`
	EnableMetricsCollection bool          `yaml:"enable_metrics_collection"`
	ErrorDetailLevel        string        `yaml:"error_detail_level"` // "minimal", "standard", "verbose"
}

JDBCConfig holds configuration for JDBC compatibility features.

type JDBCErrorMapper

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

JDBCErrorMapper provides enterprise-grade error mapping for JDBC compatibility.

func NewJDBCErrorMapper

func NewJDBCErrorMapper(detailLevel string) *JDBCErrorMapper

NewJDBCErrorMapper creates a new JDBC error mapper.

func (*JDBCErrorMapper) MapError

func (m *JDBCErrorMapper) MapError(err error) error

MapError maps internal errors to JDBC-compatible error messages.

type JDBCMetrics

type JDBCMetrics interface {
	IncrementStatementCount(stmtType string)
	RecordStatementExecutionTime(stmtType string, duration time.Duration)
	IncrementErrorCount(errorType string)
	RecordRowsAffected(count int64)
	IncrementCacheHit()
	IncrementCacheMiss()

	// Extended methods for enterprise features
	RecordQueryComplexity(stmtType string, complexityScore float64)
	RecordResultSetSize(stmtType string, sizeBytes int64)
	UpdateActiveConnections(count int)
	UpdateActiveTransactions(count int)
	UpdateCacheSize(size int)
	UpdateMemoryUsage(bytes int64)
}

JDBCMetrics interface for JDBC-specific metrics collection. This interface is implemented by EnterpriseJDBCMetrics for full functionality.

type JDBCStatementInfo

type JDBCStatementInfo struct {
	Type                services.StatementType
	ExpectsResultSet    bool
	ExpectsUpdateCount  bool
	RequiresTransaction bool
	IsReadOnly          bool
	EstimatedComplexity services.StatementComplexity
	SecurityRisk        services.SecurityRiskLevel
	IsDangerous         bool
	Keywords            []string
	Tables              []string
	Operations          []string
}

JDBCStatementInfo provides detailed information about SQL statements for JDBC compatibility.

type SQLInfoProvider

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

SQLInfoProvider exposes DuckDB/Porter SQL capabilities.

func NewSQLInfoProvider

func NewSQLInfoProvider(alloc memory.Allocator) *SQLInfoProvider

NewSQLInfoProvider returns a ready‑to‑use provider.

func (*SQLInfoProvider) GetSQLInfo

func (p *SQLInfoProvider) GetSQLInfo(ids []uint32) ([]models.SQLInfo, error)

GetSQLInfo implements the Flight SQL "GetSqlInfo" RPC semantics.

func (*SQLInfoProvider) GetSQLInfoResultMap

func (p *SQLInfoProvider) GetSQLInfoResultMap() flightsql.SqlInfoResultMap

GetSQLInfoResultMap returns the provider's internal map in Flight format. Map is copied to avoid caller mutation.

type Searchability

type Searchability int32

Searchability describes how a type can appear in WHERE clauses.

const (
	SearchableNone Searchability = iota
	SearchableLike
	SearchableNoLike
	SearchableFull
)

type XdbcTypeInfoProvider

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

XdbcTypeInfoProvider serves XDBC type metadata.

func NewXdbcTypeInfoProvider

func NewXdbcTypeInfoProvider() *XdbcTypeInfoProvider

NewXdbcTypeInfoProvider constructs with built‑in Porter/DuckDB types.

func (*XdbcTypeInfoProvider) GetTypeInfo

func (p *XdbcTypeInfoProvider) GetTypeInfo(dataType *int32) []models.XdbcTypeInfo

GetTypeInfo filters by dataType when provided.

func (*XdbcTypeInfoProvider) GetTypeInfoResult

func (p *XdbcTypeInfoProvider) GetTypeInfoResult(alloc memory.Allocator, dt *int32) arrow.Record

GetTypeInfoResult builds an Arrow record for the XDBC response.

Directories

Path Synopsis
Package converter provides type conversion between DuckDB and Apache Arrow.
Package converter provides type conversion between DuckDB and Apache Arrow.
Package metrics provides metrics collection for the Flight SQL server.
Package metrics provides metrics collection for the Flight SQL server.
Package pool provides database connection pooling for DuckDB.
Package pool provides database connection pooling for DuckDB.

Jump to

Keyboard shortcuts

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