Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateBindSQL(ctx context.Context, stmtNode ast.StmtNode, planHint string) string
- type BindHandle
- func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) (err error)
- func (h *BindHandle) AddDropInvalidBindTask(invalidBindRecord *BindRecord)
- func (h *BindHandle) AddEvolvePlanTask(originalSQL, DB string, binding Binding)
- func (h *BindHandle) CaptureBaselines()
- func (h *BindHandle) Clear()
- func (h *BindHandle) CreateBindRecord(sctx sessionctx.Context, record *BindRecord) (err error)
- func (h *BindHandle) DropBindRecord(originalSQL, db string, binding *Binding) (err error)
- func (h *BindHandle) DropInvalidBindRecord()
- func (h *BindHandle) FlushBindings() error
- func (h *BindHandle) GetAllBindRecord() (bindRecords []*BindRecord)
- func (h *BindHandle) GetBindRecord(hash, normdOrigSQL, db string) *BindRecord
- func (h *BindHandle) HandleEvolvePlanTask(sctx sessionctx.Context, adminEvolve bool) error
- func (h *BindHandle) ReloadBindings() error
- func (h *BindHandle) SaveEvolveTasksToStore()
- func (h *BindHandle) Size() int
- func (h *BindHandle) Update(fullLoad bool) (err error)
- type BindRecord
- type Binding
- type SessionHandle
- func (h *SessionHandle) Close()
- func (h *SessionHandle) CreateBindRecord(sctx sessionctx.Context, record *BindRecord) (err error)
- func (h *SessionHandle) DropBindRecord(originalSQL, db string, binding *Binding) error
- func (h *SessionHandle) GetAllBindRecord() (bindRecords []*BindRecord)
- func (h *SessionHandle) GetBindRecord(normdOrigSQL, db string) *BindRecord
Constants ¶
const ( // Using is the bind info's in use status. Using = "using" // Invalid is the bind info's invalid status. Invalid = "invalid" // PendingVerify means the bind info needs to be verified. PendingVerify = "pending verify" // Rejected means that the bind has been rejected after verify process. // We can retry it after certain time has passed. Rejected = "rejected" )
const ( // OwnerKey is the bindinfo owner path that is saved to etcd. OwnerKey = "/tidb/bindinfo/owner" // Prompt is the prompt for bindinfo owner manager. Prompt = "bindinfo" )
const SessionBindInfoKeyType sessionBindInfoKeyType = 0
SessionBindInfoKeyType is a variable key for store session bind info.
Variables ¶
var Lease = 3 * time.Second
Lease influences the duration of loading bind info and handling invalid bind.
Functions ¶
Types ¶
type BindHandle ¶
type BindHandle struct {
// contains filtered or unexported fields
}
BindHandle is used to handle all global sql bind operations.
func NewBindHandle ¶
func NewBindHandle(ctx sessionctx.Context) *BindHandle
NewBindHandle creates a new BindHandle.
func (*BindHandle) AddBindRecord ¶
func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, record *BindRecord) (err error)
AddBindRecord adds a BindRecord to the storage and BindRecord to the cache.
func (*BindHandle) AddDropInvalidBindTask ¶
func (h *BindHandle) AddDropInvalidBindTask(invalidBindRecord *BindRecord)
AddDropInvalidBindTask adds BindRecord which needs to be deleted into invalidBindRecordMap.
func (*BindHandle) AddEvolvePlanTask ¶
func (h *BindHandle) AddEvolvePlanTask(originalSQL, DB string, binding Binding)
AddEvolvePlanTask adds the evolve plan task into memory cache. It would be flushed to store periodically.
func (*BindHandle) CaptureBaselines ¶
func (h *BindHandle) CaptureBaselines()
CaptureBaselines is used to automatically capture plan baselines.
func (*BindHandle) Clear ¶
func (h *BindHandle) Clear()
Clear resets the bind handle. It is only used for test.
func (*BindHandle) CreateBindRecord ¶
func (h *BindHandle) CreateBindRecord(sctx sessionctx.Context, record *BindRecord) (err error)
CreateBindRecord creates a BindRecord to the storage and the cache. It replaces all the exists bindings for the same normalized SQL.
func (*BindHandle) DropBindRecord ¶
func (h *BindHandle) DropBindRecord(originalSQL, db string, binding *Binding) (err error)
DropBindRecord drops a BindRecord to the storage and BindRecord int the cache.
func (*BindHandle) DropInvalidBindRecord ¶
func (h *BindHandle) DropInvalidBindRecord()
DropInvalidBindRecord executes the drop BindRecord tasks.
func (*BindHandle) FlushBindings ¶
func (h *BindHandle) FlushBindings() error
FlushBindings flushes the BindRecord in temp maps to storage and loads them into cache.
func (*BindHandle) GetAllBindRecord ¶
func (h *BindHandle) GetAllBindRecord() (bindRecords []*BindRecord)
GetAllBindRecord returns all bind records in cache.
func (*BindHandle) GetBindRecord ¶
func (h *BindHandle) GetBindRecord(hash, normdOrigSQL, db string) *BindRecord
GetBindRecord returns the BindRecord of the (normdOrigSQL,db) if BindRecord exist.
func (*BindHandle) HandleEvolvePlanTask ¶
func (h *BindHandle) HandleEvolvePlanTask(sctx sessionctx.Context, adminEvolve bool) error
HandleEvolvePlanTask tries to evolve one plan task. It only handle one tasks once because we want each task could use the latest parameters.
func (*BindHandle) ReloadBindings ¶
func (h *BindHandle) ReloadBindings() error
ReloadBindings clears existing binding cache and do a full load from mysql.bind_info. It is used to maintain consistency between cache and mysql.bind_info if the table is deleted or truncated.
func (*BindHandle) SaveEvolveTasksToStore ¶
func (h *BindHandle) SaveEvolveTasksToStore()
SaveEvolveTasksToStore saves the evolve task into store.
func (*BindHandle) Update ¶
func (h *BindHandle) Update(fullLoad bool) (err error)
Update updates the global sql bind cache.
type BindRecord ¶
BindRecord represents a sql bind record retrieved from the storage.
func (*BindRecord) FindBinding ¶
func (br *BindRecord) FindBinding(hint string) *Binding
FindBinding find bindings in BindRecord.
func (*BindRecord) HasUsingBinding ¶
func (br *BindRecord) HasUsingBinding() bool
HasUsingBinding checks if there are any using bindings in bind record.
type Binding ¶
type Binding struct { BindSQL string // Status represents the status of the binding. It can only be one of the following values: // 1. deleted: BindRecord is deleted, can not be used anymore. // 2. using: Binding is in the normal active mode. Status string CreateTime types.Time UpdateTime types.Time Charset string Collation string // Hint is the parsed hints, it is used to bind hints to stmt node. Hint *hint.HintsSet // ID is the string form of Hint. It would be non-empty only when the status is `Using` or `PendingVerify`. ID string }
Binding stores the basic bind hint info.
type SessionHandle ¶
type SessionHandle struct {
// contains filtered or unexported fields
}
SessionHandle is used to handle all session sql bind operations.
func NewSessionBindHandle ¶
func NewSessionBindHandle(parser *parser.Parser) *SessionHandle
NewSessionBindHandle creates a new SessionBindHandle.
func (*SessionHandle) CreateBindRecord ¶
func (h *SessionHandle) CreateBindRecord(sctx sessionctx.Context, record *BindRecord) (err error)
CreateBindRecord creates a BindRecord to the cache. It replaces all the exists bindings for the same normalized SQL.
func (*SessionHandle) DropBindRecord ¶
func (h *SessionHandle) DropBindRecord(originalSQL, db string, binding *Binding) error
DropBindRecord drops a BindRecord in the cache.
func (*SessionHandle) GetAllBindRecord ¶
func (h *SessionHandle) GetAllBindRecord() (bindRecords []*BindRecord)
GetAllBindRecord return all session bind info.
func (*SessionHandle) GetBindRecord ¶
func (h *SessionHandle) GetBindRecord(normdOrigSQL, db string) *BindRecord
GetBindRecord return the BindMeta of the (normdOrigSQL,db) if BindMeta exist.