tidb: github.com/pingcap/tidb/sessionctx/stmtctx Index | Files

package stmtctx

import "github.com/pingcap/tidb/sessionctx/stmtctx"


Package Files



const (
    // WarnLevelError represents level "Error" for 'SHOW WARNINGS' syntax.
    WarnLevelError = "Error"
    // WarnLevelWarning represents level "Warning" for 'SHOW WARNINGS' syntax.
    WarnLevelWarning = "Warning"
    // WarnLevelNote represents level "Note" for 'SHOW WARNINGS' syntax.
    WarnLevelNote = "Note"

func AllocateTaskID Uses

func AllocateTaskID() uint64

AllocateTaskID allocates a new unique ID for a statement execution

type CopTasksDetails Uses

type CopTasksDetails struct {
    NumCopTasks int

    AvgProcessTime    time.Duration
    P90ProcessTime    time.Duration
    MaxProcessAddress string
    MaxProcessTime    time.Duration

    AvgWaitTime    time.Duration
    P90WaitTime    time.Duration
    MaxWaitAddress string
    MaxWaitTime    time.Duration

    MaxBackoffTime    map[string]time.Duration
    MaxBackoffAddress map[string]string
    AvgBackoffTime    map[string]time.Duration
    P90BackoffTime    map[string]time.Duration
    TotBackoffTime    map[string]time.Duration
    TotBackoffTimes   map[string]int

CopTasksDetails collects some useful information of cop-tasks during execution.

func (*CopTasksDetails) ToZapFields Uses

func (d *CopTasksDetails) ToZapFields() (fields []zap.Field)

ToZapFields wraps the CopTasksDetails as zap.Fileds.

type SQLWarn Uses

type SQLWarn struct {
    Level string
    Err   error

SQLWarn relates a sql warning and it's level.

type StatementContext Uses

type StatementContext struct {
    // Set the following variables before execution

    // IsDDLJobInQueue is used to mark whether the DDL job is put into the queue.
    // If IsDDLJobInQueue is true, it means the DDL job is in the queue of storage, and it can be handled by the DDL worker.
    IsDDLJobInQueue        bool
    InInsertStmt           bool
    InUpdateStmt           bool
    InDeleteStmt           bool
    InSelectStmt           bool
    InLoadDataStmt         bool
    InExplainStmt          bool
    IgnoreTruncate         bool
    IgnoreZeroInDate       bool
    DupKeyAsWarning        bool
    BadNullAsWarning       bool
    DividedByZeroAsWarning bool
    TruncateAsWarning      bool
    OverflowAsWarning      bool
    InShowWarning          bool
    UseCache               bool
    BatchCheck             bool
    InNullRejectCheck      bool
    AllowInvalidDate       bool

    // PrevAffectedRows is the affected-rows value(DDL is 0, DML is the number of affected rows).
    PrevAffectedRows int64
    // PrevLastInsertID is the last insert ID of previous statement.
    PrevLastInsertID uint64
    // LastInsertID is the auto-generated ID in the current statement.
    LastInsertID uint64
    // InsertID is the given insert ID of an auto_increment column.
    InsertID uint64

    BaseRowID int64
    MaxRowID  int64

    // Copied from SessionVars.TimeZone.
    TimeZone         *time.Location
    Priority         mysql.PriorityEnum
    NotFillCache     bool
    MemTracker       *memory.Tracker
    DiskTracker      *disk.Tracker
    RuntimeStatsColl *execdetails.RuntimeStatsColl
    TableIDs         []int64
    IndexNames       []string

    StmtType    string
    OriginalSQL string

    Tables    []TableEntry
    PointExec bool // for point update cached execution, Constant expression need to set "paramMarker"

    PessimisticLockWaited int32
    LockKeysDuration      time.Duration
    LockKeysCount         int32
    TblInfo2UnionScan     map[*model.TableInfo]bool
    TaskID                uint64 // unique ID for an execution of a statement
    // contains filtered or unexported fields

StatementContext contains variables for a statement. It should be reset before executing a statement.

func (*StatementContext) AddAffectedRows Uses

func (sc *StatementContext) AddAffectedRows(rows uint64)

AddAffectedRows adds affected rows.

func (*StatementContext) AddCopiedRows Uses

func (sc *StatementContext) AddCopiedRows(rows uint64)

AddCopiedRows adds copied rows.

func (*StatementContext) AddFoundRows Uses

func (sc *StatementContext) AddFoundRows(rows uint64)

AddFoundRows adds found rows.

func (*StatementContext) AddRecordRows Uses

func (sc *StatementContext) AddRecordRows(rows uint64)

AddRecordRows adds record rows.

func (*StatementContext) AddTouchedRows Uses

func (sc *StatementContext) AddTouchedRows(rows uint64)

AddTouchedRows adds touched rows.

func (*StatementContext) AddUpdatedRows Uses

func (sc *StatementContext) AddUpdatedRows(rows uint64)

AddUpdatedRows adds updated rows.

func (*StatementContext) AffectedRows Uses

func (sc *StatementContext) AffectedRows() uint64

AffectedRows gets affected rows.

func (*StatementContext) AppendError Uses

func (sc *StatementContext) AppendError(warn error)

AppendError appends a warning with level 'Error'.

func (*StatementContext) AppendNote Uses

func (sc *StatementContext) AppendNote(warn error)

AppendNote appends a warning with level 'Note'.

func (*StatementContext) AppendWarning Uses

func (sc *StatementContext) AppendWarning(warn error)

AppendWarning appends a warning with level 'Warning'.

func (*StatementContext) AppendWarnings Uses

func (sc *StatementContext) AppendWarnings(warns []SQLWarn)

AppendWarnings appends some warnings.

func (*StatementContext) CopTasksDetails Uses

func (sc *StatementContext) CopTasksDetails() *CopTasksDetails

CopTasksDetails returns some useful information of cop-tasks during execution.

func (*StatementContext) CopiedRows Uses

func (sc *StatementContext) CopiedRows() uint64

CopiedRows is used to generate info message

func (*StatementContext) FoundRows Uses

func (sc *StatementContext) FoundRows() uint64

FoundRows gets found rows.

func (*StatementContext) GetExecDetails Uses

func (sc *StatementContext) GetExecDetails() execdetails.ExecDetails

GetExecDetails gets the execution details for the statement.

func (*StatementContext) GetLockWaitStartTime Uses

func (sc *StatementContext) GetLockWaitStartTime() time.Time

GetLockWaitStartTime returns the statement pessimistic lock wait start time

func (*StatementContext) GetMessage Uses

func (sc *StatementContext) GetMessage() string

GetMessage returns the extra message of the last executed command, if there is no message, it returns empty string

func (*StatementContext) GetNowTsCached Uses

func (sc *StatementContext) GetNowTsCached() time.Time

GetNowTsCached getter for nowTs, if not set get now time and cache it

func (*StatementContext) GetPlanDigest Uses

func (sc *StatementContext) GetPlanDigest() (normalized, planDigest string)

GetPlanDigest gets the normalized plan and plan digest.

func (*StatementContext) GetWarnings Uses

func (sc *StatementContext) GetWarnings() []SQLWarn

GetWarnings gets warnings.

func (*StatementContext) HandleOverflow Uses

func (sc *StatementContext) HandleOverflow(err error, warnErr error) error

HandleOverflow treats ErrOverflow as warnings or returns the error based on the StmtCtx.OverflowAsWarning state.

func (*StatementContext) HandleTruncate Uses

func (sc *StatementContext) HandleTruncate(err error) error

HandleTruncate ignores or returns the error based on the StatementContext state.

func (*StatementContext) InitSQLDigest Uses

func (sc *StatementContext) InitSQLDigest(normalized, digest string)

InitSQLDigest sets the normalized and digest for sql.

func (*StatementContext) MergeExecDetails Uses

func (sc *StatementContext) MergeExecDetails(details *execdetails.ExecDetails, commitDetails *execdetails.CommitDetails)

MergeExecDetails merges a single region execution details into self, used to print the information in slow query log.

func (*StatementContext) NumErrorWarnings Uses

func (sc *StatementContext) NumErrorWarnings() (ec uint16, wc int)

NumErrorWarnings gets warning and error count.

func (*StatementContext) PushDownFlags Uses

func (sc *StatementContext) PushDownFlags() uint64

PushDownFlags converts StatementContext to tipb.SelectRequest.Flags.

func (*StatementContext) RecordRows Uses

func (sc *StatementContext) RecordRows() uint64

RecordRows is used to generate info message

func (*StatementContext) ResetForRetry Uses

func (sc *StatementContext) ResetForRetry()

ResetForRetry resets the changed states during execution.

func (*StatementContext) ResetNowTs Uses

func (sc *StatementContext) ResetNowTs()

ResetNowTs resetter for nowTs, clear cached time flag

func (*StatementContext) SQLDigest Uses

func (sc *StatementContext) SQLDigest() (normalized, sqlDigest string)

SQLDigest gets normalized and digest for provided sql. it will cache result after first calling.

func (*StatementContext) SetFlagsFromPBFlag Uses

func (sc *StatementContext) SetFlagsFromPBFlag(flags uint64)

SetFlagsFromPBFlag set the flag of StatementContext from a `tipb.SelectRequest.Flags`.

func (*StatementContext) SetHistogramsNotLoad Uses

func (sc *StatementContext) SetHistogramsNotLoad()

SetHistogramsNotLoad sets histogramsNotLoad.

func (*StatementContext) SetMessage Uses

func (sc *StatementContext) SetMessage(msg string)

SetMessage sets the info message generated by some commands

func (*StatementContext) SetPlanDigest Uses

func (sc *StatementContext) SetPlanDigest(normalized, planDigest string)

SetPlanDigest sets the normalized plan and plan digest.

func (*StatementContext) SetWarnings Uses

func (sc *StatementContext) SetWarnings(warns []SQLWarn)

SetWarnings sets warnings.

func (*StatementContext) ShouldClipToZero Uses

func (sc *StatementContext) ShouldClipToZero() bool

ShouldClipToZero indicates whether values less than 0 should be clipped to 0 for unsigned integer types. This is the case for `insert`, `update`, `alter table` and `load data infile` statements, when not in strict SQL mode. see https://dev.mysql.com/doc/refman/5.7/en/out-of-range-and-overflow.html

func (*StatementContext) ShouldIgnoreOverflowError Uses

func (sc *StatementContext) ShouldIgnoreOverflowError() bool

ShouldIgnoreOverflowError indicates whether we should ignore the error when type conversion overflows, so we can leave it for further processing like clipping values less than 0 to 0 for unsigned integer types.

func (*StatementContext) TouchedRows Uses

func (sc *StatementContext) TouchedRows() uint64

TouchedRows is used to generate info message

func (*StatementContext) TruncateWarnings Uses

func (sc *StatementContext) TruncateWarnings(start int) []SQLWarn

TruncateWarnings truncates wanrings begin from start and returns the truncated warnings.

func (*StatementContext) UpdatedRows Uses

func (sc *StatementContext) UpdatedRows() uint64

UpdatedRows is used to generate info message

func (*StatementContext) WarningCount Uses

func (sc *StatementContext) WarningCount() uint16

WarningCount gets warning count.

type StmtHints Uses

type StmtHints struct {
    // Hint Information
    MemQuotaQuery           int64
    MaxExecutionTime        uint64
    ReplicaRead             byte
    AllowInSubqToJoinAndAgg bool
    NoIndexMergeHint        bool
    // EnableCascadesPlanner is use cascades planner for a single query only.
    EnableCascadesPlanner bool

    // Hint flags
    HasAllowInSubqToJoinAndAggHint bool
    HasMemQuotaHint                bool
    HasReplicaReadHint             bool
    HasMaxExecutionTime            bool
    HasEnableCascadesPlannerHint   bool

StmtHints are SessionVars related sql hints.

type TableEntry Uses

type TableEntry struct {
    DB    string
    Table string

TableEntry presents table in db.

Package stmtctx imports 13 packages (graph) and is imported by 320 packages. Updated 2020-05-30. Refresh now. Tools for package owners.