qrouter

package
v0.0.0-...-0caea15 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: PostgreSQL Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ComplexQuery = fmt.Errorf("too complex query to parse")
View Source
var CrossShardQueryUnsupported = fmt.Errorf("cross shard query unsupported")
View Source
var ErrRuleIntersect = fmt.Errorf("sharding rule intersects with existing one")
View Source
var FailedToFindKeyRange = fmt.Errorf("failed to match key with ranges")
View Source
var FailedToMatch = fmt.Errorf("failed to match query to any sharding rule")
View Source
var InformationSchemaCombinedQuery = fmt.Errorf("combined information schema and regular relation is not supported")
View Source
var MatchShardError = fmt.Errorf("failed to match datashard")
View Source
var ParseError = fmt.Errorf("parsing stmt error")
View Source
var ShardingKeysMissing = fmt.Errorf("sharding keys are missing in query")
View Source
var SkipColumn = fmt.Errorf("skip column for routing")

Functions

func ReportStmtDeparsedAttrs

func ReportStmtDeparsedAttrs(ctx context.Context, pi *clientinteractor.PSQLInteractor, meta *RoutingMetadataContext) error

TODO : unit tests

Types

type AnyRelation

type AnyRelation struct{}

type LocalQrouter

type LocalQrouter struct {
	QueryRouter
	// contains filtered or unexported fields
}

func NewLocalQrouter

func NewLocalQrouter(shardMapping map[string]*config.Shard) (*LocalQrouter, error)

func (*LocalQrouter) AddDataShard

func (l *LocalQrouter) AddDataShard(_ context.Context, ds *datashards.DataShard) error

TODO : unit tests

func (*LocalQrouter) Initialize

func (l *LocalQrouter) Initialize() bool

func (*LocalQrouter) Initialized

func (l *LocalQrouter) Initialized() bool

func (*LocalQrouter) ListKeyRanges

func (l *LocalQrouter) ListKeyRanges(ctx context.Context) ([]*kr.KeyRange, error)

func (*LocalQrouter) Route

TODO : unit tests

type ProxyQrouter

type ProxyQrouter struct {
	ColumnMapping map[string]struct{}
	LocalTables   map[string]struct{}

	// shards
	DataShardCfgs  map[string]*config.Shard
	WorldShardCfgs map[string]*config.Shard
	// contains filtered or unexported fields
}

func NewProxyRouter

func NewProxyRouter(shardMapping map[string]*config.Shard, mgr meta.EntityMgr, qcfg *config.QRouter) (*ProxyQrouter, error)

func (*ProxyQrouter) CheckTableIsRoutable

func (qr *ProxyQrouter) CheckTableIsRoutable(ctx context.Context, node *lyx.CreateTable, meta *RoutingMetadataContext) error

CheckTableIsRoutable Given table create statement, check if it is routable with some sharding rule TODO : unit tests

func (*ProxyQrouter) DataShardsRoutes

func (qr *ProxyQrouter) DataShardsRoutes() []*routingstate.DataShardRoute

TODO : unit tests

func (*ProxyQrouter) DeparseExprShardingEntries

func (qr *ProxyQrouter) DeparseExprShardingEntries(expr lyx.Node, meta *RoutingMetadataContext) (string, string, error)

DeparseExprShardingEntries deparses sharding column entries(column names or aliased column names) e.g {fields:{string:{str:"a"}} fields:{string:{str:"i"}} for `WHERE a.i = 1` returns alias and column name

func (*ProxyQrouter) DeparseKeyWithRangesInternal

func (qr *ProxyQrouter) DeparseKeyWithRangesInternal(_ context.Context, key string, krs []*kr.KeyRange) (*routingstate.DataShardRoute, error)

TODO : unit tests

func (*ProxyQrouter) DeparseSelectStmt

func (qr *ProxyQrouter) DeparseSelectStmt(ctx context.Context, selectStmt lyx.Node, meta *RoutingMetadataContext) error

TODO : unit tests

func (*ProxyQrouter) Explain

TODO : unit tests

func (*ProxyQrouter) Initialize

func (qr *ProxyQrouter) Initialize() bool

func (*ProxyQrouter) Initialized

func (qr *ProxyQrouter) Initialized() bool

func (*ProxyQrouter) Mgr

func (qr *ProxyQrouter) Mgr() meta.EntityMgr

func (*ProxyQrouter) RecordDistributionKeyColumnValue

func (qr *ProxyQrouter) RecordDistributionKeyColumnValue(meta *RoutingMetadataContext, alias, colname, value string) error

func (*ProxyQrouter) RecordDistributionKeyColumnValueOnRFQN

func (qr *ProxyQrouter) RecordDistributionKeyColumnValueOnRFQN(meta *RoutingMetadataContext, resolvedRelation RelationFQN, colname, value string) error

func (*ProxyQrouter) RecordDistributionKeyExprOnRFQN

func (qr *ProxyQrouter) RecordDistributionKeyExprOnRFQN(meta *RoutingMetadataContext, resolvedRelation RelationFQN, colname string, expr lyx.Node) error

TODO : unit tests

func (*ProxyQrouter) Route

TODO : unit tests

func (*ProxyQrouter) WorldShardsRoutes

func (qr *ProxyQrouter) WorldShardsRoutes() []*routingstate.DataShardRoute

TODO : unit tests

type QueryRouter

type QueryRouter interface {
	Route(ctx context.Context, stmt lyx.Node, sph session.SessionParamsHolder) (routingstate.RoutingState, error)

	WorldShardsRoutes() []*routingstate.DataShardRoute
	DataShardsRoutes() []*routingstate.DataShardRoute

	DeparseKeyWithRangesInternal(ctx context.Context, key string, krs []*kr.KeyRange) (*routingstate.DataShardRoute, error)

	Initialized() bool
	Initialize() bool

	Mgr() meta.EntityMgr
}

func NewQrouter

func NewQrouter(qtype config.RouterMode, shardMapping map[string]*config.Shard, mgr meta.EntityMgr, qcfg *config.QRouter) (QueryRouter, error)

type RelationFQN

type RelationFQN struct {
	RelationName string
	SchemaName   string
}

func RelationFQNFromRangeRangeVar

func RelationFQNFromRangeRangeVar(rv *lyx.RangeVar) RelationFQN

type RelationList

type RelationList struct {
	Relations []string
}

type RoutingMetadataContext

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

func NewRoutingMetadataContext

func NewRoutingMetadataContext(params [][]byte, paramsFormatCodes []int16) *RoutingMetadataContext

func (*RoutingMetadataContext) RFQNIsCTE

func (meta *RoutingMetadataContext) RFQNIsCTE(resolvedRelation RelationFQN) bool

func (*RoutingMetadataContext) RecordConstExpr

func (meta *RoutingMetadataContext) RecordConstExpr(resolvedRelation RelationFQN, colname string, expr string) error

TODO : unit tests

func (*RoutingMetadataContext) ResolveRelationByAlias

func (meta *RoutingMetadataContext) ResolveRelationByAlias(alias string) (RelationFQN, error)

TODO : unit tests

type SpecificRelation

type SpecificRelation struct {
	Name string
}

type StatementRelation

type StatementRelation interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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