stmtctx

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
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"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLWarn

type SQLWarn struct {
	Level string
	Err   error
}

SQLWarn relates a sql warning and it's level.

type StatementContext

type StatementContext struct {

	// 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
	IgnoreTruncate         bool
	IgnoreZeroInDate       bool
	DupKeyAsWarning        bool
	BadNullAsWarning       bool
	DividedByZeroAsWarning bool
	TruncateAsWarning      bool
	OverflowAsWarning      bool
	InShowWarning          bool
	UseCache               bool
	PadCharToFullLength    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

	// Copied from SessionVars.TimeZone.
	TimeZone     *time.Location
	Priority     mysql.PriorityEnum
	NotFillCache bool
	TableIDs     []int64
	IndexIDs     []int64
	NowTs        time.Time
	SysTs        time.Time
	StmtType     string
	// contains filtered or unexported fields
}

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

func (*StatementContext) AddAffectedRows

func (sc *StatementContext) AddAffectedRows(rows uint64)

AddAffectedRows adds affected rows.

func (*StatementContext) AddCopiedRows

func (sc *StatementContext) AddCopiedRows(rows uint64)

AddCopiedRows adds copied rows.

func (*StatementContext) AddFoundRows

func (sc *StatementContext) AddFoundRows(rows uint64)

AddFoundRows adds found rows.

func (*StatementContext) AddRecordRows

func (sc *StatementContext) AddRecordRows(rows uint64)

AddRecordRows adds record rows.

func (*StatementContext) AddTouchedRows

func (sc *StatementContext) AddTouchedRows(rows uint64)

AddTouchedRows adds touched rows.

func (*StatementContext) AddUpdatedRows

func (sc *StatementContext) AddUpdatedRows(rows uint64)

AddUpdatedRows adds updated rows.

func (*StatementContext) AffectedRows

func (sc *StatementContext) AffectedRows() uint64

AffectedRows gets affected rows.

func (*StatementContext) AppendError

func (sc *StatementContext) AppendError(warn error)

AppendError appends a warning with level 'Error'.

func (*StatementContext) AppendNote

func (sc *StatementContext) AppendNote(warn error)

AppendNote appends a warning with level 'Note'.

func (*StatementContext) AppendWarning

func (sc *StatementContext) AppendWarning(warn error)

AppendWarning appends a warning with level 'Warning'.

func (*StatementContext) CopiedRows

func (sc *StatementContext) CopiedRows() uint64

CopiedRows is used to generate info message

func (*StatementContext) FoundRows

func (sc *StatementContext) FoundRows() uint64

FoundRows gets found rows.

func (*StatementContext) GetMessage

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) GetWarnings

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

GetWarnings gets warnings.

func (*StatementContext) HandleOverflow

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

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

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

func (*StatementContext) HistogramsNotLoad

func (sc *StatementContext) HistogramsNotLoad() bool

HistogramsNotLoad gets histogramsNotLoad.

func (*StatementContext) NumWarnings

func (sc *StatementContext) NumWarnings(errOnly bool) uint16

NumWarnings gets warning count. It's different from `WarningCount` in that `WarningCount` return the warning count of the last executed command, so if the last command is a SHOW statement, `WarningCount` return 0. On the other hand, `NumWarnings` always return number of warnings(or errors if `errOnly` is set).

func (*StatementContext) RecordRows

func (sc *StatementContext) RecordRows() uint64

RecordRows is used to generate info message

func (*StatementContext) ResetForRetry

func (sc *StatementContext) ResetForRetry()

ResetForRetry resets the changed states during execution.

func (*StatementContext) SetHistogramsNotLoad

func (sc *StatementContext) SetHistogramsNotLoad()

SetHistogramsNotLoad sets histogramsNotLoad.

func (*StatementContext) SetMessage

func (sc *StatementContext) SetMessage(msg string)

SetMessage sets the info message generated by some commands

func (*StatementContext) SetWarnings

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

SetWarnings sets warnings.

func (*StatementContext) ShouldClipToZero

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

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

func (sc *StatementContext) TouchedRows() uint64

TouchedRows is used to generate info message

func (*StatementContext) UpdatedRows

func (sc *StatementContext) UpdatedRows() uint64

UpdatedRows is used to generate info message

func (*StatementContext) WarningCount

func (sc *StatementContext) WarningCount() uint16

WarningCount gets warning count.

Jump to

Keyboard shortcuts

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