mysql

package
v3.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <swh@admpub.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (

	//Charsets MySQL 支持的字符集
	Charsets = utils.Charsets
	// UnsignedTags 无符号标签
	UnsignedTags = []string{"unsigned", "zerofill", "unsigned zerofill"}
	// EnumLength 枚举选项
	EnumLength = "'(?:''|[^'\\\\]|\\\\.)*'"

	// OnActions used in foreignKeys()
	OnActions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"
	// PartitionTypes 分区类型
	PartitionTypes = []string{`HASH`, `LINEAR HASH`, `KEY`, `LINEAR KEY`, `RANGE`, `LIST`}
)
View Source
var SQLTempDir = os.TempDir

SQLTempDir sql文件缓存目录获取函数(用于导入导出SQL)

Functions

func TempDir

func TempDir(op string) string

Types

type CharsetData

type CharsetData struct {
	Charset          sql.NullString
	Description      sql.NullString
	DefaultCollation sql.NullString
	Maxlen           sql.NullInt64
}

type Collation

type Collation struct {
	Collation    sql.NullString
	Charset      sql.NullString `json:"-"`
	Id           sql.NullInt64  `json:"-"`
	Default      sql.NullString `json:"-"`
	Compiled     sql.NullString `json:"-"`
	Sortlen      sql.NullInt64  `json:"-"`
	PadAttribute sql.NullString `json:"-"`
}

type Collations

type Collations struct {
	Collations map[string][]Collation
	Defaults   map[string]int
}

func NewCollations

func NewCollations() *Collations

type DataTable

type DataTable struct {
	Columns []string
	Values  []map[string]*sql.NullString
}

func NewDataTable

func NewDataTable() *DataTable

type Enum

type Enum struct {
	Int    int
	String string
}

type Field

type Field struct {
	Field         string
	Full_type     string
	Type          string
	Options       []string
	Length        string
	LengthN       int
	Precision     int
	Unsigned      string
	Default       sql.NullString
	Null          bool
	AutoIncrement sql.NullString
	On_update     string
	On_delete     string
	Collation     string
	Privileges    map[string]int
	Comment       string
	Primary       bool

	Original string
}

func (*Field) Format

func (f *Field) Format(value string) string

func (*Field) InputType

func (f *Field) InputType() string

func (*Field) MaxSize

func (f *Field) MaxSize() int

type FieldInfo

type FieldInfo struct {
	Field      sql.NullString
	Type       sql.NullString
	Collation  sql.NullString
	Null       sql.NullString
	Key        sql.NullString
	Default    sql.NullString
	Extra      sql.NullString
	Privileges sql.NullString
	Comment    sql.NullString
}

type FieldType

type FieldType struct {
	Name              string
	MaxUnsignedLength uint64
}

type FieldTypeGroup

type FieldTypeGroup struct {
	Types []*FieldType
	Label string
	Type  string
}

func (*FieldTypeGroup) IsNumeric

func (f *FieldTypeGroup) IsNumeric(typeName string) bool

func (*FieldTypeGroup) IsString

func (f *FieldTypeGroup) IsString(typeName string) bool

type ForeignKeyParam

type ForeignKeyParam struct {
	Name     string
	Database string
	Table    string
	Source   []string
	Target   []string
	OnDelete string
	OnUpdate string
}

type Grant

type Grant struct {
	Scope    string //all|database|table|column|proxy
	Value    string //*.*|db.*|db.table|db.table(col1,col2)
	Database string
	Table    string
	Columns  string            //col1,col2
	Settings map[string]string //["CREATE"]="1|0"
	*Operation
}

func (*Grant) IsValid

func (g *Grant) IsValid(group string, values map[string]*echo.Mapx) bool

func (*Grant) String

func (g *Grant) String() string

type IndexInfo

type IndexInfo struct {
	Table         sql.NullString
	Non_unique    sql.NullString
	Key_name      sql.NullString
	Seq_in_index  sql.NullString
	Column_name   sql.NullString
	Collation     sql.NullString // A 表示升序 / D 表示降序(MySQL8+) / null 表示无分类
	Cardinality   sql.NullString
	Sub_part      sql.NullString
	Packed        sql.NullString
	Null          sql.NullString
	Index_type    sql.NullString
	Comment       sql.NullString
	Index_comment sql.NullString
	Visible       sql.NullString
	Expression    sql.NullString
}

type Indexes

type Indexes struct {
	Name    string
	Type    string
	Columns []string
	Lengths []string
	Descs   []string
}

type KV

type KV struct {
	Value string
	Text  string
}

type Operation

type Operation struct {
	Revoke  []string
	Grant   []string
	Columns string
	On      string
	User    string
	Scope   string //all|database|table|column|proxy
}

