1 // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
3 // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 // You can obtain one at http://mozilla.org/MPL/2.0/.
18 // Various errors the driver might return. Can change between driver versions.
20 ErrInvalidConn = errors.New("invalid connection")
21 ErrMalformPkt = errors.New("malformed packet")
22 ErrNoTLS = errors.New("TLS requested but server does not support TLS")
23 ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN")
24 ErrNativePassword = errors.New("this user requires mysql native password authentication.")
25 ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords")
26 ErrUnknownPlugin = errors.New("this authentication plugin is not supported")
27 ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")
28 ErrPktSync = errors.New("commands out of sync. You can't run this command now")
29 ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?")
30 ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server")
31 ErrBusyBuffer = errors.New("busy buffer")
33 // errBadConnNoWrite is used for connection errors where nothing was sent to the database yet.
34 // If this happens first in a function starting a database interaction, it should be replaced by driver.ErrBadConn
35 // to trigger a resend.
36 // See https://github.com/go-sql-driver/mysql/pull/302
37 errBadConnNoWrite = errors.New("bad connection")
40 var errLog = Logger(log.New(os.Stderr, "[mysql] ", log.Ldate|log.Ltime|log.Lshortfile))
42 // Logger is used to log critical error messages.
43 type Logger interface {
44 Print(v ...interface{})
47 // SetLogger is used to set the logger for critical errors.
48 // The initial logger is os.Stderr.
49 func SetLogger(logger Logger) error {
51 return errors.New("logger is nil")
57 // MySQLError is an error type which represents a single MySQL error
58 type MySQLError struct {
63 func (me *MySQLError) Error() string {
64 return fmt.Sprintf("Error %d: %s", me.Number, me.Message)