constant

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigPathKey      = "config"
	TransactionTimeout = "transaction-timeout"

	DBPackRestoreFormat = format.DefaultRestoreFlags | format.RestoreStringWithoutDefaultCharset
)
View Source
const (
	DefaultMaxAllowedPacket = 4 << 20 // 4 MiB

	// MaxPacketSize is the maximum payload length of a packet
	// the server supports.
	MaxPacketSize = (1 << 24) - 1

	// ProtocolVersion is the current version of the protocol.
	// Always 10.
	ProtocolVersion = 10

	TimeFormat = "2006-01-02 15:04:05.999999"
)
View Source
const (
	// MysqlNativePassword uses a salt and transmits a hash on the wire.
	MysqlNativePassword = "mysql_native_password"

	// MysqlClearPassword transmits the password in the clear.
	MysqlClearPassword = "mysql_clear_password"

	// MysqlDialog uses the dialog plugin on the client side.
	// It transmits data in the clear.
	MysqlDialog = "dialog"
)

Supported auth forms.

View Source
const (
	// CapabilityClientLongPassword is CLIENT_LONG_PASSWORD.
	// New more secure passwords. Assumed to be set since 4.1.1.
	// We do not check this anywhere.
	CapabilityClientLongPassword = 1

	// CapabilityClientFoundRows is CLIENT_FOUND_ROWS.
	CapabilityClientFoundRows = 1 << 1

	// CapabilityClientLongFlag is CLIENT_LONG_FLAG.
	// Longer flags in Protocol::ColumnDefinition320.
	// Set it everywhere, not used, as we use Protocol::ColumnDefinition41.
	CapabilityClientLongFlag = 1 << 2

	// CapabilityClientConnectWithDB is CLIENT_CONNECT_WITH_DB.
	// One can specify db on connect.
	CapabilityClientConnectWithDB = 1 << 3

	// CapabilityClientProtocol41 is CLIENT_PROTOCOL_41.
	// New 4.1 protocol. Enforced everywhere.
	CapabilityClientProtocol41 = 1 << 9

	// CapabilityClientSSL is CLIENT_SSL.
	// Switch to SSL after handshake.
	CapabilityClientSSL = 1 << 11

	// CapabilityClientTransactions is CLIENT_TRANSACTIONS.
	// Can send status flags in EOF_Packet.
	// This flag is optional in 3.23, but always set by the server since 4.0.
	// We just do it all the time.
	CapabilityClientTransactions = 1 << 13

	// CapabilityClientSecureConnection is CLIENT_SECURE_CONNECTION.
	// New 4.1 authentication. Always set, expected, never checked.
	CapabilityClientSecureConnection = 1 << 15

	// CapabilityClientMultiStatements is CLIENT_MULTI_STATEMENTS
	// Can handle multiple statements per COM_QUERY and COM_STMT_PREPARE.
	CapabilityClientMultiStatements = 1 << 16

	// CapabilityClientMultiResults is CLIENT_MULTI_RESULTS
	// Can send multiple resultsets for COM_QUERY.
	CapabilityClientMultiResults = 1 << 17

	// CapabilityClientPluginAuth is CLIENT_PLUGIN_AUTH.
	// Client supports plugin authentication.
	CapabilityClientPluginAuth = 1 << 19

	// CapabilityClientConnAttr is CLIENT_CONNECT_ATTRS
	// Permits connection attributes in Protocol::HandshakeResponse41.
	CapabilityClientConnAttr = 1 << 20

	// CapabilityClientPluginAuthLenencClientData is CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA
	CapabilityClientPluginAuthLenencClientData = 1 << 21

	// CapabilityClientDeprecateEOF is CLIENT_DEPRECATE_EOF
	// Expects an OK (instead of EOF) after the resultset rows of a Text Resultset.
	CapabilityClientDeprecateEOF = 1 << 24
)

Capability flags. Originally found in include/mysql/mysql_com.h

