inspector

package
v0.2.1-0...-d023f04 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColumnOptionMap = map[ast.ColumnOptionType]string{
	ast.ColumnOptionNotNull:       "NOT NULL",
	ast.ColumnOptionNull:          "NULL",
	ast.ColumnOptionAutoIncrement: "AUTO_INCREMENT",
	ast.ColumnOptionPrimaryKey:    "PRIMARY KEY",
	ast.ColumnOptionUniqKey:       "UNIQUE KEY",
}

Functions

func GetPrimaryKey

func GetPrimaryKey(stmt *ast.CreateTableStmt) (map[string]struct{}, bool)

func HasOneInOptions

func HasOneInOptions(Options []*ast.ColumnOption, opTp ...ast.ColumnOptionType) bool

func IsAllInOptions

func IsAllInOptions(Options []*ast.ColumnOption, opTp ...ast.ColumnOptionType) bool

func MysqlDataTypeIsBlob

func MysqlDataTypeIsBlob(tp byte) bool

func ParseCreateTableStmt

func ParseCreateTableStmt(dbtype string, sql string) (*ast.CreateTableStmt, error)

func RemoveArrayRepeat

func RemoveArrayRepeat(input []string) (output []string)

Types

type Context

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

func NewContext

func NewContext(parent *Context) *Context

func (*Context) AddSchema

func (c *Context) AddSchema(name string)

func (*Context) AddTable

func (c *Context) AddTable(schemaName, tableName string, table *TableInfo)

func (*Context) DelSchema

func (c *Context) DelSchema(name string)

func (*Context) DelTable

func (c *Context) DelTable(schemaName, tableName string)

func (*Context) GetSchema

func (c *Context) GetSchema(schemaName string) (*SchemaInfo, bool)

func (*Context) GetTable

func (c *Context) GetTable(schemaName, tableName string) (*TableInfo, bool)

func (*Context) HasLoadSchemas

func (c *Context) HasLoadSchemas() bool

func (*Context) HasLoadTables

func (c *Context) HasLoadTables(schemaName string) (hasLoad bool)

func (*Context) HasSchema

func (c *Context) HasSchema(schemaName string) (has bool)

func (*Context) HasTable

func (c *Context) HasTable(schemaName, tableName string) (has bool)

func (*Context) LoadSchemas

func (c *Context) LoadSchemas(schemas []string)

func (*Context) LoadTables

func (c *Context) LoadTables(schemaName string, tablesName []string)

func (*Context) SetSchemasLoad

func (c *Context) SetSchemasLoad()

func (*Context) UpdateContext

func (ctx *Context) UpdateContext(node ast.Node, dbtype string)

func (*Context) UseSchema

func (c *Context) UseSchema(schema string)

type SchemaInfo

type SchemaInfo struct {
	DefaultEngine string

	DefaultCharacter string

	Tables map[string]*TableInfo
	// contains filtered or unexported fields
}

type TableChecker

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

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
}

Jump to

Keyboard shortcuts

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