tidb: github.com/pingcap/tidb/bindinfo Index | Files

package bindinfo

import "github.com/pingcap/tidb/bindinfo"

Index

Package Files

bind.go cache.go handle.go session_handle.go

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"
)
const SessionBindInfoKeyType sessionBindInfoKeyType = 0

SessionBindInfoKeyType is a variable key for store session bind info.

Variables

var GenHintsFromSQL func(ctx context.Context, sctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (string, error)

GenHintsFromSQL is used to generate hints from SQL. It is used to avoid the circle dependence with planner package.

var Lease = 3 * time.Second

Lease influences the duration of loading bind info and handling invalid bind.

func BindHint Uses

func BindHint(stmt ast.StmtNode, hintsSet *HintsSet) ast.StmtNode

BindHint will add hints for stmt according to the hints in `hintsSet`.

type BindHandle Uses

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

BindHandle is used to handle all global sql bind operations.

func NewBindHandle Uses

func NewBindHandle(ctx sessionctx.Context) *BindHandle

NewBindHandle creates a new BindHandle.

func (*BindHandle) AddBindRecord Uses

func (h *BindHandle) AddBindRecord(sctx sessionctx.Context, is infoschema.InfoSchema, record *BindRecord) (err error)

AddBindRecord adds a BindRecord to the storage and BindRecord to the cache.

func (*BindHandle) AddDropInvalidBindTask Uses

func (h *BindHandle) AddDropInvalidBindTask(invalidBindRecord *BindRecord)

AddDropInvalidBindTask add bindRecord to invalidBindRecordMap when the bindRecord need to be deleted.

func (*BindHandle) AddEvolvePlanTask Uses

func (h *BindHandle) AddEvolvePlanTask(originalSQL, DB string, binding Binding, planHint string)

AddEvolvePlanTask adds the evolve plan task into memory cache. It would be flushed to store periodically.

func (*BindHandle) CaptureBaselines Uses

func (h *BindHandle) CaptureBaselines()

CaptureBaselines is used to automatically capture plan baselines.

func (*BindHandle) Clear Uses

func (h *BindHandle) Clear()

Clear resets the bind handle. It is used for test.

func (*BindHandle) DropBindRecord Uses

func (h *BindHandle) DropBindRecord(sctx sessionctx.Context, is infoschema.InfoSchema, record *BindRecord) (err error)

DropBindRecord drops a BindRecord to the storage and BindRecord int the cache.

func (*BindHandle) DropInvalidBindRecord Uses

func (h *BindHandle) DropInvalidBindRecord()

DropInvalidBindRecord execute the drop bindRecord task.

func (*BindHandle) GetAllBindRecord Uses

func (h *BindHandle) GetAllBindRecord() (bindRecords []*BindRecord)

GetAllBindRecord return all bind record in cache.

func (*BindHandle) GetBindRecord Uses

func (h *BindHandle) GetBindRecord(hash, normdOrigSQL, db string) *BindRecord

GetBindRecord return the BindRecord of the (normdOrigSQL,db) if BindRecord exist.

func (*BindHandle) SaveEvolveTasksToStore Uses

func (h *BindHandle) SaveEvolveTasksToStore()

SaveEvolveTasksToStore saves the evolve task into store.

func (*BindHandle) Size Uses

func (h *BindHandle) Size() int

Size return the size of bind info cache.

func (*BindHandle) Update Uses

func (h *BindHandle) Update(fullLoad bool) (err error)

Update updates the global sql bind cache.

type BindRecord Uses

type BindRecord struct {
    OriginalSQL string
    Db          string

    Bindings []Binding
}

BindRecord represents a sql bind record retrieved from the storage.

func (*BindRecord) FindBinding Uses

func (br *BindRecord) FindBinding(hint string) *Binding

FindBinding find bindings in BindRecord.

func (*BindRecord) HasUsingBinding Uses

func (br *BindRecord) HasUsingBinding() bool

HasUsingBinding checks if there are any using bindings in bind record.

type Binding Uses

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 *HintsSet
    // contains filtered or unexported fields
}

Binding stores the basic bind hint info.

type HintsSet Uses

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

HintsSet contains all hints of a query.

func CollectHint Uses

func CollectHint(in ast.StmtNode) *HintsSet

CollectHint collects hints for a statement.

type SessionHandle Uses

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

SessionHandle is used to handle all session sql bind operations.

func NewSessionBindHandle Uses

func NewSessionBindHandle(parser *parser.Parser) *SessionHandle

NewSessionBindHandle creates a new SessionBindHandle.

func (*SessionHandle) AddBindRecord Uses

func (h *SessionHandle) AddBindRecord(sctx sessionctx.Context, is infoschema.InfoSchema, record *BindRecord) error

AddBindRecord new a BindRecord with BindMeta, add it to the cache.

func (*SessionHandle) Close Uses

func (h *SessionHandle) Close()

Close closes the session handle.

func (*SessionHandle) DropBindRecord Uses

func (h *SessionHandle) DropBindRecord(sctx sessionctx.Context, is infoschema.InfoSchema, record *BindRecord) error

DropBindRecord drops a BindRecord in the cache.

func (*SessionHandle) GetAllBindRecord Uses

func (h *SessionHandle) GetAllBindRecord() (bindRecords []*BindRecord)

GetAllBindRecord return all session bind info.

func (*SessionHandle) GetBindRecord Uses

func (h *SessionHandle) GetBindRecord(normdOrigSQL, db string) *BindRecord

GetBindRecord return the BindMeta of the (normdOrigSQL,db) if BindMeta exist.

Package bindinfo imports 22 packages (graph) and is imported by 11 packages. Updated 2019-11-18. Refresh now. Tools for package owners.