View Source
const (
	// ComQuit is COM_QUIT.
	ComQuit = 0x01

	// ComInitDB is COM_INIT_DB.
	ComInitDB = 0x02

	// ComQuery is COM_QUERY.
	ComQuery = 0x03

	ComFieldList = 0x04

	ComCreateDB = 0x05

	ComDropDB = 0x06

	ComRefresh = 0x07

	ComShutdown = 0x08

	ComStatistics = 0x09

	ComProcessInfo = 0x0a

	ComConnect = 0x0b

	ComProcessKill = 0x0c

	ComDebug = 0x0d

	// ComPing is COM_PING.
	ComPing = 0x0e

	ComTime = 0x0f

	ComDelayedInsert = 0x10

	ComChangeUser = 0x11

	// ComBinlogDump is COM_BINLOG_DUMP.
	ComBinlogDump = 0x12

	ComTableDump = 0x13

	ComConnectOut = 0x14

	ComRegisterSlave = 0x15

	// ComPrepare is COM_PREPARE.
	ComPrepare = 0x16

	// ComStmtExecute is COM_STMT_EXECUTE.
	ComStmtExecute = 0x17

	// ComStmtSendLongData is COM_STMT_SEND_LONG_DATA
	ComStmtSendLongData = 0x18

	// ComStmtClose is COM_STMT_CLOSE.
	ComStmtClose = 0x19

	// ComStmtReset is COM_STMT_RESET
	ComStmtReset = 0x1a

	// ComSetOption is COM_SET_OPTION
	ComSetOption = 0x1b

	//ComStmtFetch is COM_STMT_FETCH
	ComStmtFetch = 0x1c

	ComDaemon = 0x1d

	// ComBinlogDumpGTID is COM_BINLOG_DUMP_GTID.
	ComBinlogDumpGTID = 0x1e

	// ComResetConnection is COM_RESET_CONNECTION
	ComResetConnection = 0x1f

	ComEnd = 0x20

	// OKPacket is the header of the OK packet.
	OKPacket = 0x00

	// EOFPacket is the header of the EOF packet.
	EOFPacket = 0xfe

	// AuthSwitchRequestPacket is used to switch auth method.
	AuthSwitchRequestPacket = 0xfe

	// ErrPacket is the header of the error packet.
	ErrPacket = 0xff

	// NullValue is the encoded value of NULL.
	NullValue = 0xfb
)

Packet types. Originally found in include/mysql/mysql_com.h

View Source
const (
	// CRUnknownError is CR_UNKNOWN_ERROR
	CRUnknownError = 2000

	// CRConnectionError is CR_CONNECTION_ERROR
	// This is returned if a connection via a Unix socket fails.
	CRConnectionError = 2002

	// CRConnHostError is CR_CONN_HOST_ERROR
	// This is returned if a connection via a TCP socket fails.
	CRConnHostError = 2003

	// CRServerGone is CR_SERVER_GONE_ERROR.
	// This is returned if the client tries to send a command but it fails.
	CRServerGone = 2006

	// CRVersionError is CR_VERSION_ERROR
	// This is returned if the server versions don't match what we support.
	CRVersionError = 2007

	// CRServerHandshakeErr is CR_SERVER_HANDSHAKE_ERR
	CRServerHandshakeErr = 2012

	// CRServerLost is CR_SERVER_LOST.
	// Used when:
	// - the client cannot write an initial auth packet.
	// - the client cannot read an initial auth packet.
	// - the client cannot read a response from the server.
	CRServerLost = 2013

	// CRCommandsOutOfSync is CR_COMMANDS_OUT_OF_SYNC
	// Sent when the streaming calls are not done in the right order.
	CRCommandsOutOfSync = 2014

	// CRNamedPipeStateError is CR_NAMEDPIPESETSTATE_ERROR.
	// This is the highest possible number for a connection error.
	CRNamedPipeStateError = 2018

	// CRCantReadCharset is CR_CANT_READ_CHARSET
	CRCantReadCharset = 2019

	// CRSSLConnectionError is CR_SSL_CONNECTION_ERROR
	CRSSLConnectionError = 2026

	// CRMalformedPacket is CR_MALFORMED_PACKET
	CRMalformedPacket = 2027
)

Error codes for client-side errors. Originally found in include/mysql/errmsg.h and https://dev.mysql.com/doc/refman/5.7/en/error-messages-client.html

