Merge lp:~mordred/drizzle/one-more-stab-at-boolean into lp:drizzle/7.0
- one-more-stab-at-boolean
- Merge into 7.0
Proposed by
Monty Taylor
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Brian Aker | ||||
Approved revision: | 2194 | ||||
Merged at revision: | 2190 | ||||
Proposed branch: | lp:~mordred/drizzle/one-more-stab-at-boolean | ||||
Merge into: | lp:drizzle/7.0 | ||||
Diff against target: |
630 lines (+272/-49) 14 files modified
client/drizzle.cc (+127/-9) client/drizzledump.cc (+7/-7) client/drizzledump_data.cc (+11/-13) client/drizzledump_data.h (+4/-7) client/drizzledump_drizzle.cc (+4/-4) client/drizzletest.cc (+38/-3) client/include.am (+1/-0) client/server_detect.h (+61/-0) drizzled/field/boolean.cc (+2/-0) libdrizzle/column.c (+1/-1) libdrizzle/constants.h (+5/-1) plugin/mysql_protocol/mysql_protocol.cc (+8/-1) po/Makefile.in.in (+1/-1) tests/r/show_check.result (+2/-2) |
||||
To merge this branch: | bzr merge lp:~mordred/drizzle/one-more-stab-at-boolean | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Hutchings | Approve | ||
Review via email: mp+50675@code.launchpad.net |
Commit message
Description of the change
Gets us use of the boolean stuff via mysql_protocol for MySQL clients, but keeps the TRUE/FALSE YES/NO behavior in drizzle context.
To post a comment you must log in.
- 2194. By Monty Taylor
-
Fixed two tiny things.
Revision history for this message
Brian Aker (brianaker) wrote : | # |
Nice hack :)
Revision history for this message
Monty Taylor (mordred) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 02/21/2011 05:39 PM, Brian Aker wrote:
> Nice hack :)
Thanks! ;)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAk1
3I4AnA5pWfV1efI
=yx2q
-----END PGP SIGNATURE-----
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'client/drizzle.cc' |
2 | --- client/drizzle.cc 2011-02-17 00:14:13 +0000 |
3 | +++ client/drizzle.cc 2011-02-22 00:33:14 +0000 |
4 | @@ -37,7 +37,8 @@ |
5 | #include <config.h> |
6 | #include <libdrizzle/drizzle_client.h> |
7 | |
8 | -#include <client/get_password.h> |
9 | +#include "server_detect.h" |
10 | +#include "get_password.h" |
11 | |
12 | #include <boost/date_time/posix_time/posix_time.hpp> |
13 | |
14 | @@ -307,6 +308,7 @@ |
15 | static uint32_t select_limit; |
16 | static uint32_t max_join_size; |
17 | static uint32_t opt_connect_timeout= 0; |
18 | +static ServerDetect::server_type server_type= ServerDetect::SERVER_UNKNOWN_FOUND; |
19 | std::string current_db, |
20 | delimiter_str, |
21 | current_host, |
22 | @@ -3128,11 +3130,15 @@ |
23 | drizzle_return_t ret; |
24 | drizzle_column_st *field; |
25 | std::vector<bool> num_flag; |
26 | + std::vector<bool> boolean_flag; |
27 | + std::vector<bool> ansi_boolean_flag; |
28 | string separator; |
29 | |
30 | separator.reserve(256); |
31 | |
32 | num_flag.resize(drizzle_result_column_count(result)); |
33 | + boolean_flag.resize(drizzle_result_column_count(result)); |
34 | + ansi_boolean_flag.resize(drizzle_result_column_count(result)); |
35 | if (column_types_flag) |
36 | { |
37 | print_field_types(result); |
38 | @@ -3175,6 +3181,14 @@ |
39 | // Room for "NULL" |
40 | length=4; |
41 | } |
42 | + if ((length < 5) and |
43 | + (server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and |
44 | + (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY) and |
45 | + (drizzle_column_type(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
46 | + { |
47 | + // Room for "FALSE" |
48 | + length= 5; |
49 | + } |
50 | drizzle_column_set_max_size(field, length); |
51 | |
52 | for (x=0; x< (length+2); x++) |
53 | @@ -3198,6 +3212,24 @@ |
54 | drizzle_column_name(field)); |
55 | num_flag[off]= ((drizzle_column_type(field) <= DRIZZLE_COLUMN_TYPE_LONGLONG) || |
56 | (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_NEWDECIMAL)); |
57 | + if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and |
58 | + (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY)) |
59 | + { |
60 | + if ((drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
61 | + { |
62 | + ansi_boolean_flag[off]= true; |
63 | + } |
64 | + else |
65 | + { |
66 | + ansi_boolean_flag[off]= false; |
67 | + } |
68 | + boolean_flag[off]= true; |
69 | + num_flag[off]= false; |
70 | + } |
71 | + else |
72 | + { |
73 | + boolean_flag[off]= false; |
74 | + } |
75 | } |
76 | (void) tee_fputs("\n", PAGER); |
77 | tee_puts((char*) separator.c_str(), PAGER); |
78 | @@ -3236,6 +3268,35 @@ |
79 | buffer= "NULL"; |
80 | data_length= 4; |
81 | } |
82 | + else if (boolean_flag[off]) |
83 | + { |
84 | + if (strncmp(cur[off],"1", 1) == 0) |
85 | + { |
86 | + if (ansi_boolean_flag[off]) |
87 | + { |
88 | + buffer= "YES"; |
89 | + data_length= 3; |
90 | + } |
91 | + else |
92 | + { |
93 | + buffer= "TRUE"; |
94 | + data_length= 4; |
95 | + } |
96 | + } |
97 | + else |
98 | + { |
99 | + if (ansi_boolean_flag[off]) |
100 | + { |
101 | + buffer= "NO"; |
102 | + data_length= 2; |
103 | + } |
104 | + else |
105 | + { |
106 | + buffer= "FALSE"; |
107 | + data_length= 5; |
108 | + } |
109 | + } |
110 | + } |
111 | else |
112 | { |
113 | buffer= cur[off]; |
114 | @@ -3509,16 +3570,41 @@ |
115 | drizzle_return_t ret; |
116 | drizzle_column_st *field; |
117 | size_t *lengths; |
118 | - |
119 | - if (opt_silent < 2 && column_names) |
120 | + std::vector<bool> boolean_flag; |
121 | + std::vector<bool> ansi_boolean_flag; |
122 | + |
123 | + boolean_flag.resize(drizzle_result_column_count(result)); |
124 | + ansi_boolean_flag.resize(drizzle_result_column_count(result)); |
125 | + |
126 | + int first=0; |
127 | + for (uint32_t off= 0; (field = drizzle_column_next(result)); off++) |
128 | { |
129 | - int first=0; |
130 | - while ((field = drizzle_column_next(result))) |
131 | + if (opt_silent < 2 && column_names) |
132 | { |
133 | if (first++) |
134 | (void) tee_fputs("\t", PAGER); |
135 | (void) tee_fputs(drizzle_column_name(field), PAGER); |
136 | } |
137 | + if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and |
138 | + (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY)) |
139 | + { |
140 | + if ((drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
141 | + { |
142 | + ansi_boolean_flag[off]= true; |
143 | + } |
144 | + else |
145 | + { |
146 | + ansi_boolean_flag[off]= false; |
147 | + } |
148 | + boolean_flag[off]= true; |
149 | + } |
150 | + else |
151 | + { |
152 | + boolean_flag[off]= false; |
153 | + } |
154 | + } |
155 | + if (opt_silent < 2 && column_names) |
156 | + { |
157 | (void) tee_fputs("\n", PAGER); |
158 | } |
159 | while (1) |
160 | @@ -3539,11 +3625,40 @@ |
161 | break; |
162 | |
163 | lengths= drizzle_row_field_sizes(result); |
164 | - safe_put_field(cur[0],lengths[0]); |
165 | - for (uint32_t off=1 ; off < drizzle_result_column_count(result); off++) |
166 | + drizzle_column_seek(result, 0); |
167 | + for (uint32_t off=0 ; off < drizzle_result_column_count(result); off++) |
168 | { |
169 | - (void) tee_fputs("\t", PAGER); |
170 | - safe_put_field(cur[off], lengths[off]); |
171 | + if (off != 0) |
172 | + (void) tee_fputs("\t", PAGER); |
173 | + if (boolean_flag[off]) |
174 | + { |
175 | + if (strncmp(cur[off],"1", 1) == 0) |
176 | + { |
177 | + if (ansi_boolean_flag[off]) |
178 | + { |
179 | + safe_put_field("YES", 3); |
180 | + } |
181 | + else |
182 | + { |
183 | + safe_put_field("TRUE", 4); |
184 | + } |
185 | + } |
186 | + else |
187 | + { |
188 | + if (ansi_boolean_flag[off]) |
189 | + { |
190 | + safe_put_field("NO", 2); |
191 | + } |
192 | + else |
193 | + { |
194 | + safe_put_field("FALSE", 5); |
195 | + } |
196 | + } |
197 | + } |
198 | + else |
199 | + { |
200 | + safe_put_field(cur[off], lengths[off]); |
201 | + } |
202 | } |
203 | (void) tee_fputs("\n", PAGER); |
204 | if (quick) |
205 | @@ -4108,6 +4223,9 @@ |
206 | } |
207 | connected=1; |
208 | |
209 | + ServerDetect server_detect(&con); |
210 | + server_type= server_detect.getServerType(); |
211 | + |
212 | build_completion_hash(opt_rehash, 1); |
213 | return 0; |
214 | } |
215 | |
216 | === modified file 'client/drizzledump.cc' |
217 | --- client/drizzledump.cc 2011-02-15 23:05:12 +0000 |
218 | +++ client/drizzledump.cc 2011-02-22 00:33:14 +0000 |
219 | @@ -241,9 +241,9 @@ |
220 | cout << "-- Host: " << current_host << " Database: " << db_name << endl; |
221 | cout << "-- ------------------------------------------------------" << endl; |
222 | cout << "-- Server version\t" << db_connection->getServerVersion(); |
223 | - if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) |
224 | + if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) |
225 | cout << " (MySQL server)"; |
226 | - else if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_DRIZZLE_FOUND) |
227 | + else if (db_connection->getServerType() == ServerDetect::SERVER_DRIZZLE_FOUND) |
228 | cout << " (Drizzle server)"; |
229 | cout << endl << endl; |
230 | } |
231 | @@ -351,7 +351,7 @@ |
232 | std::cerr << _("-- Retrieving database structures...") << std::endl; |
233 | |
234 | /* Blocking the MySQL privilege tables too because we can't import them due to bug#646187 */ |
235 | - if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) |
236 | + if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) |
237 | query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'performance_schema', 'mysql')"; |
238 | else |
239 | query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM DATA_DICTIONARY.SCHEMAS WHERE SCHEMA_NAME NOT IN ('information_schema','data_dictionary')"; |
240 | @@ -360,7 +360,7 @@ |
241 | while ((row= drizzle_row_next(tableres))) |
242 | { |
243 | std::string database_name(row[0]); |
244 | - if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) |
245 | + if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) |
246 | database= new DrizzleDumpDatabaseMySQL(database_name, db_connection); |
247 | else |
248 | database= new DrizzleDumpDatabaseDrizzle(database_name, db_connection); |
249 | @@ -383,7 +383,7 @@ |
250 | for (vector<string>::const_iterator it= db_names.begin(); it != db_names.end(); ++it) |
251 | { |
252 | temp= *it; |
253 | - if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) |
254 | + if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) |
255 | database= new DrizzleDumpDatabaseMySQL(temp, db_connection); |
256 | else |
257 | database= new DrizzleDumpDatabaseDrizzle(temp, db_connection); |
258 | @@ -396,7 +396,7 @@ |
259 | { |
260 | DrizzleDumpDatabase *database; |
261 | |
262 | - if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) |
263 | + if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) |
264 | database= new DrizzleDumpDatabaseMySQL(db, db_connection); |
265 | else |
266 | database= new DrizzleDumpDatabaseDrizzle(db, db_connection); |
267 | @@ -742,7 +742,7 @@ |
268 | maybe_exit(EX_DRIZZLEERR); |
269 | } |
270 | |
271 | - if ((db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled)) |
272 | + if ((db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled)) |
273 | db_connection->queryNoResult("SET NAMES 'utf8'"); |
274 | |
275 | if (vm.count("destination-type")) |
276 | |
277 | === modified file 'client/drizzledump_data.cc' |
278 | --- client/drizzledump_data.cc 2010-12-08 07:35:23 +0000 |
279 | +++ client/drizzledump_data.cc 2011-02-22 00:33:14 +0000 |
280 | @@ -373,6 +373,13 @@ |
281 | { |
282 | os << "NULL"; |
283 | } |
284 | + else if (obj.table->fields[i]->type.compare("BOOLEAN") == 0) |
285 | + { |
286 | + if (strncmp(row[i], "1", 1) == 0) |
287 | + os << "TRUE"; |
288 | + else |
289 | + os << "FALSE"; |
290 | + } |
291 | else |
292 | os << "'" << DrizzleDumpData::escape(row[i], row_sizes[i]) << "'"; |
293 | byte_counter+= 3; |
294 | @@ -561,19 +568,10 @@ |
295 | throw std::exception(); |
296 | } |
297 | |
298 | - boost::match_flag_type flags = boost::match_default; |
299 | - |
300 | - boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)"); |
301 | - boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)"); |
302 | - |
303 | - std::string version(getServerVersion()); |
304 | - |
305 | - if (regex_search(version, mysql_regex, flags)) |
306 | - serverType= SERVER_MYSQL_FOUND; |
307 | - else if (regex_search(version, drizzle_regex, flags)) |
308 | - serverType= SERVER_DRIZZLE_FOUND; |
309 | - else |
310 | - serverType= SERVER_UNKNOWN_FOUND; |
311 | + ServerDetect server_detect= ServerDetect(&connection); |
312 | + |
313 | + serverType= server_detect.getServerType(); |
314 | + serverVersion= server_detect.getServerVersion(); |
315 | } |
316 | |
317 | drizzle_result_st* DrizzleDumpConnection::query(std::string &str_query) |
318 | |
319 | === modified file 'client/drizzledump_data.h' |
320 | --- client/drizzledump_data.h 2010-12-08 07:35:23 +0000 |
321 | +++ client/drizzledump_data.h 2011-02-22 00:33:14 +0000 |
322 | @@ -22,6 +22,7 @@ |
323 | |
324 | #define DRIZZLE_MAX_LINE_LENGTH 1024*1024L-1025 |
325 | #include "client_priv.h" |
326 | +#include "server_detect.h" |
327 | #include <string> |
328 | #include <iostream> |
329 | #include <iomanip> |
330 | @@ -214,14 +215,10 @@ |
331 | drizzle_con_st connection; |
332 | std::string hostName; |
333 | bool drizzleProtocol; |
334 | - int serverType; |
335 | + ServerDetect::server_type serverType; |
336 | + std::string serverVersion; |
337 | |
338 | public: |
339 | - enum server_type { |
340 | - SERVER_MYSQL_FOUND, |
341 | - SERVER_DRIZZLE_FOUND, |
342 | - SERVER_UNKNOWN_FOUND |
343 | - }; |
344 | DrizzleDumpConnection(std::string &host, uint16_t port, |
345 | std::string &username, std::string &password, bool drizzle_protocol); |
346 | ~DrizzleDumpConnection(); |
347 | @@ -244,7 +241,7 @@ |
348 | bool setDB(std::string databaseName); |
349 | bool usingDrizzleProtocol(void) const { return drizzleProtocol; } |
350 | bool getServerType(void) const { return serverType; } |
351 | - const char* getServerVersion(void) { return drizzle_con_server_version(&connection); } |
352 | + std::string getServerVersion(void) const { return serverVersion; } |
353 | }; |
354 | |
355 | class DrizzleStringBuf : public std::streambuf |
356 | |
357 | === modified file 'client/drizzledump_drizzle.cc' |
358 | --- client/drizzledump_drizzle.cc 2010-12-06 12:15:06 +0000 |
359 | +++ client/drizzledump_drizzle.cc 2011-02-22 00:33:14 +0000 |
360 | @@ -195,9 +195,9 @@ |
361 | else |
362 | field->defaultValue= ""; |
363 | |
364 | - field->isNull= (strcmp(row[4], "YES") == 0) ? true : false; |
365 | - field->isAutoIncrement= (strcmp(row[9], "YES") == 0) ? true : false; |
366 | - field->defaultIsNull= (strcmp(row[3], "YES") == 0) ? true : false; |
367 | + field->isNull= (boost::lexical_cast<uint32_t>(row[4])) ? true : false; |
368 | + field->isAutoIncrement= (boost::lexical_cast<uint32_t>(row[9])) ? true : false; |
369 | + field->defaultIsNull= (boost::lexical_cast<uint32_t>(row[3])) ? true : false; |
370 | field->enumValues= (row[10]) ? row[10] : ""; |
371 | field->length= (row[5]) ? boost::lexical_cast<uint32_t>(row[5]) : 0; |
372 | field->decimalPrecision= (row[6]) ? boost::lexical_cast<uint32_t>(row[6]) : 0; |
373 | @@ -244,7 +244,7 @@ |
374 | indexes.push_back(index); |
375 | index = new DrizzleDumpIndexDrizzle(indexName, dcon); |
376 | index->isPrimary= (strcmp(row[0], "PRIMARY") == 0); |
377 | - index->isUnique= (strcmp(row[3], "YES") == 0); |
378 | + index->isUnique= boost::lexical_cast<uint32_t>(row[3]); |
379 | index->isHash= 0; |
380 | index->length= (row[4]) ? boost::lexical_cast<uint32_t>(row[4]) : 0; |
381 | lastKey= row[0]; |
382 | |
383 | === modified file 'client/drizzletest.cc' |
384 | --- client/drizzletest.cc 2011-02-17 00:14:13 +0000 |
385 | +++ client/drizzletest.cc 2011-02-22 00:33:14 +0000 |
386 | @@ -4697,8 +4697,36 @@ |
387 | for (i = 0; i < num_fields; i++) |
388 | { |
389 | column= drizzle_column_next(res); |
390 | - append_field(ds, i, column, |
391 | - (const char*)row[i], lengths[i], !row[i]); |
392 | + if (row[i] && (drizzle_column_type(column) == DRIZZLE_COLUMN_TYPE_TINY)) |
393 | + { |
394 | + if (boost::lexical_cast<uint32_t>(row[i])) |
395 | + { |
396 | + if ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
397 | + { |
398 | + append_field(ds, i, column, "YES", 3, false); |
399 | + } |
400 | + else |
401 | + { |
402 | + append_field(ds, i, column, "TRUE", 4, false); |
403 | + } |
404 | + } |
405 | + else |
406 | + { |
407 | + if ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_UNSIGNED)) |
408 | + { |
409 | + append_field(ds, i, column, "NO", 2, false); |
410 | + } |
411 | + else |
412 | + { |
413 | + append_field(ds, i, column, "FALSE", 5, false); |
414 | + } |
415 | + } |
416 | + } |
417 | + else |
418 | + { |
419 | + append_field(ds, i, column, |
420 | + (const char*)row[i], lengths[i], !row[i]); |
421 | + } |
422 | } |
423 | if (!display_result_vertically) |
424 | ds->append("\n"); |
425 | @@ -4742,7 +4770,14 @@ |
426 | ds->append("\t", 1); |
427 | replace_append_uint(ds, drizzle_column_size(column)); |
428 | ds->append("\t", 1); |
429 | - replace_append_uint(ds, drizzle_column_max_size(column)); |
430 | + if (drizzle_column_type(column) == DRIZZLE_COLUMN_TYPE_TINY) |
431 | + { |
432 | + replace_append_uint(ds, 1); |
433 | + } |
434 | + else |
435 | + { |
436 | + replace_append_uint(ds, drizzle_column_max_size(column)); |
437 | + } |
438 | ds->append("\t", 1); |
439 | ds->append((char*) ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_NOT_NULL) ? "N" : "Y"), 1); |
440 | ds->append("\t", 1); |
441 | |
442 | === modified file 'client/include.am' |
443 | --- client/include.am 2010-12-28 20:54:15 +0000 |
444 | +++ client/include.am 2011-02-22 00:33:14 +0000 |
445 | @@ -54,6 +54,7 @@ |
446 | client/drizzledump_drizzle.h \ |
447 | client/drizzledump_mysql.h \ |
448 | client/option_string.h \ |
449 | + client/server_detect.h \ |
450 | client/statement.h \ |
451 | client/stats.h \ |
452 | client/thread_context.h \ |
453 | |
454 | === added file 'client/server_detect.h' |
455 | --- client/server_detect.h 1970-01-01 00:00:00 +0000 |
456 | +++ client/server_detect.h 2011-02-22 00:33:14 +0000 |
457 | @@ -0,0 +1,61 @@ |
458 | +/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*- |
459 | + * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: |
460 | + * |
461 | + * Copyright (C) 2011 Andrew Hutchings |
462 | + * |
463 | + * This program is free software; you can redistribute it and/or modify |
464 | + * it under the terms of the GNU General Public License as published by |
465 | + * the Free Software Foundation; version 2 of the License. |
466 | + * |
467 | + * This program is distributed in the hope that it will be useful, |
468 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
469 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
470 | + * GNU General Public License for more details. |
471 | + * |
472 | + * You should have received a copy of the GNU General Public License |
473 | + * along with this program; if not, write to the Free Software |
474 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
475 | + */ |
476 | + |
477 | +#ifndef CLIENT_SERVER_DETECT_H |
478 | +#define CLIENT_SERVER_DETECT_H |
479 | + |
480 | +#include <boost/regex.hpp> |
481 | + |
482 | +class ServerDetect |
483 | +{ |
484 | + public: |
485 | + enum server_type { |
486 | + SERVER_MYSQL_FOUND, |
487 | + SERVER_DRIZZLE_FOUND, |
488 | + SERVER_UNKNOWN_FOUND |
489 | + }; |
490 | + |
491 | + server_type getServerType() { return type; } |
492 | + std::string& getServerVersion() { return version; } |
493 | + |
494 | + ServerDetect(drizzle_con_st *connection) : |
495 | + type(SERVER_UNKNOWN_FOUND), |
496 | + version("") |
497 | + { |
498 | + boost::match_flag_type flags = boost::match_default; |
499 | + |
500 | + boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)"); |
501 | + boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)"); |
502 | + |
503 | + version= drizzle_con_server_version(connection); |
504 | + |
505 | + if (regex_search(version, mysql_regex, flags)) |
506 | + type= SERVER_MYSQL_FOUND; |
507 | + else if (regex_search(version, drizzle_regex, flags)) |
508 | + type= SERVER_DRIZZLE_FOUND; |
509 | + else |
510 | + type= SERVER_UNKNOWN_FOUND; |
511 | + } |
512 | + |
513 | + private: |
514 | + server_type type; |
515 | + std::string version; |
516 | +}; |
517 | + |
518 | +#endif /* CLIENT_SERVER_DETECT_H */ |
519 | |
520 | === modified file 'drizzled/field/boolean.cc' |
521 | --- drizzled/field/boolean.cc 2011-02-19 01:04:19 +0000 |
522 | +++ drizzled/field/boolean.cc 2011-02-22 00:33:14 +0000 |
523 | @@ -60,6 +60,8 @@ |
524 | field_name_arg), |
525 | ansi_display(ansi_display_arg) |
526 | { |
527 | + if (ansi_display) |
528 | + flags|= UNSIGNED_FLAG; |
529 | } |
530 | |
531 | int Boolean::cmp(const unsigned char *a, const unsigned char *b) |
532 | |
533 | === modified file 'libdrizzle/column.c' |
534 | --- libdrizzle/column.c 2010-12-23 18:47:57 +0000 |
535 | +++ libdrizzle/column.c 2011-02-22 00:33:14 +0000 |
536 | @@ -65,7 +65,7 @@ |
537 | static drizzle_column_type_drizzle_t _column_type_drizzle_map_from[]= |
538 | { |
539 | DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 0 */ |
540 | - DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY, |
541 | + DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN, |
542 | DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
543 | DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG, |
544 | DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
545 | |
546 | === modified file 'libdrizzle/constants.h' |
547 | --- libdrizzle/constants.h 2010-12-19 16:20:13 +0000 |
548 | +++ libdrizzle/constants.h 2011-02-22 00:33:14 +0000 |
549 | @@ -391,7 +391,11 @@ |
550 | DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL, |
551 | DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM, |
552 | DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB, |
553 | - DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB |
554 | + DRIZZLE_COLUMN_TYPE_DRIZZLE_TIME, |
555 | + DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN, |
556 | + DRIZZLE_COLUMN_TYPE_DRIZZLE_UUID, |
557 | + DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME, |
558 | + DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME |
559 | } drizzle_column_type_drizzle_t; |
560 | |
561 | /** |
562 | |
563 | === modified file 'plugin/mysql_protocol/mysql_protocol.cc' |
564 | --- plugin/mysql_protocol/mysql_protocol.cc 2011-02-20 00:09:56 +0000 |
565 | +++ plugin/mysql_protocol/mysql_protocol.cc 2011-02-22 00:33:14 +0000 |
566 | @@ -35,6 +35,8 @@ |
567 | |
568 | #include <drizzled/identifier.h> |
569 | |
570 | +#include <libdrizzle/constants.h> |
571 | + |
572 | #define PROTOCOL_VERSION 10 |
573 | |
574 | namespace po= boost::program_options; |
575 | @@ -558,7 +560,7 @@ |
576 | break; |
577 | |
578 | case DRIZZLE_TYPE_BOOLEAN: |
579 | - pos[6]= 15; |
580 | + pos[6]= DRIZZLE_COLUMN_TYPE_TINY; |
581 | break; |
582 | |
583 | case DRIZZLE_TYPE_DECIMAL: |
584 | @@ -609,6 +611,11 @@ |
585 | { |
586 | if (from->is_null()) |
587 | return store(); |
588 | + if (from->type() == DRIZZLE_TYPE_BOOLEAN) |
589 | + { |
590 | + return store(from->val_int()); |
591 | + } |
592 | + |
593 | char buff[MAX_FIELD_WIDTH]; |
594 | String str(buff,sizeof(buff), &my_charset_bin); |
595 | |
596 | |
597 | === modified file 'po/Makefile.in.in' |
598 | --- po/Makefile.in.in 2011-02-14 20:32:29 +0000 |
599 | +++ po/Makefile.in.in 2011-02-22 00:33:14 +0000 |
600 | @@ -145,7 +145,7 @@ |
601 | check: all $(GETTEXT_PACKAGE).pot |
602 | rm -f missing notexist |
603 | srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m |
604 | - if [ -r missing -o -r notexist -a "x${INTLTOOL_WARNINGS}" = "xyes"]; then \ |
605 | + if [ -r missing -o -r notexist -a "x${INTLTOOL_WARNINGS}" = "xyes" ]; then \ |
606 | exit 1; \ |
607 | fi |
608 | |
609 | |
610 | === modified file 'tests/r/show_check.result' |
611 | --- tests/r/show_check.result 2011-02-04 09:04:08 +0000 |
612 | +++ tests/r/show_check.result 2011-02-22 00:33:14 +0000 |
613 | @@ -27,7 +27,7 @@ |
614 | show index from t1; |
615 | Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr |
616 | def data_dictionary show_indexes SHOW_INDEXES Table Table 8 1024 2 N 4097 0 45 |
617 | -def data_dictionary show_indexes SHOW_INDEXES Unique Unique 8 1 3 N 4097 0 63 |
618 | +def data_dictionary show_indexes SHOW_INDEXES Unique Unique 13 1 1 N 36897 0 63 |
619 | def data_dictionary show_indexes SHOW_INDEXES Key_name Key_name 8 1024 7 N 4097 0 45 |
620 | def data_dictionary show_indexes SHOW_INDEXES Seq_in_index Seq_in_index 5 21 1 N 36865 0 63 |
621 | def data_dictionary show_indexes SHOW_INDEXES Column_name Column_name 8 1024 1 N 4097 0 45 |
622 | @@ -447,7 +447,7 @@ |
623 | show index from t1; |
624 | Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr |
625 | def data_dictionary show_indexes SHOW_INDEXES Table Table 8 1024 2 N 4097 0 45 |
626 | -def data_dictionary show_indexes SHOW_INDEXES Unique Unique 8 1 3 N 4097 0 63 |
627 | +def data_dictionary show_indexes SHOW_INDEXES Unique Unique 13 1 1 N 36897 0 63 |
628 | def data_dictionary show_indexes SHOW_INDEXES Key_name Key_name 8 1024 7 N 4097 0 45 |
629 | def data_dictionary show_indexes SHOW_INDEXES Seq_in_index Seq_in_index 5 21 1 N 36865 0 63 |
630 | def data_dictionary show_indexes SHOW_INDEXES Column_name Column_name 8 1024 6 N 4097 0 45 |
Nice one :)