schema

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_NUMBER    = iota + 1 // tinyint, smallint, int, bigint, year
	TYPE_FLOAT                // float, double
	TYPE_ENUM                 // enum
	TYPE_SET                  // set
	TYPE_STRING               // char, varchar, etc.
	TYPE_DATETIME             // datetime
	TYPE_TIMESTAMP            // timestamp
	TYPE_DATE                 // date
	TYPE_TIME                 // time
	TYPE_BIT                  // bit
	TYPE_JSON                 // json
	TYPE_DECIMAL              // decimal
	TYPE_MEDIUM_INT
	TYPE_BINARY // binary, varbinary
	TYPE_POINT  // coordinates
)

Different column type

Variables

View Source
var ErrMissingTableMeta = errors.New("missing table meta")
View Source
var ErrTableNotExist = errors.New("table is not exist")
View Source
var HAHealthCheckSchema = "mysql.ha_health_check"

Functions

func IsTableExist

func IsTableExist(conn mysql.Executer, schema string, name string) (bool, error)

Types

type Index

type Index struct {
	Name        string
	Columns     []string
	Cardinality []uint64
}

func NewIndex

func NewIndex(name string) *Index

func (*Index) AddColumn

func (idx *Index) AddColumn(name string, cardinality uint64)

func (*Index) FindColumn

func (idx *Index) FindColumn(name string) int

type Table

type Table struct {
	Schema string
	Name   string

	Columns   []TableColumn
	Indexes   []*Index
	PKColumns []int

	UnsignedColumns []int
}

func NewTable

func NewTable(conn mysql.Executer, schema string, name string) (*Table, error)

func NewTableFromSqlDB

func NewTableFromSqlDB(conn *sql.DB, schema string, name string) (*Table, error)

func (*Table) AddColumn

func (ta *Table) AddColumn(name string, columnType string, collation string, extra string)

func (*Table) AddIndex

func (ta *Table) AddIndex(name string) (index *Index)

func (*Table) FindColumn

func (ta *Table) FindColumn(name string) int

func (*Table) GetColumnValue

func (ta *Table) GetColumnValue(column string, row []interface{}) (interface{}, error)

GetColumnValue gets term column's value

func (*Table) GetPKColumn

func (ta *Table) GetPKColumn(index int) *TableColumn

func (*Table) GetPKValues

func (ta *Table) GetPKValues(row []interface{}) ([]interface{}, error)

GetPKValues gets primary keys in one row for a table, a table may use multi fields as the PK

func (*Table) String

func (ta *Table) String() string

type TableColumn

type TableColumn struct {
	Name       string
	Type       int
	Collation  string
	RawType    string
	IsAuto     bool
	IsUnsigned bool
	IsVirtual  bool
	EnumValues []string
	SetValues  []string
	FixedSize  uint
	MaxSize    uint
}

Jump to

Keyboard shortcuts

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