Documentation ¶
Index ¶
- Constants
- func WithExecutor(e *executor.Executor) contextOption
- type Context
- func (c *Context) AddSystemVariable(name, value string)
- func (c *Context) CurrentSchema() string
- func (c *Context) GetCollationDatabase(stmt *ast.TableName, schemaName string) (string, error)
- func (c *Context) GetColumnCardinality(tn *ast.TableName, columnName string) (int, error)
- func (c *Context) GetCreateTableStmt(stmt *ast.TableName) (*ast.CreateTableStmt, bool, error)
- func (c *Context) GetExecutionPlan(sql string) ([]*executor.ExplainRecord, error)
- func (c *Context) GetHistorySQLInfo() *HistorySQLInfo
- func (c *Context) GetMaxIndexOptionForTable(stmt *ast.TableName, columnNames []string) (float64, error)
- func (c *Context) GetSchemaCharacter(stmt *ast.TableName, schemaName string) (string, error)
- func (c *Context) GetSchemaEngine(stmt *ast.TableName, schemaName string) (string, error)
- func (c *Context) GetSchemaName(stmt *ast.TableName) string
- func (c *Context) GetSystemVariable(name string) (string, error)
- func (c *Context) GetTableInfo(stmt *ast.TableName) (*TableInfo, bool)
- func (c *Context) GetTableRowCount(tn *ast.TableName) (int, error)
- func (c *Context) GetTableSize(stmt *ast.TableName) (float64, error)
- func (c *Context) IsSchemaExist(schemaName string) (bool, error)
- func (c *Context) IsTableExist(stmt *ast.TableName) (bool, error)
- func (c *Context) IsTableExistInDatabase(tn *ast.TableName) (bool, error)
- func (c *Context) Schemas() map[string]*SchemaInfo
- func (c *Context) SetCurrentSchema(schema string)
- func (c *Context) UpdateContext(node ast.Node)
- type HistorySQLInfo
- type SchemaInfo
- type TableInfo
Constants ¶
const (
SysVarLowerCaseTableNames = "lower_case_table_names"
)
Variables ¶
This section is empty.
Functions ¶
func WithExecutor ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is a database information cache.
Is provides many methods to get database information.
It do lazy load and cache the information if executor provided. Otherwise, it only return from cache.
func NewContext ¶
NewContext creates a new context.
func NewMockContext ¶
NewMockContext creates a new mock context for unit test.
func NewMockContextForTestLowerCaseTableNameClose ¶ added in v1.2202.0
func NewMockContextForTestLowerCaseTableNameOpen ¶ added in v1.2202.0
func (*Context) AddSystemVariable ¶ added in v1.2202.0
func (*Context) CurrentSchema ¶
CurrentSchema return current schema.
func (*Context) GetCollationDatabase ¶
GetCollationDatabase get collation database.
func (*Context) GetColumnCardinality ¶
func (*Context) GetCreateTableStmt ¶
GetCreateTableStmt get create table stmtNode for db by query; if table not exist, return null.
func (*Context) GetExecutionPlan ¶
func (c *Context) GetExecutionPlan(sql string) ([]*executor.ExplainRecord, error)
GetExecutionPlan get execution plan of SQL.
func (*Context) GetHistorySQLInfo ¶ added in v1.2201.0
func (c *Context) GetHistorySQLInfo() *HistorySQLInfo
func (*Context) GetMaxIndexOptionForTable ¶
func (c *Context) GetMaxIndexOptionForTable(stmt *ast.TableName, columnNames []string) (float64, error)
GetMaxIndexOptionForTable get max index option column of table.
func (*Context) GetSchemaCharacter ¶
GetSchemaCharacter get schema default character.
func (*Context) GetSchemaEngine ¶
GetSchemaEngine get schema default engine.
func (*Context) GetSchemaName ¶
GetSchemaName get schema name from AST or current schema.
func (*Context) GetSystemVariable ¶
GetSystemVariable get system variable.
func (*Context) GetTableInfo ¶
GetTableInfo get table info from context.
func (*Context) GetTableRowCount ¶
GetTableRowCount get table row count by show table status.
func (*Context) GetTableSize ¶
GetTableSize get table size.
func (*Context) IsSchemaExist ¶
IsSchemaExist check schema is exist or not.
func (*Context) IsTableExist ¶
IsTableExist check table is exist or not.
func (*Context) IsTableExistInDatabase ¶
IsTableExistInDatabase check table exist in database. Sometimes, we need explain on SQL, if table not exist, we will get error.
func (*Context) Schemas ¶
func (c *Context) Schemas() map[string]*SchemaInfo
Schemas return all schemas info in current context.
func (*Context) SetCurrentSchema ¶
func (*Context) UpdateContext ¶
type HistorySQLInfo ¶ added in v1.2201.0
type SchemaInfo ¶
type TableInfo ¶
type TableInfo struct { Size float64 // OriginalTable save parser object from db by query "show create table ..."; // using in inspect and generate rollback sql OriginalTable *ast.CreateTableStmt // MergedTable *ast.CreateTableStmt // save alter table parse object from input sql; AlterTables []*ast.AlterTableStmt // contains filtered or unexported fields }