View Source
const (
	// unknown
	ERUnknownError = 1105

	// unimplemented
	ERNotSupportedYet = 1235

	// resource exhausted
	ERDiskFull               = 1021
	EROutOfMemory            = 1037
	EROutOfSortMemory        = 1038
	ERConCount               = 1040
	EROutOfResources         = 1041
	ERRecordFileFull         = 1114
	ERHostIsBlocked          = 1129
	ERCantCreateThread       = 1135
	ERTooManyDelayedThreads  = 1151
	ERNetPacketTooLarge      = 1153
	ERTooManyUserConnections = 1203
	ERLockTableFull          = 1206
	ERUserLimitReached       = 1226

	// deadline exceeded
	ERLockWaitTimeout = 1205

	// unavailable
	ERServerShutdown = 1053

	// not found
	ERFormNotFound          = 1029
	ERKeyNotFound           = 1032
	ERBadFieldError         = 1054
	ERNoSuchThread          = 1094
	ERUnknownTable          = 1109
	ERCantFindUDF           = 1122
	ERNonExistingGrant      = 1141
	ERNoSuchTable           = 1146
	ERNonExistingTableGrant = 1147
	ERKeyDoesNotExist       = 1176

	// permissions
	ERDBAccessDenied            = 1044
	ERAccessDeniedError         = 1045
	ERKillDenied                = 1095
	ERNoPermissionToCreateUsers = 1211
	ERSpecifiedAccessDenied     = 1227

	// failed precondition
	ERNoDb                          = 1046
	ERNoSuchIndex                   = 1082
	ERCantDropFieldOrKey            = 1091
	ERTableNotLockedForWrite        = 1099
	ERTableNotLocked                = 1100
	ERTooBigSelect                  = 1104
	ERNotAllowedCommand             = 1148
	ERTooLongString                 = 1162
	ERDelayedInsertTableLocked      = 1165
	ERDupUnique                     = 1169
	ERRequiresPrimaryKey            = 1173
	ERCantDoThisDuringAnTransaction = 1179
	ERReadOnlyTransaction           = 1207
	ERCannotAddForeign              = 1215
	ERNoReferencedRow               = 1216
	ERRowIsReferenced               = 1217
	ERCantUpdateWithReadLock        = 1223
	ERNoDefault                     = 1230
	EROperandColumns                = 1241
	ERSubqueryNo1Row                = 1242
	ERWarnDataOutOfRange            = 1264
	ERNonUpdateableTable            = 1288
	ERFeatureDisabled               = 1289
	EROptionPreventsStatement       = 1290
	ERDuplicatedValueInType         = 1291
	ERRowIsReferenced2              = 1451
	ErNoReferencedRow2              = 1452

	// already exists
	ERTableExists = 1050
	ERDupEntry    = 1062
	ERFileExists  = 1086
	ERUDFExists   = 1125

	// aborted
	ERGotSignal          = 1078
	ERForcingClose       = 1080
	ERAbortingConnection = 1152
	ERLockDeadlock       = 1213

	// invalid arg
	ERUnknownComError              = 1047
	ERBadNullError                 = 1048
	ERBadDb                        = 1049
	ERBadTable                     = 1051
	ERNonUniq                      = 1052
	ERWrongFieldWithGroup          = 1055
	ERWrongGroupField              = 1056
	ERWrongSumSelect               = 1057
	ERWrongValueCount              = 1058
	ERTooLongIdent                 = 1059
	ERDupFieldName                 = 1060
	ERDupKeyName                   = 1061
	ERWrongFieldSpec               = 1063
	ERParseError                   = 1064
	EREmptyQuery                   = 1065
	ERNonUniqTable                 = 1066
	ERInvalidDefault               = 1067
	ERMultiplePriKey               = 1068
	ERTooManyKeys                  = 1069
	ERTooManyKeyParts              = 1070
	ERTooLongKey                   = 1071
	ERKeyColumnDoesNotExist        = 1072
	ERBlobUsedAsKey                = 1073
	ERTooBigFieldLength            = 1074
	ERWrongAutoKey                 = 1075
	ERWrongFieldTerminators        = 1083
	ERBlobsAndNoTerminated         = 1084
	ERTextFileNotReadable          = 1085
	ERWrongSubKey                  = 1089
	ERCantRemoveAllFields          = 1090
	ERUpdateTableUsed              = 1093
	ERNoTablesUsed                 = 1096
	ERTooBigSet                    = 1097
	ERBlobCantHaveDefault          = 1101
	ERWrongDbName                  = 1102
	ERWrongTableName               = 1103
	ERUnknownProcedure             = 1106
	ERWrongParamCountToProcedure   = 1107
	ERWrongParametersToProcedure   = 1108
	ERFieldSpecifiedTwice          = 1110
	ERInvalidGroupFuncUse          = 1111
	ERTableMustHaveColumns         = 1113
	ERUnknownCharacterSet          = 1115
	ERTooManyTables                = 1116
	ERTooManyFields                = 1117
	ERTooBigRowSize                = 1118
	ERWrongOuterJoin               = 1120
	ERNullColumnInIndex            = 1121
	ERFunctionNotDefined           = 1128
	ERWrongValueCountOnRow         = 1136
	ERInvalidUseOfNull             = 1138
	ERRegexpError                  = 1139
	ERMixOfGroupFuncAndFields      = 1140
	ERIllegalGrantForTable         = 1144
	ERSyntaxError                  = 1149
	ERWrongColumnName              = 1166
	ERWrongKeyColumn               = 1167
	ERBlobKeyWithoutLength         = 1170
	ERPrimaryCantHaveNull          = 1171
	ERTooManyRows                  = 1172
	ERUnknownSystemVariable        = 1193
	ERSetConstantsOnly             = 1204
	ERWrongArguments               = 1210
	ERWrongUsage                   = 1221
	ERWrongNumberOfColumnsInSelect = 1222
	ERDupArgument                  = 1225
	ERLocalVariable                = 1228
	ERGlobalVariable               = 1229
	ERWrongValueForVar             = 1231
	ERWrongTypeForVar              = 1232
	ERVarCantBeRead                = 1233
	ERCantUseOptionHere            = 1234
	ERIncorrectGlobalLocalVar      = 1238
	ERWrongFKDef                   = 1239
	ERKeyRefDoNotMatchTableRef     = 1240
	ERCyclicReference              = 1245
	ERCollationCharsetMismatch     = 1253
	ERCantAggregate2Collations     = 1267
	ERCantAggregate3Collations     = 1270
	ERCantAggregateNCollations     = 1271
	ERVariableIsNotStruct          = 1272
	ERUnknownCollation             = 1273
	ERWrongNameForIndex            = 1280
	ERWrongNameForCatalog          = 1281
	ERBadFTColumn                  = 1283
	ERTruncatedWrongValue          = 1292
	ERTooMuchAutoTimestampCols     = 1293
	ERInvalidOnUpdate              = 1294
	ERUnknownTimeZone              = 1298
	ERInvalidCharacterString       = 1300
	ERIllegalReference             = 1247
	ERDerivedMustHaveAlias         = 1248
	ERTableNameNotAllowedHere      = 1250
	ERQueryInterrupted             = 1317
	ERTruncatedWrongValueForField  = 1366
	ERDataTooLong                  = 1406
	ERDataOutOfRange               = 1690
)

