Merge lp:~mordred/drizzle/one-more-stab-at-boolean into lp:drizzle/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
Reviewer Review Type Date Requested Status
Andrew Hutchings Approve
Review via email: mp+50675@code.launchpad.net

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.
Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Nice one :)

review: Approve
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://enigmail.mozdev.org/

iEYEARECAAYFAk1jF3cACgkQ2Jv7/VK1RgF4FwCgzvj2pMGKzua9AJ2nftIMSQyl
3I4AnA5pWfV1efIU5NyiId/Ypd8N/HM4
=yx2q
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'client/drizzle.cc'
--- client/drizzle.cc 2011-02-17 00:14:13 +0000
+++ client/drizzle.cc 2011-02-22 00:33:14 +0000
@@ -37,7 +37,8 @@
37#include <config.h>37#include <config.h>
38#include <libdrizzle/drizzle_client.h>38#include <libdrizzle/drizzle_client.h>
3939
40#include <client/get_password.h>40#include "server_detect.h"
41#include "get_password.h"
4142
42#include <boost/date_time/posix_time/posix_time.hpp>43#include <boost/date_time/posix_time/posix_time.hpp>
4344
@@ -307,6 +308,7 @@
307static uint32_t select_limit;308static uint32_t select_limit;
308static uint32_t max_join_size;309static uint32_t max_join_size;
309static uint32_t opt_connect_timeout= 0;310static uint32_t opt_connect_timeout= 0;
311static ServerDetect::server_type server_type= ServerDetect::SERVER_UNKNOWN_FOUND;
310std::string current_db,312std::string current_db,
311 delimiter_str, 313 delimiter_str,
312 current_host,314 current_host,
@@ -3128,11 +3130,15 @@
3128 drizzle_return_t ret;3130 drizzle_return_t ret;
3129 drizzle_column_st *field;3131 drizzle_column_st *field;
3130 std::vector<bool> num_flag;3132 std::vector<bool> num_flag;
3133 std::vector<bool> boolean_flag;
3134 std::vector<bool> ansi_boolean_flag;
3131 string separator;3135 string separator;
31323136
3133 separator.reserve(256);3137 separator.reserve(256);
31343138
3135 num_flag.resize(drizzle_result_column_count(result));3139 num_flag.resize(drizzle_result_column_count(result));
3140 boolean_flag.resize(drizzle_result_column_count(result));
3141 ansi_boolean_flag.resize(drizzle_result_column_count(result));
3136 if (column_types_flag)3142 if (column_types_flag)
3137 {3143 {
3138 print_field_types(result);3144 print_field_types(result);
@@ -3175,6 +3181,14 @@
3175 // Room for "NULL"3181 // Room for "NULL"
3176 length=4;3182 length=4;
3177 }3183 }
3184 if ((length < 5) and
3185 (server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and
3186 (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY) and
3187 (drizzle_column_type(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED))
3188 {
3189 // Room for "FALSE"
3190 length= 5;
3191 }
3178 drizzle_column_set_max_size(field, length);3192 drizzle_column_set_max_size(field, length);
31793193
3180 for (x=0; x< (length+2); x++)3194 for (x=0; x< (length+2); x++)
@@ -3198,6 +3212,24 @@
3198 drizzle_column_name(field));3212 drizzle_column_name(field));
3199 num_flag[off]= ((drizzle_column_type(field) <= DRIZZLE_COLUMN_TYPE_LONGLONG) ||3213 num_flag[off]= ((drizzle_column_type(field) <= DRIZZLE_COLUMN_TYPE_LONGLONG) ||
3200 (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_NEWDECIMAL));3214 (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_NEWDECIMAL));
3215 if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and
3216 (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY))
3217 {
3218 if ((drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED))
3219 {
3220 ansi_boolean_flag[off]= true;
3221 }
3222 else
3223 {
3224 ansi_boolean_flag[off]= false;
3225 }
3226 boolean_flag[off]= true;
3227 num_flag[off]= false;
3228 }
3229 else
3230 {
3231 boolean_flag[off]= false;
3232 }
3201 }3233 }
3202 (void) tee_fputs("\n", PAGER);3234 (void) tee_fputs("\n", PAGER);
3203 tee_puts((char*) separator.c_str(), PAGER);3235 tee_puts((char*) separator.c_str(), PAGER);
@@ -3236,6 +3268,35 @@
3236 buffer= "NULL";3268 buffer= "NULL";
3237 data_length= 4;3269 data_length= 4;
3238 }3270 }
3271 else if (boolean_flag[off])
3272 {
3273 if (strncmp(cur[off],"1", 1) == 0)
3274 {
3275 if (ansi_boolean_flag[off])
3276 {
3277 buffer= "YES";
3278 data_length= 3;
3279 }
3280 else
3281 {
3282 buffer= "TRUE";
3283 data_length= 4;
3284 }
3285 }
3286 else
3287 {
3288 if (ansi_boolean_flag[off])
3289 {
3290 buffer= "NO";
3291 data_length= 2;
3292 }
3293 else
3294 {
3295 buffer= "FALSE";
3296 data_length= 5;
3297 }
3298 }
3299 }
3239 else3300 else
3240 {3301 {
3241 buffer= cur[off];3302 buffer= cur[off];
@@ -3509,16 +3570,41 @@
3509 drizzle_return_t ret;3570 drizzle_return_t ret;
3510 drizzle_column_st *field;3571 drizzle_column_st *field;
3511 size_t *lengths;3572 size_t *lengths;
35123573 std::vector<bool> boolean_flag;
3513 if (opt_silent < 2 && column_names)3574 std::vector<bool> ansi_boolean_flag;
3575
3576 boolean_flag.resize(drizzle_result_column_count(result));
3577 ansi_boolean_flag.resize(drizzle_result_column_count(result));
3578
3579 int first=0;
3580 for (uint32_t off= 0; (field = drizzle_column_next(result)); off++)
3514 {3581 {
3515 int first=0;3582 if (opt_silent < 2 && column_names)
3516 while ((field = drizzle_column_next(result)))
3517 {3583 {
3518 if (first++)3584 if (first++)
3519 (void) tee_fputs("\t", PAGER);3585 (void) tee_fputs("\t", PAGER);
3520 (void) tee_fputs(drizzle_column_name(field), PAGER);3586 (void) tee_fputs(drizzle_column_name(field), PAGER);
3521 }3587 }
3588 if ((server_type == ServerDetect::SERVER_DRIZZLE_FOUND) and
3589 (drizzle_column_type(field) == DRIZZLE_COLUMN_TYPE_TINY))
3590 {
3591 if ((drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_UNSIGNED))
3592 {
3593 ansi_boolean_flag[off]= true;
3594 }
3595 else
3596 {
3597 ansi_boolean_flag[off]= false;
3598 }
3599 boolean_flag[off]= true;
3600 }
3601 else
3602 {
3603 boolean_flag[off]= false;
3604 }
3605 }
3606 if (opt_silent < 2 && column_names)
3607 {
3522 (void) tee_fputs("\n", PAGER);3608 (void) tee_fputs("\n", PAGER);
3523 }3609 }
3524 while (1)3610 while (1)
@@ -3539,11 +3625,40 @@
3539 break;3625 break;
35403626
3541 lengths= drizzle_row_field_sizes(result);3627 lengths= drizzle_row_field_sizes(result);
3542 safe_put_field(cur[0],lengths[0]);3628 drizzle_column_seek(result, 0);
3543 for (uint32_t off=1 ; off < drizzle_result_column_count(result); off++)3629 for (uint32_t off=0 ; off < drizzle_result_column_count(result); off++)
3544 {3630 {
3545 (void) tee_fputs("\t", PAGER);3631 if (off != 0)
3546 safe_put_field(cur[off], lengths[off]);3632 (void) tee_fputs("\t", PAGER);
3633 if (boolean_flag[off])
3634 {
3635 if (strncmp(cur[off],"1", 1) == 0)
3636 {
3637 if (ansi_boolean_flag[off])
3638 {
3639 safe_put_field("YES", 3);
3640 }
3641 else
3642 {
3643 safe_put_field("TRUE", 4);
3644 }
3645 }
3646 else
3647 {
3648 if (ansi_boolean_flag[off])
3649 {
3650 safe_put_field("NO", 2);
3651 }
3652 else
3653 {
3654 safe_put_field("FALSE", 5);
3655 }
3656 }
3657 }
3658 else
3659 {
3660 safe_put_field(cur[off], lengths[off]);
3661 }
3547 }3662 }
3548 (void) tee_fputs("\n", PAGER);3663 (void) tee_fputs("\n", PAGER);
3549 if (quick)3664 if (quick)
@@ -4108,6 +4223,9 @@
4108 }4223 }
4109 connected=1;4224 connected=1;
41104225
4226 ServerDetect server_detect(&con);
4227 server_type= server_detect.getServerType();
4228
4111 build_completion_hash(opt_rehash, 1);4229 build_completion_hash(opt_rehash, 1);
4112 return 0;4230 return 0;
4113}4231}
41144232
=== modified file 'client/drizzledump.cc'
--- client/drizzledump.cc 2011-02-15 23:05:12 +0000
+++ client/drizzledump.cc 2011-02-22 00:33:14 +0000
@@ -241,9 +241,9 @@
241 cout << "-- Host: " << current_host << " Database: " << db_name << endl;241 cout << "-- Host: " << current_host << " Database: " << db_name << endl;
242 cout << "-- ------------------------------------------------------" << endl;242 cout << "-- ------------------------------------------------------" << endl;
243 cout << "-- Server version\t" << db_connection->getServerVersion();243 cout << "-- Server version\t" << db_connection->getServerVersion();
244 if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)244 if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
245 cout << " (MySQL server)";245 cout << " (MySQL server)";
246 else if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_DRIZZLE_FOUND)246 else if (db_connection->getServerType() == ServerDetect::SERVER_DRIZZLE_FOUND)
247 cout << " (Drizzle server)";247 cout << " (Drizzle server)";
248 cout << endl << endl;248 cout << endl << endl;
249 }249 }
@@ -351,7 +351,7 @@
351 std::cerr << _("-- Retrieving database structures...") << std::endl;351 std::cerr << _("-- Retrieving database structures...") << std::endl;
352352
353 /* Blocking the MySQL privilege tables too because we can't import them due to bug#646187 */353 /* Blocking the MySQL privilege tables too because we can't import them due to bug#646187 */
354 if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)354 if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
355 query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'performance_schema', 'mysql')";355 query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'performance_schema', 'mysql')";
356 else356 else
357 query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM DATA_DICTIONARY.SCHEMAS WHERE SCHEMA_NAME NOT IN ('information_schema','data_dictionary')";357 query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM DATA_DICTIONARY.SCHEMAS WHERE SCHEMA_NAME NOT IN ('information_schema','data_dictionary')";
@@ -360,7 +360,7 @@
360 while ((row= drizzle_row_next(tableres)))360 while ((row= drizzle_row_next(tableres)))
361 {361 {
362 std::string database_name(row[0]);362 std::string database_name(row[0]);
363 if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)363 if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
364 database= new DrizzleDumpDatabaseMySQL(database_name, db_connection);364 database= new DrizzleDumpDatabaseMySQL(database_name, db_connection);
365 else365 else
366 database= new DrizzleDumpDatabaseDrizzle(database_name, db_connection);366 database= new DrizzleDumpDatabaseDrizzle(database_name, db_connection);
@@ -383,7 +383,7 @@
383 for (vector<string>::const_iterator it= db_names.begin(); it != db_names.end(); ++it)383 for (vector<string>::const_iterator it= db_names.begin(); it != db_names.end(); ++it)
384 {384 {
385 temp= *it;385 temp= *it;
386 if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)386 if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
387 database= new DrizzleDumpDatabaseMySQL(temp, db_connection);387 database= new DrizzleDumpDatabaseMySQL(temp, db_connection);
388 else388 else
389 database= new DrizzleDumpDatabaseDrizzle(temp, db_connection);389 database= new DrizzleDumpDatabaseDrizzle(temp, db_connection);
@@ -396,7 +396,7 @@
396{396{
397 DrizzleDumpDatabase *database;397 DrizzleDumpDatabase *database;
398398
399 if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)399 if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
400 database= new DrizzleDumpDatabaseMySQL(db, db_connection);400 database= new DrizzleDumpDatabaseMySQL(db, db_connection);
401 else401 else
402 database= new DrizzleDumpDatabaseDrizzle(db, db_connection);402 database= new DrizzleDumpDatabaseDrizzle(db, db_connection);
@@ -742,7 +742,7 @@
742 maybe_exit(EX_DRIZZLEERR);742 maybe_exit(EX_DRIZZLEERR);
743 }743 }
744744
745 if ((db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled))745 if ((db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled))
746 db_connection->queryNoResult("SET NAMES 'utf8'");746 db_connection->queryNoResult("SET NAMES 'utf8'");
747747
748 if (vm.count("destination-type"))748 if (vm.count("destination-type"))
749749
=== modified file 'client/drizzledump_data.cc'
--- client/drizzledump_data.cc 2010-12-08 07:35:23 +0000
+++ client/drizzledump_data.cc 2011-02-22 00:33:14 +0000
@@ -373,6 +373,13 @@
373 {373 {
374 os << "NULL";374 os << "NULL";
375 }375 }
376 else if (obj.table->fields[i]->type.compare("BOOLEAN") == 0)
377 {
378 if (strncmp(row[i], "1", 1) == 0)
379 os << "TRUE";
380 else
381 os << "FALSE";
382 }
376 else383 else
377 os << "'" << DrizzleDumpData::escape(row[i], row_sizes[i]) << "'";384 os << "'" << DrizzleDumpData::escape(row[i], row_sizes[i]) << "'";
378 byte_counter+= 3;385 byte_counter+= 3;
@@ -561,19 +568,10 @@
561 throw std::exception();568 throw std::exception();
562 }569 }
563570
564 boost::match_flag_type flags = boost::match_default; 571 ServerDetect server_detect= ServerDetect(&connection);
565572
566 boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)");573 serverType= server_detect.getServerType();
567 boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");574 serverVersion= server_detect.getServerVersion();
568
569 std::string version(getServerVersion());
570
571 if (regex_search(version, mysql_regex, flags))
572 serverType= SERVER_MYSQL_FOUND;
573 else if (regex_search(version, drizzle_regex, flags))
574 serverType= SERVER_DRIZZLE_FOUND;
575 else
576 serverType= SERVER_UNKNOWN_FOUND;
577}575}
578576
579drizzle_result_st* DrizzleDumpConnection::query(std::string &str_query)577drizzle_result_st* DrizzleDumpConnection::query(std::string &str_query)
580578
=== modified file 'client/drizzledump_data.h'
--- client/drizzledump_data.h 2010-12-08 07:35:23 +0000
+++ client/drizzledump_data.h 2011-02-22 00:33:14 +0000
@@ -22,6 +22,7 @@
2222
23#define DRIZZLE_MAX_LINE_LENGTH 1024*1024L-102523#define DRIZZLE_MAX_LINE_LENGTH 1024*1024L-1025
24#include "client_priv.h"24#include "client_priv.h"
25#include "server_detect.h"
25#include <string>26#include <string>
26#include <iostream>27#include <iostream>
27#include <iomanip>28#include <iomanip>
@@ -214,14 +215,10 @@
214 drizzle_con_st connection;215 drizzle_con_st connection;
215 std::string hostName;216 std::string hostName;
216 bool drizzleProtocol;217 bool drizzleProtocol;
217 int serverType;218 ServerDetect::server_type serverType;
219 std::string serverVersion;
218220
219 public:221 public:
220 enum server_type {
221 SERVER_MYSQL_FOUND,
222 SERVER_DRIZZLE_FOUND,
223 SERVER_UNKNOWN_FOUND
224 };
225 DrizzleDumpConnection(std::string &host, uint16_t port,222 DrizzleDumpConnection(std::string &host, uint16_t port,
226 std::string &username, std::string &password, bool drizzle_protocol);223 std::string &username, std::string &password, bool drizzle_protocol);
227 ~DrizzleDumpConnection();224 ~DrizzleDumpConnection();
@@ -244,7 +241,7 @@
244 bool setDB(std::string databaseName);241 bool setDB(std::string databaseName);
245 bool usingDrizzleProtocol(void) const { return drizzleProtocol; }242 bool usingDrizzleProtocol(void) const { return drizzleProtocol; }
246 bool getServerType(void) const { return serverType; }243 bool getServerType(void) const { return serverType; }
247 const char* getServerVersion(void) { return drizzle_con_server_version(&connection); }244 std::string getServerVersion(void) const { return serverVersion; }
248};245};
249246
250class DrizzleStringBuf : public std::streambuf247class DrizzleStringBuf : public std::streambuf
251248
=== modified file 'client/drizzledump_drizzle.cc'
--- client/drizzledump_drizzle.cc 2010-12-06 12:15:06 +0000
+++ client/drizzledump_drizzle.cc 2011-02-22 00:33:14 +0000
@@ -195,9 +195,9 @@
195 else195 else
196 field->defaultValue= "";196 field->defaultValue= "";
197197
198 field->isNull= (strcmp(row[4], "YES") == 0) ? true : false;198 field->isNull= (boost::lexical_cast<uint32_t>(row[4])) ? true : false;
199 field->isAutoIncrement= (strcmp(row[9], "YES") == 0) ? true : false;199 field->isAutoIncrement= (boost::lexical_cast<uint32_t>(row[9])) ? true : false;
200 field->defaultIsNull= (strcmp(row[3], "YES") == 0) ? true : false;200 field->defaultIsNull= (boost::lexical_cast<uint32_t>(row[3])) ? true : false;
201 field->enumValues= (row[10]) ? row[10] : "";201 field->enumValues= (row[10]) ? row[10] : "";
202 field->length= (row[5]) ? boost::lexical_cast<uint32_t>(row[5]) : 0;202 field->length= (row[5]) ? boost::lexical_cast<uint32_t>(row[5]) : 0;
203 field->decimalPrecision= (row[6]) ? boost::lexical_cast<uint32_t>(row[6]) : 0;203 field->decimalPrecision= (row[6]) ? boost::lexical_cast<uint32_t>(row[6]) : 0;
@@ -244,7 +244,7 @@
244 indexes.push_back(index);244 indexes.push_back(index);
245 index = new DrizzleDumpIndexDrizzle(indexName, dcon);245 index = new DrizzleDumpIndexDrizzle(indexName, dcon);
246 index->isPrimary= (strcmp(row[0], "PRIMARY") == 0);246 index->isPrimary= (strcmp(row[0], "PRIMARY") == 0);
247 index->isUnique= (strcmp(row[3], "YES") == 0);247 index->isUnique= boost::lexical_cast<uint32_t>(row[3]);
248 index->isHash= 0;248 index->isHash= 0;
249 index->length= (row[4]) ? boost::lexical_cast<uint32_t>(row[4]) : 0;249 index->length= (row[4]) ? boost::lexical_cast<uint32_t>(row[4]) : 0;
250 lastKey= row[0];250 lastKey= row[0];
251251
=== modified file 'client/drizzletest.cc'
--- client/drizzletest.cc 2011-02-17 00:14:13 +0000
+++ client/drizzletest.cc 2011-02-22 00:33:14 +0000
@@ -4697,8 +4697,36 @@
4697 for (i = 0; i < num_fields; i++)4697 for (i = 0; i < num_fields; i++)
4698 {4698 {
4699 column= drizzle_column_next(res);4699 column= drizzle_column_next(res);
4700 append_field(ds, i, column,4700 if (row[i] && (drizzle_column_type(column) == DRIZZLE_COLUMN_TYPE_TINY))
4701 (const char*)row[i], lengths[i], !row[i]);4701 {
4702 if (boost::lexical_cast<uint32_t>(row[i]))
4703 {
4704 if ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_UNSIGNED))
4705 {
4706 append_field(ds, i, column, "YES", 3, false);
4707 }
4708 else
4709 {
4710 append_field(ds, i, column, "TRUE", 4, false);
4711 }
4712 }
4713 else
4714 {
4715 if ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_UNSIGNED))
4716 {
4717 append_field(ds, i, column, "NO", 2, false);
4718 }
4719 else
4720 {
4721 append_field(ds, i, column, "FALSE", 5, false);
4722 }
4723 }
4724 }
4725 else
4726 {
4727 append_field(ds, i, column,
4728 (const char*)row[i], lengths[i], !row[i]);
4729 }
4702 }4730 }
4703 if (!display_result_vertically)4731 if (!display_result_vertically)
4704 ds->append("\n");4732 ds->append("\n");
@@ -4742,7 +4770,14 @@
4742 ds->append("\t", 1);4770 ds->append("\t", 1);
4743 replace_append_uint(ds, drizzle_column_size(column));4771 replace_append_uint(ds, drizzle_column_size(column));
4744 ds->append("\t", 1);4772 ds->append("\t", 1);
4745 replace_append_uint(ds, drizzle_column_max_size(column));4773 if (drizzle_column_type(column) == DRIZZLE_COLUMN_TYPE_TINY)
4774 {
4775 replace_append_uint(ds, 1);
4776 }
4777 else
4778 {
4779 replace_append_uint(ds, drizzle_column_max_size(column));
4780 }
4746 ds->append("\t", 1);4781 ds->append("\t", 1);
4747 ds->append((char*) ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_NOT_NULL) ? "N" : "Y"), 1);4782 ds->append((char*) ((drizzle_column_flags(column) & DRIZZLE_COLUMN_FLAGS_NOT_NULL) ? "N" : "Y"), 1);
4748 ds->append("\t", 1);4783 ds->append("\t", 1);
47494784
=== modified file 'client/include.am'
--- client/include.am 2010-12-28 20:54:15 +0000
+++ client/include.am 2011-02-22 00:33:14 +0000
@@ -54,6 +54,7 @@
54 client/drizzledump_drizzle.h \54 client/drizzledump_drizzle.h \
55 client/drizzledump_mysql.h \55 client/drizzledump_mysql.h \
56 client/option_string.h \56 client/option_string.h \
57 client/server_detect.h \
57 client/statement.h \58 client/statement.h \
58 client/stats.h \59 client/stats.h \
59 client/thread_context.h \60 client/thread_context.h \
6061
=== added file 'client/server_detect.h'
--- client/server_detect.h 1970-01-01 00:00:00 +0000
+++ client/server_detect.h 2011-02-22 00:33:14 +0000
@@ -0,0 +1,61 @@
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2011 Andrew Hutchings
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef CLIENT_SERVER_DETECT_H
21#define CLIENT_SERVER_DETECT_H
22
23#include <boost/regex.hpp>
24
25class ServerDetect
26{
27 public:
28 enum server_type {
29 SERVER_MYSQL_FOUND,
30 SERVER_DRIZZLE_FOUND,
31 SERVER_UNKNOWN_FOUND
32 };
33
34 server_type getServerType() { return type; }
35 std::string& getServerVersion() { return version; }
36
37 ServerDetect(drizzle_con_st *connection) :
38 type(SERVER_UNKNOWN_FOUND),
39 version("")
40 {
41 boost::match_flag_type flags = boost::match_default;
42
43 boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)");
44 boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
45
46 version= drizzle_con_server_version(connection);
47
48 if (regex_search(version, mysql_regex, flags))
49 type= SERVER_MYSQL_FOUND;
50 else if (regex_search(version, drizzle_regex, flags))
51 type= SERVER_DRIZZLE_FOUND;
52 else
53 type= SERVER_UNKNOWN_FOUND;
54 }
55
56 private:
57 server_type type;
58 std::string version;
59};
60
61#endif /* CLIENT_SERVER_DETECT_H */
062
=== modified file 'drizzled/field/boolean.cc'
--- drizzled/field/boolean.cc 2011-02-19 01:04:19 +0000
+++ drizzled/field/boolean.cc 2011-02-22 00:33:14 +0000
@@ -60,6 +60,8 @@
60 field_name_arg),60 field_name_arg),
61 ansi_display(ansi_display_arg)61 ansi_display(ansi_display_arg)
62 {62 {
63 if (ansi_display)
64 flags|= UNSIGNED_FLAG;
63 }65 }
6466
65int Boolean::cmp(const unsigned char *a, const unsigned char *b)67int Boolean::cmp(const unsigned char *a, const unsigned char *b)
6668
=== modified file 'libdrizzle/column.c'
--- libdrizzle/column.c 2010-12-23 18:47:57 +0000
+++ libdrizzle/column.c 2011-02-22 00:33:14 +0000
@@ -65,7 +65,7 @@
65static drizzle_column_type_drizzle_t _column_type_drizzle_map_from[]=65static drizzle_column_type_drizzle_t _column_type_drizzle_map_from[]=
66{66{
67 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 0 */67 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 0 */
68 DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY,68 DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN,
69 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX,69 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX,
70 DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG,70 DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG,
71 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX,71 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX,
7272
=== modified file 'libdrizzle/constants.h'
--- libdrizzle/constants.h 2010-12-19 16:20:13 +0000
+++ libdrizzle/constants.h 2011-02-22 00:33:14 +0000
@@ -391,7 +391,11 @@
391 DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL,391 DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL,
392 DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM,392 DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM,
393 DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB,393 DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB,
394 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB394 DRIZZLE_COLUMN_TYPE_DRIZZLE_TIME,
395 DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN,
396 DRIZZLE_COLUMN_TYPE_DRIZZLE_UUID,
397 DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME,
398 DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX=DRIZZLE_COLUMN_TYPE_DRIZZLE_MICROTIME
395} drizzle_column_type_drizzle_t;399} drizzle_column_type_drizzle_t;
396400
397/**401/**
398402
=== modified file 'plugin/mysql_protocol/mysql_protocol.cc'
--- plugin/mysql_protocol/mysql_protocol.cc 2011-02-20 00:09:56 +0000
+++ plugin/mysql_protocol/mysql_protocol.cc 2011-02-22 00:33:14 +0000
@@ -35,6 +35,8 @@
3535
36#include <drizzled/identifier.h>36#include <drizzled/identifier.h>
3737
38#include <libdrizzle/constants.h>
39
38#define PROTOCOL_VERSION 1040#define PROTOCOL_VERSION 10
3941
40namespace po= boost::program_options;42namespace po= boost::program_options;
@@ -558,7 +560,7 @@
558 break;560 break;
559561
560 case DRIZZLE_TYPE_BOOLEAN:562 case DRIZZLE_TYPE_BOOLEAN:
561 pos[6]= 15;563 pos[6]= DRIZZLE_COLUMN_TYPE_TINY;
562 break;564 break;
563565
564 case DRIZZLE_TYPE_DECIMAL:566 case DRIZZLE_TYPE_DECIMAL:
@@ -609,6 +611,11 @@
609{611{
610 if (from->is_null())612 if (from->is_null())
611 return store();613 return store();
614 if (from->type() == DRIZZLE_TYPE_BOOLEAN)
615 {
616 return store(from->val_int());
617 }
618
612 char buff[MAX_FIELD_WIDTH];619 char buff[MAX_FIELD_WIDTH];
613 String str(buff,sizeof(buff), &my_charset_bin);620 String str(buff,sizeof(buff), &my_charset_bin);
614621
615622
=== modified file 'po/Makefile.in.in'
--- po/Makefile.in.in 2011-02-14 20:32:29 +0000
+++ po/Makefile.in.in 2011-02-22 00:33:14 +0000
@@ -145,7 +145,7 @@
145check: all $(GETTEXT_PACKAGE).pot145check: all $(GETTEXT_PACKAGE).pot
146 rm -f missing notexist146 rm -f missing notexist
147 srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m147 srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m
148 if [ -r missing -o -r notexist -a "x${INTLTOOL_WARNINGS}" = "xyes"]; then \148 if [ -r missing -o -r notexist -a "x${INTLTOOL_WARNINGS}" = "xyes" ]; then \
149 exit 1; \149 exit 1; \
150 fi150 fi
151151
152152
=== modified file 'tests/r/show_check.result'
--- tests/r/show_check.result 2011-02-04 09:04:08 +0000
+++ tests/r/show_check.result 2011-02-22 00:33:14 +0000
@@ -27,7 +27,7 @@
27show index from t1;27show index from t1;
28Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr28Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
29def data_dictionary show_indexes SHOW_INDEXES Table Table 8 1024 2 N 4097 0 4529def data_dictionary show_indexes SHOW_INDEXES Table Table 8 1024 2 N 4097 0 45
30def data_dictionary show_indexes SHOW_INDEXES Unique Unique 8 1 3 N 4097 0 6330def data_dictionary show_indexes SHOW_INDEXES Unique Unique 13 1 1 N 36897 0 63
31def data_dictionary show_indexes SHOW_INDEXES Key_name Key_name 8 1024 7 N 4097 0 4531def data_dictionary show_indexes SHOW_INDEXES Key_name Key_name 8 1024 7 N 4097 0 45
32def data_dictionary show_indexes SHOW_INDEXES Seq_in_index Seq_in_index 5 21 1 N 36865 0 6332def data_dictionary show_indexes SHOW_INDEXES Seq_in_index Seq_in_index 5 21 1 N 36865 0 63
33def data_dictionary show_indexes SHOW_INDEXES Column_name Column_name 8 1024 1 N 4097 0 4533def data_dictionary show_indexes SHOW_INDEXES Column_name Column_name 8 1024 1 N 4097 0 45
@@ -447,7 +447,7 @@
447show index from t1;447show index from t1;
448Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr448Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
449def data_dictionary show_indexes SHOW_INDEXES Table Table 8 1024 2 N 4097 0 45449def data_dictionary show_indexes SHOW_INDEXES Table Table 8 1024 2 N 4097 0 45
450def data_dictionary show_indexes SHOW_INDEXES Unique Unique 8 1 3 N 4097 0 63450def data_dictionary show_indexes SHOW_INDEXES Unique Unique 13 1 1 N 36897 0 63
451def data_dictionary show_indexes SHOW_INDEXES Key_name Key_name 8 1024 7 N 4097 0 45451def data_dictionary show_indexes SHOW_INDEXES Key_name Key_name 8 1024 7 N 4097 0 45
452def data_dictionary show_indexes SHOW_INDEXES Seq_in_index Seq_in_index 5 21 1 N 36865 0 63452def data_dictionary show_indexes SHOW_INDEXES Seq_in_index Seq_in_index 5 21 1 N 36865 0 63
453def data_dictionary show_indexes SHOW_INDEXES Column_name Column_name 8 1024 6 N 4097 0 45453def data_dictionary show_indexes SHOW_INDEXES Column_name Column_name 8 1024 6 N 4097 0 45

Subscribers

People subscribed via source and target branches