ruby-mysql 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-mysql might be problematic. Click here for more details.
- data/ChangeLog +3 -0
- data/README.rdoc +68 -0
- data/lib/mysql.rb +1080 -0
- data/lib/mysql/charset.rb +255 -0
- data/lib/mysql/constants.rb +164 -0
- data/lib/mysql/error.rb +518 -0
- data/lib/mysql/protocol.rb +710 -0
- metadata +73 -0
@@ -0,0 +1,255 @@
|
|
1
|
+
# Copyright (C) 2008 TOMITA Masahiro
|
2
|
+
# mailto:tommy@tmtm.org
|
3
|
+
|
4
|
+
require "#{File.dirname __FILE__}/error"
|
5
|
+
|
6
|
+
class Mysql
|
7
|
+
class Charset
|
8
|
+
def initialize(number, name, csname)
|
9
|
+
@number, @name, @csname = number, name, csname
|
10
|
+
end
|
11
|
+
attr_reader :number, :name, :csname
|
12
|
+
|
13
|
+
# [[charset_number, charset_name, collation_name, default], ...]
|
14
|
+
CHARSETS = [
|
15
|
+
[ 1, "big5", "big5_chinese_ci", true ],
|
16
|
+
[ 2, "latin2", "latin2_czech_cs", false],
|
17
|
+
[ 3, "dec8", "dec8_swedish_ci", true ],
|
18
|
+
[ 4, "cp850", "cp850_general_ci", true ],
|
19
|
+
[ 5, "latin1", "latin1_german1_ci", false],
|
20
|
+
[ 6, "hp8", "hp8_english_ci", true ],
|
21
|
+
[ 7, "koi8r", "koi8r_general_ci", true ],
|
22
|
+
[ 8, "latin1", "latin1_swedish_ci", true ],
|
23
|
+
[ 9, "latin2", "latin2_general_ci", true ],
|
24
|
+
[ 10, "swe7", "swe7_swedish_ci", true ],
|
25
|
+
[ 11, "ascii", "ascii_general_ci", true ],
|
26
|
+
[ 12, "ujis", "ujis_japanese_ci", true ],
|
27
|
+
[ 13, "sjis", "sjis_japanese_ci", true ],
|
28
|
+
[ 14, "cp1251", "cp1251_bulgarian_ci", false],
|
29
|
+
[ 15, "latin1", "latin1_danish_ci", false],
|
30
|
+
[ 16, "hebrew", "hebrew_general_ci", true ],
|
31
|
+
[ 18, "tis620", "tis620_thai_ci", true ],
|
32
|
+
[ 19, "euckr", "euckr_korean_ci", true ],
|
33
|
+
[ 20, "latin7", "latin7_estonian_cs", false],
|
34
|
+
[ 21, "latin2", "latin2_hungarian_ci", false],
|
35
|
+
[ 22, "koi8u", "koi8u_general_ci", true ],
|
36
|
+
[ 23, "cp1251", "cp1251_ukrainian_ci", false],
|
37
|
+
[ 24, "gb2312", "gb2312_chinese_ci", true ],
|
38
|
+
[ 25, "greek", "greek_general_ci", true ],
|
39
|
+
[ 26, "cp1250", "cp1250_general_ci", true ],
|
40
|
+
[ 27, "latin2", "latin2_croatian_ci", false],
|
41
|
+
[ 28, "gbk", "gbk_chinese_ci", true ],
|
42
|
+
[ 29, "cp1257", "cp1257_lithuanian_ci", false],
|
43
|
+
[ 30, "latin5", "latin5_turkish_ci", true ],
|
44
|
+
[ 31, "latin1", "latin1_german2_ci", false],
|
45
|
+
[ 32, "armscii8", "armscii8_general_ci", true ],
|
46
|
+
[ 33, "utf8", "utf8_general_ci", true ],
|
47
|
+
[ 34, "cp1250", "cp1250_czech_cs", false],
|
48
|
+
[ 35, "ucs2", "ucs2_general_ci", true ],
|
49
|
+
[ 36, "cp866", "cp866_general_ci", true ],
|
50
|
+
[ 37, "keybcs2", "keybcs2_general_ci", true ],
|
51
|
+
[ 38, "macce", "macce_general_ci", true ],
|
52
|
+
[ 39, "macroman", "macroman_general_ci", true ],
|
53
|
+
[ 40, "cp852", "cp852_general_ci", true ],
|
54
|
+
[ 41, "latin7", "latin7_general_ci", true ],
|
55
|
+
[ 42, "latin7", "latin7_general_cs", false],
|
56
|
+
[ 43, "macce", "macce_bin", false],
|
57
|
+
[ 44, "cp1250", "cp1250_croatian_ci", false],
|
58
|
+
[ 47, "latin1", "latin1_bin", false],
|
59
|
+
[ 48, "latin1", "latin1_general_ci", false],
|
60
|
+
[ 49, "latin1", "latin1_general_cs", false],
|
61
|
+
[ 50, "cp1251", "cp1251_bin", false],
|
62
|
+
[ 51, "cp1251", "cp1251_general_ci", true ],
|
63
|
+
[ 52, "cp1251", "cp1251_general_cs", false],
|
64
|
+
[ 53, "macroman", "macroman_bin", false],
|
65
|
+
[ 57, "cp1256", "cp1256_general_ci", true ],
|
66
|
+
[ 58, "cp1257", "cp1257_bin", false],
|
67
|
+
[ 59, "cp1257", "cp1257_general_ci", true ],
|
68
|
+
[ 63, "binary", "binary", true ],
|
69
|
+
[ 64, "armscii8", "armscii8_bin", false],
|
70
|
+
[ 65, "ascii", "ascii_bin", false],
|
71
|
+
[ 66, "cp1250", "cp1250_bin", false],
|
72
|
+
[ 67, "cp1256", "cp1256_bin", false],
|
73
|
+
[ 68, "cp866", "cp866_bin", false],
|
74
|
+
[ 69, "dec8", "dec8_bin", false],
|
75
|
+
[ 70, "greek", "greek_bin", false],
|
76
|
+
[ 71, "hebrew", "hebrew_bin", false],
|
77
|
+
[ 72, "hp8", "hp8_bin", false],
|
78
|
+
[ 73, "keybcs2", "keybcs2_bin", false],
|
79
|
+
[ 74, "koi8r", "koi8r_bin", false],
|
80
|
+
[ 75, "koi8u", "koi8u_bin", false],
|
81
|
+
[ 77, "latin2", "latin2_bin", false],
|
82
|
+
[ 78, "latin5", "latin5_bin", false],
|
83
|
+
[ 79, "latin7", "latin7_bin", false],
|
84
|
+
[ 80, "cp850", "cp850_bin", false],
|
85
|
+
[ 81, "cp852", "cp852_bin", false],
|
86
|
+
[ 82, "swe7", "swe7_bin", false],
|
87
|
+
[ 83, "utf8", "utf8_bin", false],
|
88
|
+
[ 84, "big5", "big5_bin", false],
|
89
|
+
[ 85, "euckr", "euckr_bin", false],
|
90
|
+
[ 86, "gb2312", "gb2312_bin", false],
|
91
|
+
[ 87, "gbk", "gbk_bin", false],
|
92
|
+
[ 88, "sjis", "sjis_bin", false],
|
93
|
+
[ 89, "tis620", "tis620_bin", false],
|
94
|
+
[ 90, "ucs2", "ucs2_bin", false],
|
95
|
+
[ 91, "ujis", "ujis_bin", false],
|
96
|
+
[ 92, "geostd8", "geostd8_general_ci", true ],
|
97
|
+
[ 93, "geostd8", "geostd8_bin", false],
|
98
|
+
[ 94, "latin1", "latin1_spanish_ci", false],
|
99
|
+
[ 95, "cp932", "cp932_japanese_ci" , true ],
|
100
|
+
[ 96, "cp932", "cp932_bin" , false],
|
101
|
+
[ 97, "eucjpms", "eucjpms_japanese_ci", true ],
|
102
|
+
[ 98, "eucjpms", "eucjpms_bin", false],
|
103
|
+
[128, "ucs2", "ucs2_unicode_ci", false],
|
104
|
+
[129, "ucs2", "ucs2_icelandic_ci", false],
|
105
|
+
[130, "ucs2", "ucs2_latvian_ci", false],
|
106
|
+
[131, "ucs2", "ucs2_romanian_ci", false],
|
107
|
+
[132, "ucs2", "ucs2_slovenian_ci", false],
|
108
|
+
[133, "ucs2", "ucs2_polish_ci", false],
|
109
|
+
[134, "ucs2", "ucs2_estonian_ci", false],
|
110
|
+
[135, "ucs2", "ucs2_spanish_ci", false],
|
111
|
+
[136, "ucs2", "ucs2_swedish_ci", false],
|
112
|
+
[137, "ucs2", "ucs2_turkish_ci", false],
|
113
|
+
[138, "ucs2", "ucs2_czech_ci", false],
|
114
|
+
[139, "ucs2", "ucs2_danish_ci", false],
|
115
|
+
[140, "ucs2", "ucs2_lithuanian_ci", false],
|
116
|
+
[141, "ucs2", "ucs2_slovak_ci", false],
|
117
|
+
[142, "ucs2", "ucs2_spanish2_ci", false],
|
118
|
+
[143, "ucs2", "ucs2_roman_ci", false],
|
119
|
+
[144, "ucs2", "ucs2_persian_ci", false],
|
120
|
+
[145, "ucs2", "ucs2_esperanto_ci", false],
|
121
|
+
[146, "ucs2", "ucs2_hungarian_ci", false],
|
122
|
+
[192, "utf8", "utf8_unicode_ci", false],
|
123
|
+
[193, "utf8", "utf8_icelandic_ci", false],
|
124
|
+
[194, "utf8", "utf8_latvian_ci", false],
|
125
|
+
[195, "utf8", "utf8_romanian_ci", false],
|
126
|
+
[196, "utf8", "utf8_slovenian_ci", false],
|
127
|
+
[197, "utf8", "utf8_polish_ci", false],
|
128
|
+
[198, "utf8", "utf8_estonian_ci", false],
|
129
|
+
[199, "utf8", "utf8_spanish_ci", false],
|
130
|
+
[200, "utf8", "utf8_swedish_ci", false],
|
131
|
+
[201, "utf8", "utf8_turkish_ci", false],
|
132
|
+
[202, "utf8", "utf8_czech_ci", false],
|
133
|
+
[203, "utf8", "utf8_danish_ci", false],
|
134
|
+
[204, "utf8", "utf8_lithuanian_ci", false],
|
135
|
+
[205, "utf8", "utf8_slovak_ci", false],
|
136
|
+
[206, "utf8", "utf8_spanish2_ci", false],
|
137
|
+
[207, "utf8", "utf8_roman_ci", false],
|
138
|
+
[208, "utf8", "utf8_persian_ci", false],
|
139
|
+
[209, "utf8", "utf8_esperanto_ci", false],
|
140
|
+
[210, "utf8", "utf8_hungarian_ci", false],
|
141
|
+
]
|
142
|
+
|
143
|
+
NUMBER_TO_CHARSET = {}
|
144
|
+
COLLATION_TO_CHARSET = {}
|
145
|
+
CHARSET_DEFAULT = {}
|
146
|
+
CHARSETS.each do |number, csname, clname, default|
|
147
|
+
cs = Charset.new number, csname, clname
|
148
|
+
NUMBER_TO_CHARSET[number] = cs
|
149
|
+
COLLATION_TO_CHARSET[clname] = cs
|
150
|
+
CHARSET_DEFAULT[csname] = cs if default
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.by_number(n)
|
154
|
+
raise ClientError, "unknown charset number: #{n}" unless NUMBER_TO_CHARSET.key? n
|
155
|
+
NUMBER_TO_CHARSET[n]
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.by_name(str)
|
159
|
+
ret = COLLATION_TO_CHARSET[str] || CHARSET_DEFAULT[str]
|
160
|
+
raise ClientError, "unknown charset: #{str}" unless ret
|
161
|
+
ret
|
162
|
+
end
|
163
|
+
|
164
|
+
if defined? Encoding
|
165
|
+
|
166
|
+
# MySQL Charset -> Ruby's Encodeing
|
167
|
+
CHARSET_ENCODING = {
|
168
|
+
"armscii8" => nil,
|
169
|
+
"ascii" => Encoding::US_ASCII,
|
170
|
+
"big5" => Encoding::Big5,
|
171
|
+
"binary" => Encoding::ASCII_8BIT,
|
172
|
+
"cp1250" => Encoding::Windows_1250,
|
173
|
+
"cp1251" => Encoding::Windows_1251,
|
174
|
+
"cp1256" => Encoding::Windows_1256,
|
175
|
+
"cp1257" => Encoding::Windows_1257,
|
176
|
+
"cp850" => Encoding::CP850,
|
177
|
+
"cp852" => Encoding::CP852,
|
178
|
+
"cp866" => Encoding::IBM866,
|
179
|
+
"cp932" => Encoding::Windows_31J,
|
180
|
+
"dec8" => nil,
|
181
|
+
"eucjpms" => Encoding::EucJP_ms,
|
182
|
+
"euckr" => Encoding::EUC_KR,
|
183
|
+
"gb2312" => Encoding::EUC_CN,
|
184
|
+
"gbk" => Encoding::GBK,
|
185
|
+
"geostd8" => nil,
|
186
|
+
"greek" => Encoding::ISO_8859_7,
|
187
|
+
"hebrew" => Encoding::ISO_8859_8,
|
188
|
+
"hp8" => nil,
|
189
|
+
"keybcs2" => nil,
|
190
|
+
"koi8r" => Encoding::KOI8_R,
|
191
|
+
"koi8u" => Encoding::KOI8_U,
|
192
|
+
"latin1" => Encoding::ISO_8859_1,
|
193
|
+
"latin2" => Encoding::ISO_8859_2,
|
194
|
+
"latin5" => Encoding::ISO_8859_9,
|
195
|
+
"latin7" => Encoding::ISO_8859_13,
|
196
|
+
"macce" => Encoding::MacCentEuro,
|
197
|
+
"macroman" => Encoding::MacRoman,
|
198
|
+
"sjis" => Encoding::SHIFT_JIS,
|
199
|
+
"swe7" => nil,
|
200
|
+
"tis620" => nil,
|
201
|
+
"ucs2" => Encoding::UTF_16BE,
|
202
|
+
"ujis" => Encoding::EucJP_ms,
|
203
|
+
"utf8" => Encoding::UTF_8,
|
204
|
+
}
|
205
|
+
|
206
|
+
def self.to_binary(value)
|
207
|
+
value.dup.force_encoding Encoding::ASCII_8BIT
|
208
|
+
end
|
209
|
+
|
210
|
+
# retrun corresponding Ruby encoding
|
211
|
+
# === Return
|
212
|
+
# encoding [Encoding]
|
213
|
+
def encoding
|
214
|
+
enc = CHARSET_ENCODING[@name.downcase]
|
215
|
+
raise Mysql::ClientError, "unsupported charset: #{@name}" unless enc
|
216
|
+
enc
|
217
|
+
end
|
218
|
+
|
219
|
+
# convert encoding to corrensponding to MySQL charset
|
220
|
+
def convert(value)
|
221
|
+
if value.is_a? String and value.encoding != Encoding::ASCII_8BIT
|
222
|
+
value = value.encode encoding
|
223
|
+
end
|
224
|
+
value
|
225
|
+
end
|
226
|
+
|
227
|
+
# convert encoding from MySQL charset to Ruby
|
228
|
+
def force_encoding(value)
|
229
|
+
if value.is_a? String
|
230
|
+
value = value.dup.force_encoding encoding
|
231
|
+
end
|
232
|
+
value
|
233
|
+
end
|
234
|
+
|
235
|
+
else
|
236
|
+
# for Ruby 1.8
|
237
|
+
|
238
|
+
def self.to_binary(value)
|
239
|
+
value
|
240
|
+
end
|
241
|
+
|
242
|
+
def encoding
|
243
|
+
nil
|
244
|
+
end
|
245
|
+
|
246
|
+
def convert(value)
|
247
|
+
value
|
248
|
+
end
|
249
|
+
|
250
|
+
def force_encoding(value)
|
251
|
+
value
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# Copyright (C) 2003-2008 TOMITA Masahiro
|
2
|
+
# mailto:tommy@tmtm.org
|
3
|
+
|
4
|
+
class Mysql
|
5
|
+
# Command
|
6
|
+
COM_SLEEP = 0
|
7
|
+
COM_QUIT = 1
|
8
|
+
COM_INIT_DB = 2
|
9
|
+
COM_QUERY = 3
|
10
|
+
COM_FIELD_LIST = 4
|
11
|
+
COM_CREATE_DB = 5
|
12
|
+
COM_DROP_DB = 6
|
13
|
+
COM_REFRESH = 7
|
14
|
+
COM_SHUTDOWN = 8
|
15
|
+
COM_STATISTICS = 9
|
16
|
+
COM_PROCESS_INFO = 10
|
17
|
+
COM_CONNECT = 11
|
18
|
+
COM_PROCESS_KILL = 12
|
19
|
+
COM_DEBUG = 13
|
20
|
+
COM_PING = 14
|
21
|
+
COM_TIME = 15
|
22
|
+
COM_DELAYED_INSERT = 16
|
23
|
+
COM_CHANGE_USER = 17
|
24
|
+
COM_BINLOG_DUMP = 18
|
25
|
+
COM_TABLE_DUMP = 19
|
26
|
+
COM_CONNECT_OUT = 20
|
27
|
+
COM_REGISTER_SLAVE = 21
|
28
|
+
COM_STMT_PREPARE = 22
|
29
|
+
COM_STMT_EXECUTE = 23
|
30
|
+
COM_STMT_SEND_LONG_DATA = 24
|
31
|
+
COM_STMT_CLOSE = 25
|
32
|
+
COM_STMT_RESET = 26
|
33
|
+
COM_SET_OPTION = 27
|
34
|
+
COM_STMT_FETCH = 28
|
35
|
+
|
36
|
+
# Client flag
|
37
|
+
CLIENT_LONG_PASSWORD = 1 # new more secure passwords
|
38
|
+
CLIENT_FOUND_ROWS = 1 << 1 # Found instead of affected rows
|
39
|
+
CLIENT_LONG_FLAG = 1 << 2 # Get all column flags
|
40
|
+
CLIENT_CONNECT_WITH_DB = 1 << 3 # One can specify db on connect
|
41
|
+
CLIENT_NO_SCHEMA = 1 << 4 # Don't allow database.table.column
|
42
|
+
CLIENT_COMPRESS = 1 << 5 # Can use compression protocol
|
43
|
+
CLIENT_ODBC = 1 << 6 # Odbc client
|
44
|
+
CLIENT_LOCAL_FILES = 1 << 7 # Can use LOAD DATA LOCAL
|
45
|
+
CLIENT_IGNORE_SPACE = 1 << 8 # Ignore spaces before '('
|
46
|
+
CLIENT_PROTOCOL_41 = 1 << 9 # New 4.1 protocol
|
47
|
+
CLIENT_INTERACTIVE = 1 << 10 # This is an interactive client
|
48
|
+
CLIENT_SSL = 1 << 11 # Switch to SSL after handshake
|
49
|
+
CLIENT_IGNORE_SIGPIPE = 1 << 12 # IGNORE sigpipes
|
50
|
+
CLIENT_TRANSACTIONS = 1 << 13 # Client knows about transactions
|
51
|
+
CLIENT_RESERVED = 1 << 14 # Old flag for 4.1 protocol
|
52
|
+
CLIENT_SECURE_CONNECTION = 1 << 15 # New 4.1 authentication
|
53
|
+
CLIENT_MULTI_STATEMENTS = 1 << 16 # Enable/disable multi-stmt support
|
54
|
+
CLIENT_MULTI_RESULTS = 1 << 17 # Enable/disable multi-results
|
55
|
+
|
56
|
+
# Connection Option
|
57
|
+
OPT_CONNECT_TIMEOUT = 0
|
58
|
+
OPT_COMPRESS = 1
|
59
|
+
OPT_NAMED_PIPE = 2
|
60
|
+
INIT_COMMAND = 3
|
61
|
+
READ_DEFAULT_FILE = 4
|
62
|
+
READ_DEFAULT_GROUP = 5
|
63
|
+
SET_CHARSET_DIR = 6
|
64
|
+
SET_CHARSET_NAME = 7
|
65
|
+
OPT_LOCAL_INFILE = 8
|
66
|
+
OPT_PROTOCOL = 9
|
67
|
+
SHARED_MEMORY_BASE_NAME = 10
|
68
|
+
OPT_READ_TIMEOUT = 11
|
69
|
+
OPT_WRITE_TIMEOUT = 12
|
70
|
+
OPT_USE_RESULT = 13
|
71
|
+
OPT_USE_REMOTE_CONNECTION = 14
|
72
|
+
OPT_USE_EMBEDDED_CONNECTION = 15
|
73
|
+
OPT_GUESS_CONNECTION = 16
|
74
|
+
SET_CLIENT_IP = 17
|
75
|
+
SECURE_AUTH = 18
|
76
|
+
REPORT_DATA_TRUNCATION = 19
|
77
|
+
OPT_RECONNECT = 20
|
78
|
+
OPT_SSL_VERIFY_SERVER_CERT = 21
|
79
|
+
|
80
|
+
# Server Option
|
81
|
+
OPTION_MULTI_STATEMENTS_ON = 0
|
82
|
+
OPTION_MULTI_STATEMENTS_OFF = 1
|
83
|
+
|
84
|
+
# Server Status
|
85
|
+
SERVER_STATUS_IN_TRANS = 1
|
86
|
+
SERVER_STATUS_AUTOCOMMIT = 1 << 1
|
87
|
+
SERVER_MORE_RESULTS_EXISTS = 1 << 3
|
88
|
+
SERVER_QUERY_NO_GOOD_INDEX_USED = 1 << 4
|
89
|
+
SERVER_QUERY_NO_INDEX_USED = 1 << 5
|
90
|
+
SERVER_STATUS_CURSOR_EXISTS = 1 << 6
|
91
|
+
SERVER_STATUS_LAST_ROW_SENT = 1 << 7
|
92
|
+
SERVER_STATUS_DB_DROPPED = 1 << 8
|
93
|
+
SERVER_STATUS_NO_BACKSLASH_ESCAPES = 1 << 9
|
94
|
+
|
95
|
+
# Refresh parameter
|
96
|
+
REFRESH_GRANT = 1
|
97
|
+
REFRESH_LOG = 1 << 1
|
98
|
+
REFRESH_TABLES = 1 << 2
|
99
|
+
REFRESH_HOSTS = 1 << 3
|
100
|
+
REFRESH_STATUS = 1 << 4
|
101
|
+
REFRESH_THREADS = 1 << 5
|
102
|
+
REFRESH_SLAVE = 1 << 6
|
103
|
+
REFRESH_MASTER = 1 << 7
|
104
|
+
REFRESH_READ_LOCK = 1 << 14
|
105
|
+
REFRESH_FAST = 1 << 15
|
106
|
+
|
107
|
+
class Field
|
108
|
+
# Field type
|
109
|
+
TYPE_DECIMAL = 0
|
110
|
+
TYPE_TINY = 1
|
111
|
+
TYPE_SHORT = 2
|
112
|
+
TYPE_LONG = 3
|
113
|
+
TYPE_FLOAT = 4
|
114
|
+
TYPE_DOUBLE = 5
|
115
|
+
TYPE_NULL = 6
|
116
|
+
TYPE_TIMESTAMP = 7
|
117
|
+
TYPE_LONGLONG = 8
|
118
|
+
TYPE_INT24 = 9
|
119
|
+
TYPE_DATE = 10
|
120
|
+
TYPE_TIME = 11
|
121
|
+
TYPE_DATETIME = 12
|
122
|
+
TYPE_YEAR = 13
|
123
|
+
TYPE_NEWDATE = 14
|
124
|
+
TYPE_VARCHAR = 15
|
125
|
+
TYPE_BIT = 16
|
126
|
+
TYPE_NEWDECIMAL = 246
|
127
|
+
TYPE_ENUM = 247
|
128
|
+
TYPE_SET = 248
|
129
|
+
TYPE_TINY_BLOB = 249
|
130
|
+
TYPE_MEDIUM_BLOB = 250
|
131
|
+
TYPE_LONG_BLOB = 251
|
132
|
+
TYPE_BLOB = 252
|
133
|
+
TYPE_VAR_STRING = 253
|
134
|
+
TYPE_STRING = 254
|
135
|
+
TYPE_GEOMETRY = 255
|
136
|
+
TYPE_CHAR = TYPE_TINY
|
137
|
+
TYPE_INTERVAL = TYPE_ENUM
|
138
|
+
|
139
|
+
# Flag
|
140
|
+
NOT_NULL_FLAG = 1
|
141
|
+
PRI_KEY_FLAG = 2
|
142
|
+
UNIQUE_KEY_FLAG = 4
|
143
|
+
MULTIPLE_KEY_FLAG = 8
|
144
|
+
BLOB_FLAG = 16
|
145
|
+
UNSIGNED_FLAG = 32
|
146
|
+
ZEROFILL_FLAG = 64
|
147
|
+
BINARY_FLAG = 128
|
148
|
+
ENUM_FLAG = 256
|
149
|
+
AUTO_INCREMENT_FLAG = 512
|
150
|
+
TIMESTAMP_FLAG = 1024
|
151
|
+
SET_FLAG = 2048
|
152
|
+
NUM_FLAG = 32768
|
153
|
+
PART_KEY_FLAG = 16384
|
154
|
+
GROUP_FLAG = 32768
|
155
|
+
UNIQUE_FLAG = 65536
|
156
|
+
BINCMP_FLAG = 131072
|
157
|
+
end
|
158
|
+
|
159
|
+
class Stmt
|
160
|
+
# Cursor type
|
161
|
+
CURSOR_TYPE_NO_CURSOR = 0
|
162
|
+
CURSOR_TYPE_READ_ONLY = 1
|
163
|
+
end
|
164
|
+
end
|
data/lib/mysql/error.rb
ADDED
@@ -0,0 +1,518 @@
|
|
1
|
+
# Copyright (C) 2003-2008 TOMITA Masahiro
|
2
|
+
# mailto:tommy@tmtm.org
|
3
|
+
|
4
|
+
class Mysql
|
5
|
+
class Error < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
class ServerError < Error
|
9
|
+
ERRNO = 0
|
10
|
+
def initialize(message, sqlstate=nil)
|
11
|
+
@sqlstate = sqlstate
|
12
|
+
@error = message
|
13
|
+
super message
|
14
|
+
end
|
15
|
+
attr_reader :sqlstate, :error
|
16
|
+
|
17
|
+
def errno
|
18
|
+
self.class::ERRNO
|
19
|
+
end
|
20
|
+
|
21
|
+
ERROR_MAP = {}
|
22
|
+
|
23
|
+
ER_HASHCHK = 1000
|
24
|
+
ER_NISAMCHK = 1001
|
25
|
+
ER_NO = 1002
|
26
|
+
ER_YES = 1003
|
27
|
+
ER_CANT_CREATE_FILE = 1004
|
28
|
+
ER_CANT_CREATE_TABLE = 1005
|
29
|
+
ER_CANT_CREATE_DB = 1006
|
30
|
+
ER_DB_CREATE_EXISTS = 1007
|
31
|
+
ER_DB_DROP_EXISTS = 1008
|
32
|
+
ER_DB_DROP_DELETE = 1009
|
33
|
+
ER_DB_DROP_RMDIR = 1010
|
34
|
+
ER_CANT_DELETE_FILE = 1011
|
35
|
+
ER_CANT_FIND_SYSTEM_REC = 1012
|
36
|
+
ER_CANT_GET_STAT = 1013
|
37
|
+
ER_CANT_GET_WD = 1014
|
38
|
+
ER_CANT_LOCK = 1015
|
39
|
+
ER_CANT_OPEN_FILE = 1016
|
40
|
+
ER_FILE_NOT_FOUND = 1017
|
41
|
+
ER_CANT_READ_DIR = 1018
|
42
|
+
ER_CANT_SET_WD = 1019
|
43
|
+
ER_CHECKREAD = 1020
|
44
|
+
ER_DISK_FULL = 1021
|
45
|
+
ER_DUP_KEY = 1022
|
46
|
+
ER_ERROR_ON_CLOSE = 1023
|
47
|
+
ER_ERROR_ON_READ = 1024
|
48
|
+
ER_ERROR_ON_RENAME = 1025
|
49
|
+
ER_ERROR_ON_WRITE = 1026
|
50
|
+
ER_FILE_USED = 1027
|
51
|
+
ER_FILSORT_ABORT = 1028
|
52
|
+
ER_FORM_NOT_FOUND = 1029
|
53
|
+
ER_GET_ERRNO = 1030
|
54
|
+
ER_ILLEGAL_HA = 1031
|
55
|
+
ER_KEY_NOT_FOUND = 1032
|
56
|
+
ER_NOT_FORM_FILE = 1033
|
57
|
+
ER_NOT_KEYFILE = 1034
|
58
|
+
ER_OLD_KEYFILE = 1035
|
59
|
+
ER_OPEN_AS_READONLY = 1036
|
60
|
+
ER_OUTOFMEMORY = 1037
|
61
|
+
ER_OUT_OF_SORTMEMORY = 1038
|
62
|
+
ER_UNEXPECTED_EOF = 1039
|
63
|
+
ER_CON_COUNT_ERROR = 1040
|
64
|
+
ER_OUT_OF_RESOURCES = 1041
|
65
|
+
ER_BAD_HOST_ERROR = 1042
|
66
|
+
ER_HANDSHAKE_ERROR = 1043
|
67
|
+
ER_DBACCESS_DENIED_ERROR = 1044
|
68
|
+
ER_ACCESS_DENIED_ERROR = 1045
|
69
|
+
ER_NO_DB_ERROR = 1046
|
70
|
+
ER_UNKNOWN_COM_ERROR = 1047
|
71
|
+
ER_BAD_NULL_ERROR = 1048
|
72
|
+
ER_BAD_DB_ERROR = 1049
|
73
|
+
ER_TABLE_EXISTS_ERROR = 1050
|
74
|
+
ER_BAD_TABLE_ERROR = 1051
|
75
|
+
ER_NON_UNIQ_ERROR = 1052
|
76
|
+
ER_SERVER_SHUTDOWN = 1053
|
77
|
+
ER_BAD_FIELD_ERROR = 1054
|
78
|
+
ER_WRONG_FIELD_WITH_GROUP = 1055
|
79
|
+
ER_WRONG_GROUP_FIELD = 1056
|
80
|
+
ER_WRONG_SUM_SELECT = 1057
|
81
|
+
ER_WRONG_VALUE_COUNT = 1058
|
82
|
+
ER_TOO_LONG_IDENT = 1059
|
83
|
+
ER_DUP_FIELDNAME = 1060
|
84
|
+
ER_DUP_KEYNAME = 1061
|
85
|
+
ER_DUP_ENTRY = 1062
|
86
|
+
ER_WRONG_FIELD_SPEC = 1063
|
87
|
+
ER_PARSE_ERROR = 1064
|
88
|
+
ER_EMPTY_QUERY = 1065
|
89
|
+
ER_NONUNIQ_TABLE = 1066
|
90
|
+
ER_INVALID_DEFAULT = 1067
|
91
|
+
ER_MULTIPLE_PRI_KEY = 1068
|
92
|
+
ER_TOO_MANY_KEYS = 1069
|
93
|
+
ER_TOO_MANY_KEY_PARTS = 1070
|
94
|
+
ER_TOO_LONG_KEY = 1071
|
95
|
+
ER_KEY_COLUMN_DOES_NOT_EXITS = 1072
|
96
|
+
ER_BLOB_USED_AS_KEY = 1073
|
97
|
+
ER_TOO_BIG_FIELDLENGTH = 1074
|
98
|
+
ER_WRONG_AUTO_KEY = 1075
|
99
|
+
ER_READY = 1076
|
100
|
+
ER_NORMAL_SHUTDOWN = 1077
|
101
|
+
ER_GOT_SIGNAL = 1078
|
102
|
+
ER_SHUTDOWN_COMPLETE = 1079
|
103
|
+
ER_FORCING_CLOSE = 1080
|
104
|
+
ER_IPSOCK_ERROR = 1081
|
105
|
+
ER_NO_SUCH_INDEX = 1082
|
106
|
+
ER_WRONG_FIELD_TERMINATORS = 1083
|
107
|
+
ER_BLOBS_AND_NO_TERMINATED = 1084
|
108
|
+
ER_TEXTFILE_NOT_READABLE = 1085
|
109
|
+
ER_FILE_EXISTS_ERROR = 1086
|
110
|
+
ER_LOAD_INFO = 1087
|
111
|
+
ER_ALTER_INFO = 1088
|
112
|
+
ER_WRONG_SUB_KEY = 1089
|
113
|
+
ER_CANT_REMOVE_ALL_FIELDS = 1090
|
114
|
+
ER_CANT_DROP_FIELD_OR_KEY = 1091
|
115
|
+
ER_INSERT_INFO = 1092
|
116
|
+
ER_UPDATE_TABLE_USED = 1093
|
117
|
+
ER_NO_SUCH_THREAD = 1094
|
118
|
+
ER_KILL_DENIED_ERROR = 1095
|
119
|
+
ER_NO_TABLES_USED = 1096
|
120
|
+
ER_TOO_BIG_SET = 1097
|
121
|
+
ER_NO_UNIQUE_LOGFILE = 1098
|
122
|
+
ER_TABLE_NOT_LOCKED_FOR_WRITE = 1099
|
123
|
+
ER_TABLE_NOT_LOCKED = 1100
|
124
|
+
ER_BLOB_CANT_HAVE_DEFAULT = 1101
|
125
|
+
ER_WRONG_DB_NAME = 1102
|
126
|
+
ER_WRONG_TABLE_NAME = 1103
|
127
|
+
ER_TOO_BIG_SELECT = 1104
|
128
|
+
ER_UNKNOWN_ERROR = 1105
|
129
|
+
ER_UNKNOWN_PROCEDURE = 1106
|
130
|
+
ER_WRONG_PARAMCOUNT_TO_PROCEDURE = 1107
|
131
|
+
ER_WRONG_PARAMETERS_TO_PROCEDURE = 1108
|
132
|
+
ER_UNKNOWN_TABLE = 1109
|
133
|
+
ER_FIELD_SPECIFIED_TWICE = 1110
|
134
|
+
ER_INVALID_GROUP_FUNC_USE = 1111
|
135
|
+
ER_UNSUPPORTED_EXTENSION = 1112
|
136
|
+
ER_TABLE_MUST_HAVE_COLUMNS = 1113
|
137
|
+
ER_RECORD_FILE_FULL = 1114
|
138
|
+
ER_UNKNOWN_CHARACTER_SET = 1115
|
139
|
+
ER_TOO_MANY_TABLES = 1116
|
140
|
+
ER_TOO_MANY_FIELDS = 1117
|
141
|
+
ER_TOO_BIG_ROWSIZE = 1118
|
142
|
+
ER_STACK_OVERRUN = 1119
|
143
|
+
ER_WRONG_OUTER_JOIN = 1120
|
144
|
+
ER_NULL_COLUMN_IN_INDEX = 1121
|
145
|
+
ER_CANT_FIND_UDF = 1122
|
146
|
+
ER_CANT_INITIALIZE_UDF = 1123
|
147
|
+
ER_UDF_NO_PATHS = 1124
|
148
|
+
ER_UDF_EXISTS = 1125
|
149
|
+
ER_CANT_OPEN_LIBRARY = 1126
|
150
|
+
ER_CANT_FIND_DL_ENTRY = 1127
|
151
|
+
ER_FUNCTION_NOT_DEFINED = 1128
|
152
|
+
ER_HOST_IS_BLOCKED = 1129
|
153
|
+
ER_HOST_NOT_PRIVILEGED = 1130
|
154
|
+
ER_PASSWORD_ANONYMOUS_USER = 1131
|
155
|
+
ER_PASSWORD_NOT_ALLOWED = 1132
|
156
|
+
ER_PASSWORD_NO_MATCH = 1133
|
157
|
+
ER_UPDATE_INFO = 1134
|
158
|
+
ER_CANT_CREATE_THREAD = 1135
|
159
|
+
ER_WRONG_VALUE_COUNT_ON_ROW = 1136
|
160
|
+
ER_CANT_REOPEN_TABLE = 1137
|
161
|
+
ER_INVALID_USE_OF_NULL = 1138
|
162
|
+
ER_REGEXP_ERROR = 1139
|
163
|
+
ER_MIX_OF_GROUP_FUNC_AND_FIELDS = 1140
|
164
|
+
ER_NONEXISTING_GRANT = 1141
|
165
|
+
ER_TABLEACCESS_DENIED_ERROR = 1142
|
166
|
+
ER_COLUMNACCESS_DENIED_ERROR = 1143
|
167
|
+
ER_ILLEGAL_GRANT_FOR_TABLE = 1144
|
168
|
+
ER_GRANT_WRONG_HOST_OR_USER = 1145
|
169
|
+
ER_NO_SUCH_TABLE = 1146
|
170
|
+
ER_NONEXISTING_TABLE_GRANT = 1147
|
171
|
+
ER_NOT_ALLOWED_COMMAND = 1148
|
172
|
+
ER_SYNTAX_ERROR = 1149
|
173
|
+
ER_DELAYED_CANT_CHANGE_LOCK = 1150
|
174
|
+
ER_TOO_MANY_DELAYED_THREADS = 1151
|
175
|
+
ER_ABORTING_CONNECTION = 1152
|
176
|
+
ER_NET_PACKET_TOO_LARGE = 1153
|
177
|
+
ER_NET_READ_ERROR_FROM_PIPE = 1154
|
178
|
+
ER_NET_FCNTL_ERROR = 1155
|
179
|
+
ER_NET_PACKETS_OUT_OF_ORDER = 1156
|
180
|
+
ER_NET_UNCOMPRESS_ERROR = 1157
|
181
|
+
ER_NET_READ_ERROR = 1158
|
182
|
+
ER_NET_READ_INTERRUPTED = 1159
|
183
|
+
ER_NET_ERROR_ON_WRITE = 1160
|
184
|
+
ER_NET_WRITE_INTERRUPTED = 1161
|
185
|
+
ER_TOO_LONG_STRING = 1162
|
186
|
+
ER_TABLE_CANT_HANDLE_BLOB = 1163
|
187
|
+
ER_TABLE_CANT_HANDLE_AUTO_INCREMENT = 1164
|
188
|
+
ER_DELAYED_INSERT_TABLE_LOCKED = 1165
|
189
|
+
ER_WRONG_COLUMN_NAME = 1166
|
190
|
+
ER_WRONG_KEY_COLUMN = 1167
|
191
|
+
ER_WRONG_MRG_TABLE = 1168
|
192
|
+
ER_DUP_UNIQUE = 1169
|
193
|
+
ER_BLOB_KEY_WITHOUT_LENGTH = 1170
|
194
|
+
ER_PRIMARY_CANT_HAVE_NULL = 1171
|
195
|
+
ER_TOO_MANY_ROWS = 1172
|
196
|
+
ER_REQUIRES_PRIMARY_KEY = 1173
|
197
|
+
ER_NO_RAID_COMPILED = 1174
|
198
|
+
ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE = 1175
|
199
|
+
ER_KEY_DOES_NOT_EXITS = 1176
|
200
|
+
ER_CHECK_NO_SUCH_TABLE = 1177
|
201
|
+
ER_CHECK_NOT_IMPLEMENTED = 1178
|
202
|
+
ER_CANT_DO_THIS_DURING_AN_TRANSACTION = 1179
|
203
|
+
ER_ERROR_DURING_COMMIT = 1180
|
204
|
+
ER_ERROR_DURING_ROLLBACK = 1181
|
205
|
+
ER_ERROR_DURING_FLUSH_LOGS = 1182
|
206
|
+
ER_ERROR_DURING_CHECKPOINT = 1183
|
207
|
+
ER_NEW_ABORTING_CONNECTION = 1184
|
208
|
+
ER_DUMP_NOT_IMPLEMENTED = 1185
|
209
|
+
ER_FLUSH_MASTER_BINLOG_CLOSED = 1186
|
210
|
+
ER_INDEX_REBUILD = 1187
|
211
|
+
ER_MASTER = 1188
|
212
|
+
ER_MASTER_NET_READ = 1189
|
213
|
+
ER_MASTER_NET_WRITE = 1190
|
214
|
+
ER_FT_MATCHING_KEY_NOT_FOUND = 1191
|
215
|
+
ER_LOCK_OR_ACTIVE_TRANSACTION = 1192
|
216
|
+
ER_UNKNOWN_SYSTEM_VARIABLE = 1193
|
217
|
+
ER_CRASHED_ON_USAGE = 1194
|
218
|
+
ER_CRASHED_ON_REPAIR = 1195
|
219
|
+
ER_WARNING_NOT_COMPLETE_ROLLBACK = 1196
|
220
|
+
ER_TRANS_CACHE_FULL = 1197
|
221
|
+
ER_SLAVE_MUST_STOP = 1198
|
222
|
+
ER_SLAVE_NOT_RUNNING = 1199
|
223
|
+
ER_BAD_SLAVE = 1200
|
224
|
+
ER_MASTER_INFO = 1201
|
225
|
+
ER_SLAVE_THREAD = 1202
|
226
|
+
ER_TOO_MANY_USER_CONNECTIONS = 1203
|
227
|
+
ER_SET_CONSTANTS_ONLY = 1204
|
228
|
+
ER_LOCK_WAIT_TIMEOUT = 1205
|
229
|
+
ER_LOCK_TABLE_FULL = 1206
|
230
|
+
ER_READ_ONLY_TRANSACTION = 1207
|
231
|
+
ER_DROP_DB_WITH_READ_LOCK = 1208
|
232
|
+
ER_CREATE_DB_WITH_READ_LOCK = 1209
|
233
|
+
ER_WRONG_ARGUMENTS = 1210
|
234
|
+
ER_NO_PERMISSION_TO_CREATE_USER = 1211
|
235
|
+
ER_UNION_TABLES_IN_DIFFERENT_DIR = 1212
|
236
|
+
ER_LOCK_DEADLOCK = 1213
|
237
|
+
ER_TABLE_CANT_HANDLE_FT = 1214
|
238
|
+
ER_CANNOT_ADD_FOREIGN = 1215
|
239
|
+
ER_NO_REFERENCED_ROW = 1216
|
240
|
+
ER_ROW_IS_REFERENCED = 1217
|
241
|
+
ER_CONNECT_TO_MASTER = 1218
|
242
|
+
ER_QUERY_ON_MASTER = 1219
|
243
|
+
ER_ERROR_WHEN_EXECUTING_COMMAND = 1220
|
244
|
+
ER_WRONG_USAGE = 1221
|
245
|
+
ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT = 1222
|
246
|
+
ER_CANT_UPDATE_WITH_READLOCK = 1223
|
247
|
+
ER_MIXING_NOT_ALLOWED = 1224
|
248
|
+
ER_DUP_ARGUMENT = 1225
|
249
|
+
ER_USER_LIMIT_REACHED = 1226
|
250
|
+
ER_SPECIFIC_ACCESS_DENIED_ERROR = 1227
|
251
|
+
ER_LOCAL_VARIABLE = 1228
|
252
|
+
ER_GLOBAL_VARIABLE = 1229
|
253
|
+
ER_NO_DEFAULT = 1230
|
254
|
+
ER_WRONG_VALUE_FOR_VAR = 1231
|
255
|
+
ER_WRONG_TYPE_FOR_VAR = 1232
|
256
|
+
ER_VAR_CANT_BE_READ = 1233
|
257
|
+
ER_CANT_USE_OPTION_HERE = 1234
|
258
|
+
ER_NOT_SUPPORTED_YET = 1235
|
259
|
+
ER_MASTER_FATAL_ERROR_READING_BINLOG = 1236
|
260
|
+
ER_SLAVE_IGNORED_TABLE = 1237
|
261
|
+
ER_INCORRECT_GLOBAL_LOCAL_VAR = 1238
|
262
|
+
ER_WRONG_FK_DEF = 1239
|
263
|
+
ER_KEY_REF_DO_NOT_MATCH_TABLE_REF = 1240
|
264
|
+
ER_OPERAND_COLUMNS = 1241
|
265
|
+
ER_SUBQUERY_NO_1_ROW = 1242
|
266
|
+
ER_UNKNOWN_STMT_HANDLER = 1243
|
267
|
+
ER_CORRUPT_HELP_DB = 1244
|
268
|
+
ER_CYCLIC_REFERENCE = 1245
|
269
|
+
ER_AUTO_CONVERT = 1246
|
270
|
+
ER_ILLEGAL_REFERENCE = 1247
|
271
|
+
ER_DERIVED_MUST_HAVE_ALIAS = 1248
|
272
|
+
ER_SELECT_REDUCED = 1249
|
273
|
+
ER_TABLENAME_NOT_ALLOWED_HERE = 1250
|
274
|
+
ER_NOT_SUPPORTED_AUTH_MODE = 1251
|
275
|
+
ER_SPATIAL_CANT_HAVE_NULL = 1252
|
276
|
+
ER_COLLATION_CHARSET_MISMATCH = 1253
|
277
|
+
ER_SLAVE_WAS_RUNNING = 1254
|
278
|
+
ER_SLAVE_WAS_NOT_RUNNING = 1255
|
279
|
+
ER_TOO_BIG_FOR_UNCOMPRESS = 1256
|
280
|
+
ER_ZLIB_Z_MEM_ERROR = 1257
|
281
|
+
ER_ZLIB_Z_BUF_ERROR = 1258
|
282
|
+
ER_ZLIB_Z_DATA_ERROR = 1259
|
283
|
+
ER_CUT_VALUE_GROUP_CONCAT = 1260
|
284
|
+
ER_WARN_TOO_FEW_RECORDS = 1261
|
285
|
+
ER_WARN_TOO_MANY_RECORDS = 1262
|
286
|
+
ER_WARN_NULL_TO_NOTNULL = 1263
|
287
|
+
ER_WARN_DATA_OUT_OF_RANGE = 1264
|
288
|
+
WARN_DATA_TRUNCATED = 1265
|
289
|
+
ER_WARN_USING_OTHER_HANDLER = 1266
|
290
|
+
ER_CANT_AGGREGATE_2COLLATIONS = 1267
|
291
|
+
ER_DROP_USER = 1268
|
292
|
+
ER_REVOKE_GRANTS = 1269
|
293
|
+
ER_CANT_AGGREGATE_3COLLATIONS = 1270
|
294
|
+
ER_CANT_AGGREGATE_NCOLLATIONS = 1271
|
295
|
+
ER_VARIABLE_IS_NOT_STRUCT = 1272
|
296
|
+
ER_UNKNOWN_COLLATION = 1273
|
297
|
+
ER_SLAVE_IGNORED_SSL_PARAMS = 1274
|
298
|
+
ER_SERVER_IS_IN_SECURE_AUTH_MODE = 1275
|
299
|
+
ER_WARN_FIELD_RESOLVED = 1276
|
300
|
+
ER_BAD_SLAVE_UNTIL_COND = 1277
|
301
|
+
ER_MISSING_SKIP_SLAVE = 1278
|
302
|
+
ER_UNTIL_COND_IGNORED = 1279
|
303
|
+
ER_WRONG_NAME_FOR_INDEX = 1280
|
304
|
+
ER_WRONG_NAME_FOR_CATALOG = 1281
|
305
|
+
ER_WARN_QC_RESIZE = 1282
|
306
|
+
ER_BAD_FT_COLUMN = 1283
|
307
|
+
ER_UNKNOWN_KEY_CACHE = 1284
|
308
|
+
ER_WARN_HOSTNAME_WONT_WORK = 1285
|
309
|
+
ER_UNKNOWN_STORAGE_ENGINE = 1286
|
310
|
+
ER_WARN_DEPRECATED_SYNTAX = 1287
|
311
|
+
ER_NON_UPDATABLE_TABLE = 1288
|
312
|
+
ER_FEATURE_DISABLED = 1289
|
313
|
+
ER_OPTION_PREVENTS_STATEMENT = 1290
|
314
|
+
ER_DUPLICATED_VALUE_IN_TYPE = 1291
|
315
|
+
ER_TRUNCATED_WRONG_VALUE = 1292
|
316
|
+
ER_TOO_MUCH_AUTO_TIMESTAMP_COLS = 1293
|
317
|
+
ER_INVALID_ON_UPDATE = 1294
|
318
|
+
ER_UNSUPPORTED_PS = 1295
|
319
|
+
ER_GET_ERRMSG = 1296
|
320
|
+
ER_GET_TEMPORARY_ERRMSG = 1297
|
321
|
+
ER_UNKNOWN_TIME_ZONE = 1298
|
322
|
+
ER_WARN_INVALID_TIMESTAMP = 1299
|
323
|
+
ER_INVALID_CHARACTER_STRING = 1300
|
324
|
+
ER_WARN_ALLOWED_PACKET_OVERFLOWED = 1301
|
325
|
+
ER_CONFLICTING_DECLARATIONS = 1302
|
326
|
+
ER_SP_NO_RECURSIVE_CREATE = 1303
|
327
|
+
ER_SP_ALREADY_EXISTS = 1304
|
328
|
+
ER_SP_DOES_NOT_EXIST = 1305
|
329
|
+
ER_SP_DROP_FAILED = 1306
|
330
|
+
ER_SP_STORE_FAILED = 1307
|
331
|
+
ER_SP_LILABEL_MISMATCH = 1308
|
332
|
+
ER_SP_LABEL_REDEFINE = 1309
|
333
|
+
ER_SP_LABEL_MISMATCH = 1310
|
334
|
+
ER_SP_UNINIT_VAR = 1311
|
335
|
+
ER_SP_BADSELECT = 1312
|
336
|
+
ER_SP_BADRETURN = 1313
|
337
|
+
ER_SP_BADSTATEMENT = 1314
|
338
|
+
ER_UPDATE_LOG_DEPRECATED_IGNORED = 1315
|
339
|
+
ER_UPDATE_LOG_DEPRECATED_TRANSLATED = 1316
|
340
|
+
ER_QUERY_INTERRUPTED = 1317
|
341
|
+
ER_SP_WRONG_NO_OF_ARGS = 1318
|
342
|
+
ER_SP_COND_MISMATCH = 1319
|
343
|
+
ER_SP_NORETURN = 1320
|
344
|
+
ER_SP_NORETURNEND = 1321
|
345
|
+
ER_SP_BAD_CURSOR_QUERY = 1322
|
346
|
+
ER_SP_BAD_CURSOR_SELECT = 1323
|
347
|
+
ER_SP_CURSOR_MISMATCH = 1324
|
348
|
+
ER_SP_CURSOR_ALREADY_OPEN = 1325
|
349
|
+
ER_SP_CURSOR_NOT_OPEN = 1326
|
350
|
+
ER_SP_UNDECLARED_VAR = 1327
|
351
|
+
ER_SP_WRONG_NO_OF_FETCH_ARGS = 1328
|
352
|
+
ER_SP_FETCH_NO_DATA = 1329
|
353
|
+
ER_SP_DUP_PARAM = 1330
|
354
|
+
ER_SP_DUP_VAR = 1331
|
355
|
+
ER_SP_DUP_COND = 1332
|
356
|
+
ER_SP_DUP_CURS = 1333
|
357
|
+
ER_SP_CANT_ALTER = 1334
|
358
|
+
ER_SP_SUBSELECT_NYI = 1335
|
359
|
+
ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG = 1336
|
360
|
+
ER_SP_VARCOND_AFTER_CURSHNDLR = 1337
|
361
|
+
ER_SP_CURSOR_AFTER_HANDLER = 1338
|
362
|
+
ER_SP_CASE_NOT_FOUND = 1339
|
363
|
+
ER_FPARSER_TOO_BIG_FILE = 1340
|
364
|
+
ER_FPARSER_BAD_HEADER = 1341
|
365
|
+
ER_FPARSER_EOF_IN_COMMENT = 1342
|
366
|
+
ER_FPARSER_ERROR_IN_PARAMETER = 1343
|
367
|
+
ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER = 1344
|
368
|
+
ER_VIEW_NO_EXPLAIN = 1345
|
369
|
+
ER_FRM_UNKNOWN_TYPE = 1346
|
370
|
+
ER_WRONG_OBJECT = 1347
|
371
|
+
ER_NONUPDATEABLE_COLUMN = 1348
|
372
|
+
ER_VIEW_SELECT_DERIVED = 1349
|
373
|
+
ER_VIEW_SELECT_CLAUSE = 1350
|
374
|
+
ER_VIEW_SELECT_VARIABLE = 1351
|
375
|
+
ER_VIEW_SELECT_TMPTABLE = 1352
|
376
|
+
ER_VIEW_WRONG_LIST = 1353
|
377
|
+
ER_WARN_VIEW_MERGE = 1354
|
378
|
+
ER_WARN_VIEW_WITHOUT_KEY = 1355
|
379
|
+
ER_VIEW_INVALID = 1356
|
380
|
+
ER_SP_NO_DROP_SP = 1357
|
381
|
+
ER_SP_GOTO_IN_HNDLR = 1358
|
382
|
+
ER_TRG_ALREADY_EXISTS = 1359
|
383
|
+
ER_TRG_DOES_NOT_EXIST = 1360
|
384
|
+
ER_TRG_ON_VIEW_OR_TEMP_TABLE = 1361
|
385
|
+
ER_TRG_CANT_CHANGE_ROW = 1362
|
386
|
+
ER_TRG_NO_SUCH_ROW_IN_TRG = 1363
|
387
|
+
ER_NO_DEFAULT_FOR_FIELD = 1364
|
388
|
+
ER_DIVISION_BY_ZERO = 1365
|
389
|
+
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD = 1366
|
390
|
+
ER_ILLEGAL_VALUE_FOR_TYPE = 1367
|
391
|
+
ER_VIEW_NONUPD_CHECK = 1368
|
392
|
+
ER_VIEW_CHECK_FAILED = 1369
|
393
|
+
ER_PROCACCESS_DENIED_ERROR = 1370
|
394
|
+
ER_RELAY_LOG_FAIL = 1371
|
395
|
+
ER_PASSWD_LENGTH = 1372
|
396
|
+
ER_UNKNOWN_TARGET_BINLOG = 1373
|
397
|
+
ER_IO_ERR_LOG_INDEX_READ = 1374
|
398
|
+
ER_BINLOG_PURGE_PROHIBITED = 1375
|
399
|
+
ER_FSEEK_FAIL = 1376
|
400
|
+
ER_BINLOG_PURGE_FATAL_ERR = 1377
|
401
|
+
ER_LOG_IN_USE = 1378
|
402
|
+
ER_LOG_PURGE_UNKNOWN_ERR = 1379
|
403
|
+
ER_RELAY_LOG_INIT = 1380
|
404
|
+
ER_NO_BINARY_LOGGING = 1381
|
405
|
+
ER_RESERVED_SYNTAX = 1382
|
406
|
+
ER_WSAS_FAILED = 1383
|
407
|
+
ER_DIFF_GROUPS_PROC = 1384
|
408
|
+
ER_NO_GROUP_FOR_PROC = 1385
|
409
|
+
ER_ORDER_WITH_PROC = 1386
|
410
|
+
ER_LOGGING_PROHIBIT_CHANGING_OF = 1387
|
411
|
+
ER_NO_FILE_MAPPING = 1388
|
412
|
+
ER_WRONG_MAGIC = 1389
|
413
|
+
ER_PS_MANY_PARAM = 1390
|
414
|
+
ER_KEY_PART_0 = 1391
|
415
|
+
ER_VIEW_CHECKSUM = 1392
|
416
|
+
ER_VIEW_MULTIUPDATE = 1393
|
417
|
+
ER_VIEW_NO_INSERT_FIELD_LIST = 1394
|
418
|
+
ER_VIEW_DELETE_MERGE_VIEW = 1395
|
419
|
+
ER_CANNOT_USER = 1396
|
420
|
+
ER_XAER_NOTA = 1397
|
421
|
+
ER_XAER_INVAL = 1398
|
422
|
+
ER_XAER_RMFAIL = 1399
|
423
|
+
ER_XAER_OUTSIDE = 1400
|
424
|
+
ER_XAER_RMERR = 1401
|
425
|
+
ER_XA_RBROLLBACK = 1402
|
426
|
+
ER_NONEXISTING_PROC_GRANT = 1403
|
427
|
+
ER_PROC_AUTO_GRANT_FAIL = 1404
|
428
|
+
ER_PROC_AUTO_REVOKE_FAIL = 1405
|
429
|
+
ER_DATA_TOO_LONG = 1406
|
430
|
+
ER_SP_BAD_SQLSTATE = 1407
|
431
|
+
ER_STARTUP = 1408
|
432
|
+
ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR = 1409
|
433
|
+
ER_CANT_CREATE_USER_WITH_GRANT = 1410
|
434
|
+
ER_WRONG_VALUE_FOR_TYPE = 1411
|
435
|
+
ER_TABLE_DEF_CHANGED = 1412
|
436
|
+
ER_SP_DUP_HANDLER = 1413
|
437
|
+
ER_SP_NOT_VAR_ARG = 1414
|
438
|
+
ER_SP_NO_RETSET = 1415
|
439
|
+
ER_CANT_CREATE_GEOMETRY_OBJECT = 1416
|
440
|
+
ER_FAILED_ROUTINE_BREAK_BINLOG = 1417
|
441
|
+
ER_BINLOG_UNSAFE_ROUTINE = 1418
|
442
|
+
ER_BINLOG_CREATE_ROUTINE_NEED_SUPER = 1419
|
443
|
+
ER_EXEC_STMT_WITH_OPEN_CURSOR = 1420
|
444
|
+
ER_STMT_HAS_NO_OPEN_CURSOR = 1421
|
445
|
+
ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG = 1422
|
446
|
+
ER_NO_DEFAULT_FOR_VIEW_FIELD = 1423
|
447
|
+
ER_SP_NO_RECURSION = 1424
|
448
|
+
ER_TOO_BIG_SCALE = 1425
|
449
|
+
ER_TOO_BIG_PRECISION = 1426
|
450
|
+
ER_M_BIGGER_THAN_D = 1427
|
451
|
+
ER_WRONG_LOCK_OF_SYSTEM_TABLE = 1428
|
452
|
+
ER_CONNECT_TO_FOREIGN_DATA_SOURCE = 1429
|
453
|
+
ER_QUERY_ON_FOREIGN_DATA_SOURCE = 1430
|
454
|
+
ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST = 1431
|
455
|
+
ER_FOREIGN_DATA_STRING_INVALID_CANT_CREATE = 1432
|
456
|
+
ER_FOREIGN_DATA_STRING_INVALID = 1433
|
457
|
+
ER_CANT_CREATE_FEDERATED_TABLE = 1434
|
458
|
+
ER_TRG_IN_WRONG_SCHEMA = 1435
|
459
|
+
ER_STACK_OVERRUN_NEED_MORE = 1436
|
460
|
+
ER_TOO_LONG_BODY = 1437
|
461
|
+
ER_WARN_CANT_DROP_DEFAULT_KEYCACHE = 1438
|
462
|
+
ER_TOO_BIG_DISPLAYWIDTH = 1439
|
463
|
+
ER_XAER_DUPID = 1440
|
464
|
+
ER_DATETIME_FUNCTION_OVERFLOW = 1441
|
465
|
+
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG = 1442
|
466
|
+
ER_VIEW_PREVENT_UPDATE = 1443
|
467
|
+
ER_PS_NO_RECURSION = 1444
|
468
|
+
ER_SP_CANT_SET_AUTOCOMMIT = 1445
|
469
|
+
ER_MALFORMED_DEFINER = 1446
|
470
|
+
ER_VIEW_FRM_NO_USER = 1447
|
471
|
+
ER_VIEW_OTHER_USER = 1448
|
472
|
+
ER_NO_SUCH_USER = 1449
|
473
|
+
ER_FORBID_SCHEMA_CHANGE = 1450
|
474
|
+
ER_ROW_IS_REFERENCED_2 = 1451
|
475
|
+
ER_NO_REFERENCED_ROW_2 = 1452
|
476
|
+
ER_SP_BAD_VAR_SHADOW = 1453
|
477
|
+
ER_TRG_NO_DEFINER = 1454
|
478
|
+
ER_OLD_FILE_FORMAT = 1455
|
479
|
+
ER_SP_RECURSION_LIMIT = 1456
|
480
|
+
ER_SP_PROC_TABLE_CORRUPT = 1457
|
481
|
+
ER_SP_WRONG_NAME = 1458
|
482
|
+
ER_TABLE_NEEDS_UPGRADE = 1459
|
483
|
+
ER_SP_NO_AGGREGATE = 1460
|
484
|
+
ER_MAX_PREPARED_STMT_COUNT_REACHED = 1461
|
485
|
+
ER_VIEW_RECURSIVE = 1462
|
486
|
+
ER_NON_GROUPING_FIELD_USED = 1463
|
487
|
+
ER_TABLE_CANT_HANDLE_SPKEYS = 1464
|
488
|
+
ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA = 1465
|
489
|
+
ER_REMOVED_SPACES = 1466
|
490
|
+
ER_AUTOINC_READ_FAILED = 1467
|
491
|
+
ER_USERNAME = 1468
|
492
|
+
ER_HOSTNAME = 1469
|
493
|
+
ER_WRONG_STRING_LENGTH = 1470
|
494
|
+
ER_NON_INSERTABLE_TABLE = 1471
|
495
|
+
end
|
496
|
+
|
497
|
+
ServerError.constants.each do |errname|
|
498
|
+
errname = errname.to_s
|
499
|
+
next unless errname =~ /\AER_/
|
500
|
+
errno = ServerError.const_get errname
|
501
|
+
excname = errname.sub(/\AER_/,"").gsub(/(\A.|_.)([A-Z]+)/){$1+$2.downcase}.gsub(/_/,"")
|
502
|
+
eval <<EOS
|
503
|
+
class Mysql::#{excname} < Mysql::ServerError
|
504
|
+
ERRNO = #{errno}
|
505
|
+
end
|
506
|
+
EOS
|
507
|
+
ServerError::ERROR_MAP[errno] = eval "Mysql::#{excname}"
|
508
|
+
end
|
509
|
+
|
510
|
+
# client side error
|
511
|
+
class ClientError < Error
|
512
|
+
end
|
513
|
+
|
514
|
+
# protocol error
|
515
|
+
class ProtocolError < ClientError
|
516
|
+
end
|
517
|
+
|
518
|
+
end
|