Error codes for server-side errors. Originally found in include/mysql/mysqld_error.h and https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html The below are in sorted order by value, grouped by vterror code they should be bucketed into. See above reference for more information on each code.

View Source
const (
	// SSUnknownSQLState is ER_SIGNAL_EXCEPTION in
	// include/mysql/sql_state.h, but:
	// const char *unknown_sqlstate= "HY000"
	// in client.c. So using that one.
	SSUnknownSQLState = "HY000"

	// SSUnknownComError is ER_UNKNOWN_COM_ERROR
	SSUnknownComError = "08S01"

	// SSHandshakeError is ER_HANDSHAKE_ERROR
	SSHandshakeError = "08S01"

	// SSServerShutdown is ER_SERVER_SHUTDOWN
	SSServerShutdown = "08S01"

	// SSDataTooLong is ER_DATA_TOO_LONG
	SSDataTooLong = "22001"

	// SSDataOutOfRange is ER_DATA_OUT_OF_RANGE
	SSDataOutOfRange = "22003"

	// SSBadNullError is ER_BAD_NULL_ERROR
	SSBadNullError = "23000"

	// SSBadFieldError is ER_BAD_FIELD_ERROR
	SSBadFieldError = "42S22"

	// SSDupKey is ER_DUP_KEY
	SSDupKey = "23000"

	// SSCantDoThisDuringAnTransaction is
	// ER_CANT_DO_THIS_DURING_AN_TRANSACTION
	SSCantDoThisDuringAnTransaction = "25000"

	// SSAccessDeniedError is ER_ACCESS_DENIED_ERROR
	SSAccessDeniedError = "28000"

	// SSLockDeadlock is ER_LOCK_DEADLOCK
	SSLockDeadlock = "40001"
)

