Documentation
¶
Overview ¶
Package queryaccess defines application-level contracts for query access analysis. input: SQL text, dialect, mode, and optional schema resolver output: domain-typed query access results for transport adapters pos: application contract layer for the query access analysis foundation note: if this file changes, update this header and module README.md.
Package queryaccess defines application-level contracts for query access analysis. input: SQL text, dialect, mode, and optional schema resolver output: domain-typed query access results for transport adapters pos: application contract layer for the query access analysis foundation note: if this file changes, update this header and module README.md.
Package queryaccess provides the PostgreSQL query access stub when built without the postgresql tag. input: none (stub only) output: ErrPostgreSQLNotAvailable for all calls pos: application stub for non-PostgreSQL builds note: if this file changes, update this header and module README.md.
Package queryaccess provides TiDB query access extraction bridging infrastructure facts to domain types. input: SQL text, dialect, mode, default schema, and optional schema resolver output: domain-typed query access results for transport adapters pos: application adapter bridging TiDB infrastructure query access facts to domain query access types note: if this file changes, update this header and module README.md.
Package queryaccess implements requirement generation for query access analysis. input: resolved query access facts (relations, columns, outputs, unresolved) and mode output: access requirements, warnings, and reason codes pos: application requirement layer bridging resolved facts to permission requirements note: if this file changes, update this header and module README.md.
Package queryaccess implements metadata-backed resolution for query access analysis. input: domain Result with extracted facts, SchemaResolver for metadata lookup output: enriched Result with resolved wildcards, columns, aliases, and lineage pos: application resolution layer bridging extracted facts to metadata-resolved results note: if this file changes, update this header and module README.md.
Package queryaccess provides the application service for query access analysis. input: SQL text, dialect, mode, default schema, and optional schema resolver output: domain-typed query access results with optional metadata resolution pos: application orchestration layer for query access analysis note: if this file changes, update this header and module README.md.
Index ¶
- Constants
- Variables
- func BuildRequirements(mode domain.Mode, relations []domain.RelationReference, ...) ([]domain.Requirement, []domain.WarningCode, []domain.ReasonCode, error)
- func FormatRelationSchemaKey(schema, name string) string
- func NewResolutionState(ctx context.Context, resolver SchemaResolver, dialect, defaultSchema string, ...) *resolutionState
- func ResolveMetadata(ctx context.Context, resolver SchemaResolver, dialect, defaultSchema string, ...) domain.Result
- type ColumnSchema
- type QueryAccessRequest
- type QueryAccessResult
- type RelationSchema
- type SchemaResolver
- type Service
Constants ¶
const ( ReasonMissingMetadata domain.ReasonCode = "missing_metadata" ReasonRelationNotFound domain.ReasonCode = "relation_not_found" ReasonColumnNotFound domain.ReasonCode = "column_not_found" ReasonAmbiguousColumn domain.ReasonCode = "ambiguous_column" ReasonRelationAmbiguous domain.ReasonCode = "relation_ambiguous" ReasonUnresolvedWildcard domain.ReasonCode = "unresolved_wildcard" ReasonUnresolvedAlias domain.ReasonCode = "unresolved_alias" )
UnresolvedReason constants for bounded unresolved tracking.
Variables ¶
var ErrExtractionFailed = errors.New("query access extraction failed")
ErrExtractionFailed indicates query access extraction failed without exposing SQL text.
var ErrPostgreSQLNotAvailable = errors.New("postgresql support requires build tag: go build -tags postgresql")
ErrPostgreSQLNotAvailable indicates PostgreSQL support was not compiled in.
Functions ¶
func BuildRequirements ¶
func BuildRequirements( mode domain.Mode, relations []domain.RelationReference, columns []domain.ColumnReference, outputs []domain.OutputColumn, unresolved []domain.Unresolved, ) ([]domain.Requirement, []domain.WarningCode, []domain.ReasonCode, error)
BuildRequirements exposes requirement generation for testing.
func FormatRelationSchemaKey ¶
FormatRelationSchemaKey returns a cache key for a relation schema lookup.
func NewResolutionState ¶
func NewResolutionState(ctx context.Context, resolver SchemaResolver, dialect, defaultSchema string, relations []domain.RelationReference) *resolutionState
NewResolutionState creates a resolution state for testing.
func ResolveMetadata ¶
func ResolveMetadata(ctx context.Context, resolver SchemaResolver, dialect, defaultSchema string, result domain.Result) domain.Result
ResolveMetadata exposes the metadata resolution for testing.
Types ¶
type ColumnSchema ¶
ColumnSchema contains metadata about a column.
type QueryAccessRequest ¶
type QueryAccessRequest struct {
SQL string
Dialect string
Mode string
DefaultSchema string
SchemaResolver SchemaResolver // optional
}
QueryAccessRequest is the input for query access analysis.
type QueryAccessResult ¶
QueryAccessResult wraps the domain result for application-layer consumption.
func AnalyzePostgreSQL ¶
func AnalyzePostgreSQL(_ context.Context, _ QueryAccessRequest) (QueryAccessResult, error)
AnalyzePostgreSQL returns ErrPostgreSQLNotAvailable when built without the postgresql tag.
func ExtractTiDBQueryAccess ¶
func ExtractTiDBQueryAccess(ctx context.Context, req QueryAccessRequest) (QueryAccessResult, error)
ExtractTiDBQueryAccess extracts query access facts from TiDB SQL and converts to domain types.
type RelationSchema ¶
type RelationSchema struct {
Schema string
Name string
Kind string // "table" or "view"
Columns []ColumnSchema
IsView bool
}
RelationSchema contains metadata about a relation for resolution.
type SchemaResolver ¶
type SchemaResolver interface {
ResolveRelation(ctx context.Context, dialect string, schema, name string) (RelationSchema, error)
}
SchemaResolver resolves relation metadata for name resolution.
type Service ¶
type Service struct{}
Service orchestrates query access analysis.
func (*Service) Analyze ¶
func (s *Service) Analyze(ctx context.Context, req QueryAccessRequest) (QueryAccessResult, error)
Analyze performs query access analysis with optional metadata resolution. When SchemaResolver is nil, wildcards and unqualified columns remain unresolved.