Documentation ¶
Index ¶
- Variables
- func ConvertAndMask(sc *stmtctx.StatementContext, datum types.Datum, toType *types.FieldType, ...) (types.Datum, *types.FieldType, error)
- func NewDefaultDictionary() *dict.Dictionary
- type CastGraph
- type CastGraphBuilder
- type CastNode
- type EventWorker
- type Expr
- type ExprMap
- type ExprOffsetMap
- type InferredType
- type MaskFunc
- type NameMap
- type Node
- type NormalNode
- type Prepared
- type PreparedMap
- type ReplaceMarker
- type ReplaceMode
- type ReplaceVisitor
- type RestoreMode
- type RestoreVisitor
- type SQLWorker
- type Stats
- type TypeMap
Constants ¶
This section is empty.
Variables ¶
var MaskFuncMap = map[string]MaskFunc{ "workload-sim": {"For workload simulation project", funcs.WorkloadSimMask}, "debug": {"Replace every constant with its inferred type, for debug usage", funcs.DebugMask}, "debug-color": {"Like `debug`, but in ANSI color", funcs.DebugMaskColor}, "identical": {"Dry-run baseline", funcs.IdenticalMask}, }
All mask functions
Functions ¶
func ConvertAndMask ¶
func ConvertAndMask(sc *stmtctx.StatementContext, datum types.Datum, toType *types.FieldType, maskFunc MaskFunc) (types.Datum, *types.FieldType, error)
Convert `datum` to `toType` and then mask using `maskFunc`, returns new datum and its coresponding type
func NewDefaultDictionary ¶
func NewDefaultDictionary() *dict.Dictionary
Types ¶
type CastGraph ¶
func (*CastGraph) InferType ¶
func (g *CastGraph) InferType(c *expression.Constant) *InferredType
type CastGraphBuilder ¶
type CastGraphBuilder struct { Constants []*expression.Constant Columns []*expression.Column Handles []kv.Handle Graph *CastGraph }
A visitor for physical plans, which extract sconstants for masking, and builds a `CastGraph` for inferring types
func NewCastGraphBuilder ¶
func NewCastGraphBuilder() *CastGraphBuilder
func (*CastGraphBuilder) Build ¶
func (b *CastGraphBuilder) Build(plan plannercore.Plan) error
type EventWorker ¶
type EventWorker struct {
// contains filtered or unexported fields
}
func NewEventWorker ¶
func NewEventWorker(db *tidb.Context, maskFunc MaskFunc, ignoreIntPK bool, nameMap *NameMap) *EventWorker
Create a mask worker for MySQL Events
func (*EventWorker) MaskOne ¶
func (w *EventWorker) MaskOne(ev event.MySQLEvent) (event.MySQLEvent, error)
func (*EventWorker) MaskOneExecute ¶
func (w *EventWorker) MaskOneExecute(stmtID uint64, params []interface{}) ([]interface{}, error)
For type `StmtExecute`, lookup prepared analysis from `w.preparedStmts` and mask parameters
func (*EventWorker) PrepareOne ¶
func (w *EventWorker) PrepareOne(stmtID uint64, sql string) (string, error)
For type `StmtPrepare`, do not evaluate but only analyze it and store into `w.preparedStmts`
type Expr ¶
type Expr = expression.Expression
type ExprMap ¶
type ExprMap = map[ReplaceMarker]*driver.ValueExpr
type ExprOffsetMap ¶
type ExprOffsetMap = map[ReplaceMarker]int
type InferredType ¶
func NewInferredType ¶
func NewInferredType(ft *types.FieldType) *InferredType
func NewIntHandleInferredType ¶
func NewIntHandleInferredType() *InferredType
func (InferredType) IsPrimaryKey ¶
func (it InferredType) IsPrimaryKey() bool
type MaskFunc ¶
type MaskFunc struct { Description string // contains filtered or unexported fields }
type NameMap ¶
type NameMap struct { DBs map[string]string `json:"dbs"` Tables map[string]string `json:"tables"` Columns map[string]string `json:"columns"` // contains filtered or unexported fields }
func NewGlobalNameMap ¶
func NewLocalNameMap ¶
func (*NameMap) ColumnName ¶
func (m *NameMap) ColumnName(name *ast.ColumnName) *ast.ColumnName
type NormalNode ¶
type NormalNode struct { Node // contains filtered or unexported fields }
type PreparedMap ¶
type ReplaceMarker ¶
type ReplaceMarker int64
func (ReplaceMarker) IntValue ¶
func (m ReplaceMarker) IntValue() int64
type ReplaceMode ¶
type ReplaceMode int
const ( ReplaceModeValue ReplaceMode = iota ReplaceModeParamMarker )
type ReplaceVisitor ¶
type ReplaceVisitor struct { OriginExprs ExprMap Offsets ExprOffsetMap // contains filtered or unexported fields }
Replace constants with disjoint numbers as `ReplaceMarker`s.
For normal statements, replace values with `Value` mode. For handling `PREPARE` statements internally, we may replace values with `ParamMarker` mode.
func NewReplaceVisitor ¶
func NewReplaceVisitor(mode ReplaceMode) *ReplaceVisitor
type RestoreMode ¶
type RestoreMode int
const ( RestoreModeNameValue RestoreMode = iota RestoreModeNameOnly )
type RestoreVisitor ¶
type RestoreVisitor struct {
// contains filtered or unexported fields
}
In replace phase, we replace constants with disjoint numbers as `ReplaceMarker`s in order to infer types of them and construct a `TypeMap`.
`RestoreVisitor` will traverse the AST, restoring and masking constants based on information from `ExprMap` and `TypeMap`. Also in restore phase, names may need to be masked if `nameMap` is given.
Note that for `?` in PREPARE statements, there's neither way nor need to restore them, so an option of `RestoreMode` with two variants `NameValue` and `NameOnly` is provided.
func NewNameOnlyRestoreVisitor ¶
func NewNameOnlyRestoreVisitor(nameMap *NameMap) *RestoreVisitor
Create a `RestoreVisitor` with mode `NameOnly`, which ignores restoring of constant values
func NewRestoreVisitor ¶
func NewRestoreVisitor(originExprs ExprMap, inferredTypes TypeMap, maskFunc MaskFunc, nameMap *NameMap, ignoreIntPK bool) *RestoreVisitor
Create a `RestoreVisitor` with mode `NameValue`
type SQLWorker ¶
type SQLWorker struct {
// contains filtered or unexported fields
}
func NewSQLWorker ¶
type Stats ¶
func (Stats) PrintSummary ¶
func (s Stats) PrintSummary()
type TypeMap ¶
type TypeMap = map[ReplaceMarker]*InferredType