Documentation
¶
Index ¶
- Constants
- Variables
- func GetMysqlKeyWord() map[string]string
- func GetSqlDataType(dataType string) int32
- type BranchPhase
- type ColumnImage
- type ColumnMeta
- type ColumnType
- type CommonValue
- type DBType
- type ExecContext
- type ExecResult
- type ExecutorType
- type FieldType
- type IndexMeta
- type IndexType
- type JDBCType
- type KeyType
- type MySQLDefCode
- type Option
- type ParseContext
- type RecordImage
- type RecordImages
- type RoundRecordImage
- func (r *RoundRecordImage) AfterImages() RecordImages
- func (r *RoundRecordImage) AppendAfterImage(image *RecordImage)
- func (r *RoundRecordImage) AppendAfterImages(images []*RecordImage)
- func (r *RoundRecordImage) AppendBeofreImage(image *RecordImage)
- func (r *RoundRecordImage) AppendBeofreImages(images []*RecordImage)
- func (r *RoundRecordImage) BeofreImages() RecordImages
- func (r *RoundRecordImage) IsBeforeAfterSizeEq() bool
- func (r *RoundRecordImage) IsEmpty() bool
- type RowImage
- type SQLType
- type TableMeta
- type TransactionContext
- type TransactionMode
Constants ¶
const ( SQLTypeSelect = iota SQLTypeInsert SQLTypeUpdate SQLTypeDelete SQLTypeSelectForUpdate SQLTypeReplace SQLTypeTruncate SQLTypeCreate SQLTypeDrop SQLTypeLoad SQLTypeMerge SQLTypeShow SQLTypeAlter SQLTypeRename SQLTypeDump SQLTypeDebug SQLTypeExplain SQLTypeProcedure SQLTypeDesc SQLLastInsertID SQLSelectWithoutTable SQLCreateSequence SQLShowSequence SQLGetSequence SQLAlterSequence SQLDropSequence SQLTddlShow SQLTypeSet SQLTypeReload SQLTypeSelectUnion SQLTypeCreateTable SQLTypeDropTable SQLTypeAlterTable SQLTypeSavePoint SQLTypeSelectFromUpdate SQLTypeMultiDelete SQLTypeMultiUpdate SQLTypeCreateIndex SQLTypeDropIndex SQLTypeKill SQLTypeLockTables SQLTypeUnLockTables SQLTypeCheckTable SQLTypeSelectFoundRows SQLTypeInsertIgnore = iota + 57 SQLTypeInsertOnDuplicateUpdate // SQLTypeMulti and SQLTypeUnknown is different from seata-java SQLTypeMulti = iota + 999 SQLTypeUnknown )
const ( DBTypeUnknown DBType DBTypeMySQL DBTypePostgreSQL DBTypeSQLServer DBTypeOracle DBTypeMARIADB BranchPhase_Unknown = 0 BranchPhase_Done = 1 BranchPhase_Failed = 2 // IndexPrimary primary index type. IndexPrimary IndexType = iota // IndexNormal normal index type. IndexNormal // IndexUnique unique index type. IndexUnique // IndexFullText full text index type. IndexFullText )
Variables ¶
var ( ScanTypeFloat32 = reflect.TypeOf(float32(0)) ScanTypeFloat64 = reflect.TypeOf(float64(0)) ScanTypeInt8 = reflect.TypeOf(int8(0)) ScanTypeInt16 = reflect.TypeOf(int16(0)) ScanTypeInt32 = reflect.TypeOf(int32(0)) ScanTypeInt64 = reflect.TypeOf(int64(0)) ScanTypeNullFloat = reflect.TypeOf(sql.NullFloat64{}) ScanTypeNullInt = reflect.TypeOf(sql.NullInt64{}) ScanTypeNullTime = reflect.TypeOf(nullTime{}) ScanTypeUint8 = reflect.TypeOf(uint8(0)) ScanTypeUint16 = reflect.TypeOf(uint16(0)) ScanTypeUint32 = reflect.TypeOf(uint32(0)) ScanTypeUint64 = reflect.TypeOf(uint64(0)) ScanTypeRawBytes = reflect.TypeOf(sql.RawBytes{}) ScanTypeUnknown = reflect.TypeOf(new(interface{})) )
var MysqlKeyWord map[string]string
var SqlDataTypes = map[string]int32{
"BIT": -7,
"TINYINT": -6,
"SMALLINT": 5,
"INTEGER": 4,
"BIGINT": -5,
"FLOAT": 6,
"REAL": 7,
"DOUBLE": 8,
"NUMERIC": 2,
"DECIMAL": 3,
"CHAR": 1,
"VARCHAR": 12,
"LONGVARCHAR": -1,
"DATE": 91,
"TIME": 92,
"TIMESTAMP": 93,
"BINARY": -2,
"VARBINARY": -3,
"LONGVARBINARY": -4,
"NULL": 0,
"OTHER": 1111,
"JAVA_OBJECT": 2000,
"DISTINCT": 2001,
"STRUCT": 2002,
"ARRAY": 2003,
"BLOB": 2004,
"CLOB": 2005,
"REF": 2006,
"DATALINK": 70,
"BOOLEAN": 16,
"ROWID": -8,
"NCHAR": -15,
"NVARCHAR": -9,
"LONGNVARCHAR": -16,
"NCLOB": 2011,
"SQLXML": 2009,
"REF_CURSOR": 2012,
"TIME_WITH_TIMEZONE": 2013,
"TIMESTAMP_WITH_TIMEZONE": 2014,
}
Functions ¶
func GetMysqlKeyWord ¶
func GetSqlDataType ¶
Types ¶
type ColumnImage ¶
type ColumnImage struct {
// KeyType index type
KeyType IndexType `json:"keyType"`
// ColumnName column name
ColumnName string `json:"name"`
// ColumnType column type
ColumnType JDBCType `json:"type"`
// Value column value
Value interface{} `json:"value"`
}
ColumnImage The mirror data information of the column
func (*ColumnImage) GetActualValue ¶
func (c *ColumnImage) GetActualValue() interface{}
func (*ColumnImage) MarshalJSON ¶
func (c *ColumnImage) MarshalJSON() ([]byte, error)
func (*ColumnImage) UnmarshalJSON ¶
func (c *ColumnImage) UnmarshalJSON(data []byte) error
type ColumnMeta ¶
type ColumnMeta struct {
// Schema
Schema string
Table string
// ColumnDef the column default
ColumnDef []byte
// Autoincrement
Autoincrement bool
// todo get columnType
//ColumnTypeInfo *sql.ColumnType
ColumnName string
ColumnType string
DatabaseType int32
DatabaseTypeString string
ColumnKey string
IsNullable int8
Extra string
}
ColumnMeta
type ColumnType ¶
type ColumnType struct {
Name string
HasNullable bool
HasLength bool
HasPrecisionScale bool
Nullable bool
Length int64
DatabaseType string
Precision int64
Scale int64
ScanType reflect.Type
}
func (*ColumnType) DatabaseTypeName ¶
func (ci *ColumnType) DatabaseTypeName() string
DatabaseTypeName returns the database system name of the column type. If an empty string is returned, then the driver type name is not supported. Consult your driver documentation for a list of driver data types. Length specifiers are not included. Common type names include "VARCHAR", "TEXT", "NVARCHAR", "DECIMAL", "BOOL", "INT", and "BIGINT".
type CommonValue ¶
type CommonValue struct {
Value interface{}
}
type ExecContext ¶
type ExecContext struct {
TxCtx *TransactionContext
Query string
// todo delete
ParseContext *ParseContext
NamedValues []driver.NamedValue
// todo delete
Values []driver.Value
// todo delete
MetaDataMap map[string]TableMeta
Conn driver.Conn
DBName string
DBType DBType
// todo set values for these 4 param
IsAutoCommit bool
IsSupportsSavepoints bool
IsRequireGlobalLock bool
}
ExecContext
type ExecResult ¶
func NewResult ¶
func NewResult(opts ...Option) ExecResult
type ExecutorType ¶
type ExecutorType int32
const ( UnSupportExecutor ExecutorType InsertExecutor UpdateExecutor SelectForUpdateExecutor SelectExecutor DeleteExecutor ReplaceIntoExecutor MultiExecutor MultiDeleteExecutor InsertOnDuplicateExecutor )
type FieldType ¶
type FieldType byte
https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnType
type IndexMeta ¶
type IndexMeta struct {
// Schema
Schema string
// Table
Table string
Name string
// todo 待删除
ColumnName string
NonUnique bool
// IType
IType IndexType
// Columns
Columns []ColumnMeta
}
IndexMeta
type IndexType ¶
type IndexType int16
IndexType index type
func ParseIndexType ¶
func (IndexType) MarshalText ¶
func (*IndexType) UnmarshalText ¶
type JDBCType ¶
type JDBCType int16
JDBCType's source is seata java: java.sql.Types.java it used in undo_log.rollback_info.sqlUndoLogs.afterImage.rows.fields.type field
const ( JDBCTypeBit JDBCType = -7 JDBCTypeTinyInt JDBCType = -6 JDBCTypeSmallInt JDBCType = 5 JDBCTypeInteger JDBCType = 4 JDBCTypeBigInt JDBCType = -5 JDBCTypeFloat JDBCType = 6 JDBCTypeReal JDBCType = 7 JDBCTypeDouble JDBCType = 8 JDBCTypeNumberic JDBCType = 2 JDBCTypeDecimal JDBCType = 3 JDBCTypeChar JDBCType = 1 JDBCTypeVarchar JDBCType = 12 JDBCTypeLongVarchar JDBCType = -1 JDBCTypeDate JDBCType = 91 JDBCTypeTime JDBCType = 92 JDBCTypeTimestamp JDBCType = 93 JDBCTypeBinary JDBCType = -2 JDBCTypeVarBinary JDBCType = -3 JDBCTypeLongVarBinary JDBCType = -4 JDBCTypeNull JDBCType = 0 JDBCTypeOther JDBCType = 1111 JDBCTypeJavaObject JDBCType = 2000 JDBCTypeDistinct JDBCType = 2001 JDBCTypeStruct JDBCType = 2002 JDBCTypeArray JDBCType = 2003 JDBCTypeBlob JDBCType = 2004 JDBCTypeClob JDBCType = 2005 JDBCTypeRef JDBCType = 2006 JDBCTypeDateLink JDBCType = 70 JDBCTypeBoolean JDBCType = 16 JDBCTypeRowID JDBCType = -8 JDBCTypeNchar JDBCType = -15 JDBCTypeNvarchar JDBCType = -9 JDBCTypeLongNvVarchar JDBCType = -16 JDBCTypeNclob JDBCType = 2011 JDBCTypeSqlXML JDBCType = 2009 JDBCTypeRefCursor JDBCType = 2012 JDBCTypeTimeWithTimeZone JDBCType = 2013 JDBCTypeTimestampWithTimezone JDBCType = 2014 )
func MySQLCodeToJava ¶
func MySQLCodeToJava(mysqlType MySQLDefCode) JDBCType
func MySQLStrToJavaType ¶
type MySQLDefCode ¶
type MySQLDefCode int64
var ( COM_BINLOG_DUMP MySQLDefCode = 18 COM_CHANGE_USER MySQLDefCode = 17 COM_CLOSE_STATEMENT MySQLDefCode = 25 COM_CONNECT_OUT MySQLDefCode = 20 COM_END MySQLDefCode = 29 COM_EXECUTE MySQLDefCode = 23 COM_FETCH MySQLDefCode = 28 COM_LONG_DATA MySQLDefCode = 24 COM_PREPARE MySQLDefCode = 22 COM_REGISTER_SLAVE MySQLDefCode = 21 COM_RESET_STMT MySQLDefCode = 26 COM_SET_OPTION MySQLDefCode = 27 COM_TABLE_DUMP MySQLDefCode = 19 CONNECT MySQLDefCode = 11 CREATE_DB MySQLDefCode = 5 // Not used; deprecated? DEBUG MySQLDefCode = 13 DELAYED_INSERT MySQLDefCode = 16 DROP_DB MySQLDefCode = 6 // Not used; deprecated? FIELD_LIST MySQLDefCode = 4 // Not used; deprecated in MySQL 5.7.11 and MySQL 8.0.0. FIELD_TYPE_BIT MySQLDefCode = 16 FIELD_TYPE_BLOB MySQLDefCode = 252 FIELD_TYPE_DATE MySQLDefCode = 10 FIELD_TYPE_DATETIME MySQLDefCode = 12 // Data Types FIELD_TYPE_DECIMAL MySQLDefCode = 0 FIELD_TYPE_DOUBLE MySQLDefCode = 5 FIELD_TYPE_ENUM MySQLDefCode = 247 FIELD_TYPE_FLOAT MySQLDefCode = 4 FIELD_TYPE_GEOMETRY MySQLDefCode = 255 FIELD_TYPE_INT24 MySQLDefCode = 9 FIELD_TYPE_LONG MySQLDefCode = 3 FIELD_TYPE_LONG_BLOB MySQLDefCode = 251 FIELD_TYPE_LONGLONG MySQLDefCode = 8 FIELD_TYPE_MEDIUM_BLOB MySQLDefCode = 250 FIELD_TYPE_NEW_DECIMAL MySQLDefCode = 246 FIELD_TYPE_NEWDATE MySQLDefCode = 14 FIELD_TYPE_NULL MySQLDefCode = 6 FIELD_TYPE_SET MySQLDefCode = 248 FIELD_TYPE_SHORT MySQLDefCode = 2 FIELD_TYPE_STRING MySQLDefCode = 254 FIELD_TYPE_TIME MySQLDefCode = 11 FIELD_TYPE_TIMESTAMP MySQLDefCode = 7 FIELD_TYPE_TINY MySQLDefCode = 1 // Older data types FIELD_TYPE_TINY_BLOB MySQLDefCode = 249 FIELD_TYPE_VAR_STRING MySQLDefCode = 253 FIELD_TYPE_VARCHAR MySQLDefCode = 15 // Newer data types FIELD_TYPE_YEAR MySQLDefCode = 13 FIELD_TYPE_JSON MySQLDefCode = 245 INIT_DB MySQLDefCode = 2 LENGTH_BLOB MySQLDefCode = 65535 LENGTH_LONGBLOB MySQLDefCode = 4294967295 LENGTH_MEDIUMBLOB MySQLDefCode = 16777215 LENGTH_TINYBLOB MySQLDefCode = 255 // Limitations MAX_ROWS MySQLDefCode = 50000000 // From the MySQL FAQ /** * Used to indicate that the server sent no field-level character set information, so the driver should use the connection-level character encoding instead. */ NO_CHARSET_INFO MySQLDefCode = -1 OPEN_CURSOR_FLAG MySQLDefCode = 1 PING MySQLDefCode = 14 PROCESS_INFO MySQLDefCode = 10 // Not used; deprecated in MySQL 5.7.11 and MySQL 8.0.0. PROCESS_KILL MySQLDefCode = 12 // Not used; deprecated in MySQL 5.7.11 and MySQL 8.0.0. QUERY MySQLDefCode = 3 QUIT MySQLDefCode = 1 RELOAD MySQLDefCode = 7 // Not used; deprecated in MySQL 5.7.11 and MySQL 8.0.0. SHUTDOWN MySQLDefCode = 8 // Deprecated in MySQL 5.7.9 and MySQL 8.0.0. // // Constants defined from mysql // // DB Operations SLEEP MySQLDefCode = 0 STATISTICS MySQLDefCode = 9 TIME MySQLDefCode = 15 )
type ParseContext ¶
type ParseContext struct {
SQLType SQLType
ExecutorType ExecutorType
InsertStmt *ast.InsertStmt
UpdateStmt *ast.UpdateStmt
SelectStmt *ast.SelectStmt
DeleteStmt *ast.DeleteStmt
MultiStmt []*ParseContext
}
func (*ParseContext) GetTableName ¶
func (p *ParseContext) GetTableName() (string, error)
func (*ParseContext) HasValidStmt ¶
func (p *ParseContext) HasValidStmt() bool
type RecordImage ¶
type RecordImage struct {
// TableName table name
TableName string `json:"tableName"`
// SQLType sql type
SQLType SQLType `json:"sqlType"`
// Rows data row
Rows []RowImage `json:"rows"`
// TableMeta table information schema
TableMeta *TableMeta `json:"-"`
// contains filtered or unexported fields
}
RecordImage
func NewEmptyRecordImage ¶
func NewEmptyRecordImage(tableMeta *TableMeta, sqlType SQLType) *RecordImage
type RecordImages ¶
type RecordImages []*RecordImage
func (RecordImages) IsEmptyImage ¶
func (rs RecordImages) IsEmptyImage() bool
func (RecordImages) Reserve ¶
func (rs RecordImages) Reserve()
Reserve The order of reverse mirrors, when executing undo, needs to be executed in reverse
type RoundRecordImage ¶
type RoundRecordImage struct {
// contains filtered or unexported fields
}
RoundRecordImage Front and rear mirror data
func (*RoundRecordImage) AfterImages ¶
func (r *RoundRecordImage) AfterImages() RecordImages
func (*RoundRecordImage) AppendAfterImage ¶
func (r *RoundRecordImage) AppendAfterImage(image *RecordImage)
AppendAfterImage
func (*RoundRecordImage) AppendAfterImages ¶
func (r *RoundRecordImage) AppendAfterImages(images []*RecordImage)
AppendAfterImages
func (*RoundRecordImage) AppendBeofreImage ¶
func (r *RoundRecordImage) AppendBeofreImage(image *RecordImage)
AppendBeofreImage
func (*RoundRecordImage) AppendBeofreImages ¶
func (r *RoundRecordImage) AppendBeofreImages(images []*RecordImage)
AppendBeofreImages
func (*RoundRecordImage) BeofreImages ¶
func (r *RoundRecordImage) BeofreImages() RecordImages
func (*RoundRecordImage) IsBeforeAfterSizeEq ¶
func (r *RoundRecordImage) IsBeforeAfterSizeEq() bool
func (*RoundRecordImage) IsEmpty ¶
func (r *RoundRecordImage) IsEmpty() bool
type RowImage ¶
type RowImage struct {
// Columns All columns of image data
Columns []ColumnImage `json:"fields"`
}
RowImage Mirror data information information
func (*RowImage) GetColumnMap ¶
func (r *RowImage) GetColumnMap() map[string]*ColumnImage
func (*RowImage) NonPrimaryKeys ¶
func (r *RowImage) NonPrimaryKeys(cols []ColumnImage) []ColumnImage
NonPrimaryKeys get non-primary keys
func (*RowImage) PrimaryKeys ¶
func (r *RowImage) PrimaryKeys(cols []ColumnImage) []ColumnImage
PrimaryKeys Primary keys list.
type TableMeta ¶
type TableMeta struct {
// TableName
TableName string
// Columns
Columns map[string]ColumnMeta
// Indexs
Indexs map[string]IndexMeta
ColumnNames []string
}
TableMeta
func (TableMeta) GetPrimaryKeyMap ¶
func (m TableMeta) GetPrimaryKeyMap() map[string]ColumnMeta
func (TableMeta) GetPrimaryKeyOnlyName ¶
func (TableMeta) GetPrimaryKeyType ¶
GetPrimaryKeyType get PK database type
func (TableMeta) GetPrimaryKeyTypeStrMap ¶
GetPrimaryKeyTypeStrMap get all PK type to map
type TransactionContext ¶
type TransactionContext struct {
// LocalTransID locals transaction id
LocalTransID string
// LockKeys
LockKeys map[string]struct{}
// DBType db type, eg. MySQL/PostgreSQL/SQLServer
DBType DBType
// TxOpt transaction option
TxOpt driver.TxOptions
// TransactionMode transaction mode, eg. XA/AT
TransactionMode TransactionMode
// ResourceID resource id, database-table
ResourceID string
// BranchID transaction branch unique id
BranchID uint64
// XID global transaction id
XID string
// GlobalLockRequire
GlobalLockRequire bool
// RoundImages when run in AT mode, record before and after Row image
RoundImages *RoundRecordImage
}
TransactionContext seata-go‘s context of transaction
func NewTxCtx ¶
func NewTxCtx() *TransactionContext
func (*TransactionContext) IsBranchRegistered ¶
func (t *TransactionContext) IsBranchRegistered() bool
func (*TransactionContext) OpenGlobalTransaction ¶
func (t *TransactionContext) OpenGlobalTransaction() bool
type TransactionMode ¶
type TransactionMode int8
const ( Local TransactionMode XAMode ATMode )
func (TransactionMode) BranchType ¶
func (t TransactionMode) BranchType() branch.BranchType