Sql states for errors. Originally found in include/mysql/sql_state.h

View Source
const (
	ServerStatusInTrans = 0x0001

	// ServerStatusAutocommit is SERVER_STATUS_AUTOCOMMIT.
	ServerStatusAutocommit = 0x0002

	// ServerMoreResultsExists is SERVER_MORE_RESULTS_EXISTS
	ServerMoreResultsExists = 0x0008
)

Status flags. They are returned by the server in a few cases. Originally found in include/mysql/mysql_com.h See http://dev.mysql.com/doc/internals/en/status-flags.html

View Source
const (
	// CharacterSetUtf8 is for UTF8. We use this by default.
	CharacterSetUtf8 = 33

	// CharacterSetBinary is for binary. Use by integer fields for instance.
	CharacterSetBinary = 63
)

A few interesting character set values. See http://dev.mysql.com/doc/internals/en/character-set.html#packet-Protocol::CharacterSet

View Source
const (
	BIT SqlDataType = -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
)
View Source
const (
	NotNullFlag        uint = 1 << 0  /* Field can't be NULL */
	PriKeyFlag         uint = 1 << 1  /* Field is part of a primary key */
	UniqueKeyFlag      uint = 1 << 2  /* Field is part of a unique key */
	MultipleKeyFlag    uint = 1 << 3  /* Field is part of a key */
	BlobFlag           uint = 1 << 4  /* Field is a blob */
	UnsignedFlag       uint = 1 << 5  /* Field is unsigned */
	ZerofillFlag       uint = 1 << 6  /* Field is zerofill */
	BinaryFlag         uint = 1 << 7  /* Field is binary   */
	EnumFlag           uint = 1 << 8  /* Field is an enum */
	AutoIncrementFlag  uint = 1 << 9  /* Field is an auto increment field */
	TimestampFlag      uint = 1 << 10 /* Field is a timestamp */
	SetFlag            uint = 1 << 11 /* Field is a set */
	NoDefaultValueFlag uint = 1 << 12 /* Field doesn't have a default value */
	OnUpdateNowFlag    uint = 1 << 13 /* Field is set to NOW on UPDATE */
	PartKeyFlag        uint = 1 << 14 /* Intern: Part of some keys */
	NumFlag            uint = 1 << 15 /* Field is a num (for clients) */

	GroupFlag             uint = 1 << 15 /* Internal: Group field */
	UniqueFlag            uint = 1 << 16 /* Internal: Used by sql_yacc */
	BinCmpFlag            uint = 1 << 17 /* Internal: Used by sql_yacc */
	ParseToJSONFlag       uint = 1 << 18 /* Internal: Used when we want to parse string to JSON in CAST */
	IsBooleanFlag         uint = 1 << 19 /* Internal: Used for telling boolean literal from integer */
	PreventNullInsertFlag uint = 1 << 20 /* Prevent this Field from inserting NULL values */
)

Flag information.

View Source
const (
	MaxUint24 = 1<<24 - 1
	MaxInt24  = 1<<23 - 1
	MinInt24  = -1 << 23
)

TypeInt24 bounds.

View Source
const BinaryCollation = "binary"
View Source
const DefaultCollation = "utf8mb4_general_ci"
View Source
const (
	// ERMaxRowsExceeded is when a user tries to select more rows than the max rows as enforced by vitess.
	ERMaxRowsExceeded = 10001
)

