sql

package
v0.0.0-...-fb8553b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2017 License: MIT Imports: 8 Imported by: 2 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TypeDDL     = "DDL"
	TypeDML     = "DML"
	TypeDCL     = "DCL"
	TypeTCL     = "TCL"
	TypeUnknown = "Unknown"
)

Query

View Source
const (
	StmtSelect         = "SELECT"
	StmtInsert         = "INSERT"
	StmtReplace        = "REPLACE"
	StmtMerge          = "MERE"
	StmtCall           = "CALL"
	StmtUpdate         = "UPDATE"
	StmtDelete         = "DELETE"
	StmtBegin          = "BEGIN"
	StmtCommit         = "COMMIT"
	StmtRollback       = "ROLLBACK"
	StmtSavePoint      = "SAVEPOINT"
	StmtSet            = "SET"
	StmtShow           = "SHOW"
	StmtUse            = "USE"
	StmtCreate         = "CREATE"
	StmtAlert          = "ALERT"
	StmtDrop           = "DROP"
	StmtTruncate       = "TRUNCATE"
	StmtComment        = "COMMENT"
	StmtRename         = "RENAME"
	StmtGrant          = "GRANT"
	StmtRevoke         = "REVOKE"
	StmtExplainPlan    = "EXPLAINPLAN"
	StmtLockTable      = "LOCKTABLE"
	StmtSetTransaction = "SETTRANSATION"
	StmtOther          = "OTHER"
	StmtUnknown        = "UNKNOWN"
)

Statement

Variables

This section is empty.

Functions

func Classify

func Classify(sql string) string

Classify 分类sql语句

func ExtractTableNames

func ExtractTableNames(fromSQL string) (rets []string, err error)

ExtractTableNames from sql statement

func GetStmtType

func GetStmtType(sql string) string

GetStmtType 获取sql语句类型

func GetTableName

func GetTableName(query string) (string, error)

GetTableName from sql select statement

func Pattern

func Pattern(query []byte) []byte

Pattern returns pattern of given query

Types

type QueryAction

type QueryAction struct {
	QueryContext
	Action    string
	Duration  time.Duration
	Tables    []string
	QueryType string
}

QueryAction action and duration

type QueryContext

type QueryContext struct {
	Query      []byte
	User       []byte
	Client     []byte
	Database   []byte
	Time       time.Time
	SessionID  string
	ServerIP   string
	ServerPort uint
}

QueryContext holds information around query

func (*QueryContext) Marshal

func (c *QueryContext) Marshal() []byte

Marshal load []byte into QueryContext

func (*QueryContext) Unmarshal

func (c *QueryContext) Unmarshal(b []byte) (size uint32)

Unmarshal []byte into QueryContext

Jump to

Keyboard shortcuts

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