Documentation
¶
Overview ¶
Package xxsql provides a Go SQL driver for XxSql database.
Index ¶
Constants ¶
View Source
const ( IsolationLevelDefault driver.IsolationLevel = iota // Default IsolationLevelReadUncommitted // ReadUncommitted IsolationLevelReadCommitted // ReadCommitted IsolationLevelRepeatableRead // RepeatableRead IsolationLevelSerializable // Serializable )
Isolation levels matching sql.IsolationLevel
View Source
const ( DefaultAddr = "127.0.0.1:3306" DefaultNet = "tcp" DefaultTimeout = 10 * time.Second DefaultReadTimeout = 30 * time.Second DefaultWriteTimeout = 30 * time.Second DefaultCharset = "utf8mb4" DefaultCollation = "utf8mb4_general_ci" MaxAllowedPacket = 4 * 1024 * 1024 // 4MB )
Default values for connection configuration.
View Source
const ( ErrCodeAccessDenied = 1045 ErrCodeDuplicateEntry = 1062 ErrCodeSyntax = 1064 ErrCodeTableNotExist = 1146 ErrCodeDeadlock = 1213 ErrCodeServerGone = 2006 ErrCodeConnectionLost = 2013 )
MySQL error codes
View Source
const ( ProtocolVersion = 10 MaxPacketSize = 1<<24 - 1 // 16MB // Client capabilities ClientLongPassword = 0x00000001 ClientFoundRows = 0x00000002 ClientLongFlag = 0x00000004 ClientConnectWithDB = 0x00000008 ClientNoSchema = 0x00000010 ClientCompress = 0x00000020 ClientODBC = 0x00000040 ClientLocalFiles = 0x00000080 ClientIgnoreSpace = 0x00000100 ClientProtocol41 = 0x00000200 ClientInteractive = 0x00000400 ClientSSL = 0x00000800 ClientIgnoreSigpipe = 0x00001000 ClientTransactions = 0x00002000 ClientSecureConn = 0x00008000 ClientMultiStatements = 0x00010000 ClientMultiResults = 0x00020000 ClientPluginAuth = 0x00080000 ClientDeprecateEOF = 0x01000000 // Default client capabilities DefaultClientCapabilities = ClientLongPassword | ClientFoundRows | ClientLongFlag | ClientConnectWithDB | ClientProtocol41 | ClientTransactions | ClientSecureConn | ClientMultiStatements | ClientMultiResults | ClientPluginAuth | ClientDeprecateEOF // Character sets CharacterSetUTF8MB4 = 45 // Command types ComQuit = 0x01 ComInitDB = 0x02 ComQuery = 0x03 ComPing = 0x0E ComStmtPrepare = 0x16 ComStmtExecute = 0x17 ComStmtClose = 0x19 // Response types OKPacket = 0x00 ERRPacket = 0xFF EOFPacket = 0xFE )
MySQL protocol constants
View Source
const ( TypeDecimal = 0x00 TypeTiny = 0x01 TypeShort = 0x02 TypeLong = 0x03 TypeFloat = 0x04 TypeDouble = 0x05 TypeNull = 0x06 TypeTimestamp = 0x07 TypeLongLong = 0x08 TypeInt24 = 0x09 TypeDate = 0x0A TypeTime = 0x0B TypeDateTime = 0x0C TypeYear = 0x0D TypeNewDate = 0x0E TypeVarChar = 0x0F TypeBit = 0x10 TypeNewDecimal = 0xE6 TypeEnum = 0xF7 TypeSet = 0xF8 TypeTinyBlob = 0xF9 TypeMediumBlob = 0xFA TypeLongBlob = 0xFB TypeBlob = 0xFC TypeVarString = 0xFD TypeString = 0xFE TypeGeometry = 0xFF )
MySQL column type codes
View Source
const DriverName = "xxsql"
Driver name for registration.
Variables ¶
View Source
var ( // ErrBadConn indicates the connection is in a bad state. ErrBadConn = errors.New("bad connection") // ErrTxDone indicates the transaction has already been committed or rolled back. ErrTxDone = errors.New("transaction has already been committed or rolled back") // ErrDuplicateEntry indicates a unique constraint violation. ErrDuplicateEntry = errors.New("duplicate entry") // ErrTableNotExist indicates the table does not exist. ErrTableNotExist = errors.New("table does not exist") // ErrDeadlock indicates a deadlock was detected. ErrDeadlock = errors.New("deadlock detected") // ErrAccessDenied indicates authentication failed. ErrAccessDenied = errors.New("access denied") // ErrSyntax indicates a SQL syntax error. ErrSyntax = errors.New("syntax error") )
Sentinel errors
Functions ¶
func RegisterDriver ¶
func RegisterDriver()
RegisterDriver registers the xxsql driver with database/sql.
Types ¶
type Config ¶
type Config struct {
User string
Passwd string
Net string // Network type: "tcp"
Addr string // Network address: "host:port"
DBName string // Database name
Timeout time.Duration // Connection timeout
ReadTimeout time.Duration // Read timeout
WriteTimeout time.Duration // Write timeout
Charset string // Character set
Collation string // Collation
TLS bool // Enable TLS
AllowOldPassword bool // Allow old password authentication
MaxAllowedPacket int // Maximum packet size allowed
}
Config represents the configuration for an XxSql connection.
Click to show internal directories.
Click to hide internal directories.