Error codes return in SQLErrors generated by vitess. These error codes are in a high range to avoid conflicting with mysql error codes below.

View Source
const (
	EnvDBPackConfig = "DBPack_Config"
)
View Source
const TypeUnspecified = FieldTypeDecimal

TypeUnspecified is an uninitialized type. TypeDecimal is not used in MySQL.

Variables

View Source
var CharacterSetMap = map[string]uint8{
	"big5":     1,
	"dec8":     3,
	"cp850":    4,
	"hp8":      6,
	"koi8r":    7,
	"latin1":   8,
	"latin2":   9,
	"swe7":     10,
	"ascii":    11,
	"ujis":     12,
	"sjis":     13,
	"hebrew":   16,
	"tis620":   18,
	"euckr":    19,
	"koi8u":    22,
	"gb2312":   24,
	"greek":    25,
	"cp1250":   26,
	"gbk":      28,
	"latin5":   30,
	"armscii8": 32,
	"utf8":     CharacterSetUtf8,
	"ucs2":     35,
	"cp866":    36,
	"keybcs2":  37,
	"macce":    38,
	"macroman": 39,
	"cp852":    40,
	"latin7":   41,
	"utf8mb4":  45,
	"cp1251":   51,
	"utf16":    54,
	"utf16le":  56,
	"cp1256":   57,
	"cp1257":   59,
	"utf32":    60,
	"binary":   CharacterSetBinary,
	"geostd8":  92,
	"cp932":    95,
	"eucjpms":  97,
}

CharacterSetMap maps the charset name (used in ConnParams) to the integer value. Interesting ones have their own constant above.

View Source
var Collations = map[string]uint16{}/* 143 elements not displayed */

Collations A list of available Collations mapped to the internal ID. To update this map use the following MySQL query:

SELECT COLLATION_NAME, ID FROM information_schema.COLLATIONS WHERE ID<256 ORDER BY ID

Handshake packet have only 1 byte for collation_id. So we can't use Collations with ID > 255.

ucs2, utf16, and utf32 can't be used for connection charset. https://dev.mysql.com/doc/refman/5.7/en/charset-connection.html#charset-connection-impermissible-client-charset They are commented out to reduce this map.

View Source
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,
}
View Source
var UnsafeCollations = map[string]bool{
	"big5_chinese_ci":        true,
	"sjis_japanese_ci":       true,
	"gbk_chinese_ci":         true,
	"big5_bin":               true,
	"gb2312_bin":             true,
	"gbk_bin":                true,
	"sjis_bin":               true,
	"cp932_japanese_ci":      true,
	"cp932_bin":              true,
	"gb18030_chinese_ci":     true,
	"gb18030_bin":            true,
	"gb18030_unicode_520_ci": true,
}