func (*Operation) Apply

func (op *Operation) Apply(m *mySQL) error

func (*Operation) HasAllPrivileges

func (op *Operation) HasAllPrivileges(values *[]string, deleteIt bool) bool

func (*Operation) HasGrantOption

func (op *Operation) HasGrantOption(values *[]string, deleteIt bool) bool

type Partition

type Partition struct {
	Method     sql.NullString
	Position   sql.NullString
	Expression sql.NullString
	Names      []string
	Values     []string
}

type Privilege

type Privilege struct {
	Privilege sql.NullString
	Context   sql.NullString
	Comment   sql.NullString
}

type Privileges

type Privileges struct {
	Privileges []*Privilege
	// contains filtered or unexported fields
}

func NewPrivileges

func NewPrivileges() *Privileges

func (*Privileges) Parse

func (p *Privileges) Parse()

type ProcessList

type ProcessList struct {
	Id       sql.NullInt64
	User     sql.NullString
	Host     sql.NullString
	Db       sql.NullString
	Command  sql.NullString
	Time     sql.NullInt64
	State    sql.NullString
	Info     sql.NullString
	Progress sql.NullFloat64
}

type Result

type Result struct {
	SQL          string
	SQLs         []string
	RowsAffected int64
	TimeStart    time.Time
	TimeEnd      time.Time
	Started      string
	Elapsed      string

	ErrorString string
	// contains filtered or unexported fields
}

func (*Result) Error

func (r *Result) Error() error

func (*Result) Exec

func (r *Result) Exec(p *factory.Param) *Result

func (*Result) Execs

func (r *Result) Execs(p *factory.Param) *Result

func (*Result) GetAffected

func (r *Result) GetAffected() int64

func (*Result) GetBeginTime

func (r *Result) GetBeginTime() string

func (*Result) GetElapsedTime

func (r *Result) GetElapsedTime() string

func (*Result) GetError

func (r *Result) GetError() string

func (*Result) GetSQL

func (r *Result) GetSQL() string

func (*Result) GetSQLs

func (r *Result) GetSQLs() []string

func (*Result) Queries

func (r *Result) Queries(p *factory.Param, readRows func(*sql.Rows) error) *Result

func (*Result) Query

func (r *Result) Query(p *factory.Param, readRows func(*sql.Rows) error) *Result

func (*Result) QueryRow

func (r *Result) QueryRow(p *factory.Param, recvs ...interface{}) *Result

func (*Result) SetError

func (r *Result) SetError(err error)

type SelectData

type SelectData struct {
	Result  *Result
	Data    *DataTable
	Explain *DataTable
}

type SupportedEngine

type SupportedEngine struct {
	Engine       sql.NullString //CSV|InnoDB|MyISAM|MEMORY...
	Support      sql.NullString //YES|DEFAULT
	Comment      sql.NullString
	Transactions sql.NullString //NO|YES
	XA           sql.NullString //NO|YES
	Savepoints   sql.NullString //NO|YES
}

type TableStatus

type TableStatus struct {
	Name             sql.NullString
	Engine           sql.NullString
	Version          sql.NullString
	Row_format       sql.NullString
	Rows             sql.NullInt64
	Avg_row_length   sql.NullInt64
	Data_length      sql.NullInt64
	Max_data_length  sql.NullInt64
	Index_length     sql.NullInt64
	Data_free        sql.NullInt64
	Auto_increment   sql.NullInt64
	Create_time      sql.NullString
	Update_time      sql.NullString
	Check_time       sql.NullString
	Collation        sql.NullString
	Checksum         sql.NullString
	Create_options   sql.NullString
	Comment          sql.NullString
	Max_index_length sql.NullInt64
	Temporary        sql.NullString // Y
}

func (*TableStatus) FKSupport

func (t *TableStatus) FKSupport(currentVersion string) bool

func (*TableStatus) IsView

func (t *TableStatus) IsView() bool

func (*TableStatus) Size

func (t *TableStatus) Size() int64

type Trigger

type Trigger struct {
	Trigger              sql.NullString
	Event                sql.NullString
	Table                sql.NullString
	Statement            sql.NullString
	Timing               sql.NullString
	Created              sql.NullString
	Sql_mode             sql.NullString
	Definer              sql.NullString
	Character_set_client sql.NullString
	Collation_connection sql.NullString
	Database_collation   sql.NullString
	Of                   string
	Type                 string
}

type TriggerOption

type TriggerOption struct {
	Type    string
	Options []string
}

type TriggerOptions

type TriggerOptions []*TriggerOption

func (TriggerOptions) Get

func (t TriggerOptions) Get(typeName string) []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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