UnsafeCollations A denylist of Collations which is unsafe to interpolate parameters. These multibyte encodings may contains 0x5c (`\`) in their trailing bytes.

Functions

func GetSqlDataType

func GetSqlDataType(dataType string) int32

func HasAutoIncrementFlag

func HasAutoIncrementFlag(flag uint) bool

HasAutoIncrementFlag checks if AutoIncrementFlag is set.

func HasBinaryFlag

func HasBinaryFlag(flag uint) bool

HasBinaryFlag checks if BinaryFlag is set.

func HasIsBooleanFlag

func HasIsBooleanFlag(flag uint) bool

HasIsBooleanFlag checks if IsBooleanFlag is set.

func HasMultipleKeyFlag

func HasMultipleKeyFlag(flag uint) bool

HasMultipleKeyFlag checks if MultipleKeyFlag is set.

func HasNoDefaultValueFlag

func HasNoDefaultValueFlag(flag uint) bool

HasNoDefaultValueFlag checks if NoDefaultValueFlag is set.

func HasNotNullFlag

func HasNotNullFlag(flag uint) bool

HasNotNullFlag checks if NotNullFlag is set.

func HasOnUpdateNowFlag

func HasOnUpdateNowFlag(flag uint) bool

HasOnUpdateNowFlag checks if OnUpdateNowFlag is set.

func HasParseToJSONFlag

func HasParseToJSONFlag(flag uint) bool

HasParseToJSONFlag checks if ParseToJSONFlag is set.

func HasPreventNullInsertFlag

func HasPreventNullInsertFlag(flag uint) bool

HasPreventNullInsertFlag checks if PreventNullInsertFlag is set.

func HasPriKeyFlag

func HasPriKeyFlag(flag uint) bool

HasPriKeyFlag checks if PriKeyFlag is set.

func HasTimestampFlag

func HasTimestampFlag(flag uint) bool

HasTimestampFlag checks if HasTimestampFlag is set.

func HasUniKeyFlag

func HasUniKeyFlag(flag uint) bool

HasUniKeyFlag checks if UniqueKeyFlag is set.

func HasUnsignedFlag

func HasUnsignedFlag(flag uint) bool

HasUnsignedFlag checks if UnsignedFlag is set.

func HasZerofillFlag

func HasZerofillFlag(flag uint) bool

HasZerofillFlag checks if ZerofillFlag is set.

func IsNum

func IsNum(typ uint8) bool

IsNum returns true if a MySQL type is a numeric value. It is the same as IS_NUM defined in mysql.h.

FIXME(alainjobart) This needs to use the constants in replication/constants.go, so we are using numerical values here.

func TypeToMySQL

func TypeToMySQL(typ FieldType) (mysqlType, flags int64)

TypeToMySQL returns the equivalent mysql type and flag for a vitess type.

Types

type FieldType

type FieldType byte

https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnType

const (
	FieldTypeDecimal FieldType = iota
	FieldTypeTiny
	FieldTypeShort
	FieldTypeLong
	FieldTypeFloat
	FieldTypeDouble
	FieldTypeNULL
	FieldTypeTimestamp
	FieldTypeLongLong
	FieldTypeInt24
	FieldTypeDate
	FieldTypeTime
	FieldTypeDateTime
	FieldTypeYear
	FieldTypeNewDate
	FieldTypeVarChar
	FieldTypeBit
)
const (
	FieldTypeUint8 FieldType = iota + 0x85
	FieldTypeUint16
	FieldTypeUint24
	FieldTypeUint32
	FieldTypeUint64
)
const (
	FieldTypeJSON FieldType = iota + 0xf5
	FieldTypeNewDecimal
	FieldTypeEnum
	FieldTypeSet
	FieldTypeTinyBLOB
	FieldTypeMediumBLOB
	FieldTypeLongBLOB
	FieldTypeBLOB
	FieldTypeVarString
	FieldTypeString
	FieldTypeGeometry
)

func MySQLToType

func MySQLToType(mysqlType, flags int64) (typ FieldType, err error)

MySQLToType computes the vitess type from mysql type and flags.

type SQLType

type SQLType byte
const (
	SQLType_SELECT SQLType = iota

	SQLType_INSERT

	SQLType_UPDATE

	SQLType_DELETE

	SQLType_SELECT_FOR_UPDATE

	SQLType_REPLACE

	SQLType_TRUNCATE

	SQLType_CREATE

	SQLType_DROP

	SQLType_LOAD

	SQLType_MERGE

	SQLType_SHOW

	SQLType_ALTER

	SQLType_RENAME

	SQLType_DUMP

	SQLType_DEBUG

	SQLType_EXPLAIN

	SQLType_PROCEDURE

	SQLType_DESC

	SQLType_SET SQLType = 27

	SQLType_RELOAD SQLType = 28

	SQLType_SELECT_UNION SQLType = 29

	SQLType_CREATE_TABLE SQLType = 30

	SQLType_DROP_TABLE SQLType = 31

	SQLType_ALTER_TABLE SQLType = 32

	SQLType_SAVE_POINT SQLType = 33

	SQLType_SELECT_FROM_UPDATE SQLType = 34

	SQLType_MULTI_DELETE SQLType = 35

	SQLType_MULTI_UPDATE SQLType = 36

	SQLType_CREATE_INDEX SQLType = 37

	SQLType_DROP_INDEX SQLType = 38
)

func (SQLType) String

func (sqlType SQLType) String() string

type SqlDataType

type SqlDataType int32

Jump to

Keyboard shortcuts

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