Commit 160541b5 authored by ingo@mysql.com's avatar ingo@mysql.com

Merge mysql.com:/home/mydev/mysql-5.0

into mysql.com:/home/mydev/mysql-5.0-5000
parents 00807cb0 670a2934
......@@ -172,6 +172,7 @@ nick@nick.leippe.com
papa@gbichot.local
patg@krsna.patg.net
patg@patrick-galbraiths-computer.local
patg@pc248.lfp.kcls.org
paul@central.snake.net
paul@frost.snake.net
paul@ice.local
......
-- require r/have_federated_db.require
disable_query_log;
show variables like "have_federated_db";
show variables like "have_federated_engine";
enable_query_log;
......@@ -130,9 +130,9 @@ delete from federated.t1;
select * from federated.t1 where id = 5;
id name other created
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) );
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', 11111);
insert into federated.t1 (name, other) values ('Second Name', NULL);
insert into federated.t1 (name, other) values ('Third Name', 33333);
......@@ -162,7 +162,7 @@ id name other
7 Seventh Name NULL
10 NULL fee fie foe fum
update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL;
update federated.t1 set other = 'two two two two' where name = 'Secend Name';
update federated.t1 set other = 'two two two two' where name = 'Second Name';
update federated.t1 set other = 'seven seven' where name like 'Sec%';
update federated.t1 set other = 'seven seven' where name = 'Seventh Name';
update federated.t1 set name = 'Tenth Name' where other like 'fee fie%';
......@@ -181,6 +181,85 @@ id name other
9 Ninth Name 99999
10 Tenth Name fee fie foe fum
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name`
varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) );
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', '1111');
insert into federated.t1 (name, other) values ('Second Name', '2222');
insert into federated.t1 (name, other) values ('Third Name', '3333');
select * from federated.t1 where name = 'Second Name';
id name other
2 Second Name 2222
select * from federated.t1 where other = '2222';
id name other
2 Second Name 2222
select * from federated.t1 where name = 'Third Name';
id name other
3 Third Name 3333
select * from federated.t1 where name = 'Third Name' and other = '3333';
id name other
3 Third Name 3333
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name, other),
key bincol(bincol),
key floatval(floatval));
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name,other),
key bincol(bincol),
key floatval(floatval))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111);
insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222);
insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222);
select * from federated.t1;
id name bincol floatval other
1 first e 11.11 1111
2 second f 22.22 2222
3 third g 22.22 2222
select * from federated.t1 where name = 'second';
id name bincol floatval other
2 second f 22.22 2222
select * from federated.t1 where bincol= 'f';
id name bincol floatval other
2 second f 22.22 2222
select * from federated.t1 where bincol= 0x66;
id name bincol floatval other
2 second f 22.22 2222
select * from federated.t1 where bincol= 0x67;
id name bincol floatval other
3 third g 22.22 2222
select * from federated.t1 where bincol= 'g';
id name bincol floatval other
3 third g 22.22 2222
select * from federated.t1 where floatval=11.11;
id name bincol floatval other
1 first e 11.11 1111
select * from federated.t1 where name='third';
id name bincol floatval other
3 third g 22.22 2222
select * from federated.t1 where other=2222;
id name bincol floatval other
2 second f 22.22 2222
3 third g 22.22 2222
select * from federated.t1 where name='third' and other=2222;
id name bincol floatval other
3 third g 22.22 2222
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
......@@ -550,16 +629,46 @@ delete from federated.t1 where i50=20;
select * from federated.t1;
i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30 i31 i32 i33 i34 i35 i36 i37 i38 i39 i40 i41 i42 i43 i44 i45 i46 i47 i48 i49 i50 i51 i52 i53 i54 i55 i56 i57 i58 i59 i60 i61 i62 i63 i64 i65 i66 i67 i68 i69 i70 i71 i72 i73 i74 i75 i76 i77 i78 i79 i80 i81 i82 i83 i84 i85 i86 i87 i88 i89 i90 i91 i92 i93 i94 i95 i96 i97 i98 i99 i100 i101 i102 i103 i104 i105 i106 i107 i108 i109 i110 i111 i112 i113 i114 i115 i116 i117 i118 i119 i120 i121 i122 i123 i124 i125 i126 i127 i128 i129 i130 i131 i132 i133 i134 i135 i136 i137 i138 i139 i140 i141 i142 i143 i144 i145 i146 i147 i148 i149 i150 i151 i152 i153 i154 i155 i156 i157 i158 i159 i160 i161 i162 i163 i164 i165 i166 i167 i168 i169 i170 i171 i172 i173 i174 i175 i176 i177 i178 i179 i180 i181 i182 i183 i184 i185 i186 i187 i188 i189 i190 i191 i192 i193 i194 i195 i196 i197 i198 i199 i200 i201 i202 i203 i204 i205 i206 i207 i208 i209 i210 i211 i212 i213 i214 i215 i216 i217 i218 i219 i220 i221 i222 i223 i224 i225 i226 i227 i228 i229 i230 i231 i232 i233 i234 i235 i236 i237 i238 i239 i240 i241 i242 i243 i244 i245 i246 i247 i248 i249 i250 i251 i252 i253 i254 i255 i256 i257 i258 i259 i260 i261 i262 i263 i264 i265 i266 i267 i268 i269 i270 i271 i272 i273 i274 i275 i276 i277 i278 i279 i280 i281 i282 i283 i284 i285 i286 i287 i288 i289 i290 i291 i292 i293 i294 i295 i296 i297 i298 i299 i300 i301 i302 i303 i304 i305 i306 i307 i308 i309 i310 i311 i312 i313 i314 i315 i316 i317 i318 i319 i320 i321 i322 i323 i324 i325 i326 i327 i328 i329 i330 i331 i332 i333 i334 i335 i336 i337 i338 i339 i340 i341 i342 i343 i344 i345 i346 i347 i348 i349 i350 i351 i352 i353 i354 i355 i356 i357 i358 i359 i360 i361 i362 i363 i364 i365 i366 i367 i368 i369 i370 i371 i372 i373 i374 i375 i376 i377 i378 i379 i380 i381 i382 i383 i384 i385 i386 i387 i388 i389 i390 i391 i392 i393 i394 i395 i396 i397 i398 i399 i400 i401 i402 i403 i404 i405 i406 i407 i408 i409 i410 i411 i412 i413 i414 i415 i416 i417 i418 i419 i420 i421 i422 i423 i424 i425 i426 i427 i428 i429 i430 i431 i432 i433 i434 i435 i436 i437 i438 i439 i440 i441 i442 i443 i444 i445 i446 i447 i448 i449 i450 i451 i452 i453 i454 i455 i456 i457 i458 i459 i460 i461 i462 i463 i464 i465 i466 i467 i468 i469 i470 i471 i472 i473 i474 i475 i476 i477 i478 i479 i480 i481 i482 i483 i484 i485 i486 i487 i488 i489 i490 i491 i492 i493 i494 i495 i496 i497 i498 i499 i500 i501 i502 i503 i504 i505 i506 i507 i508 i509 i510 i511 i512 i513 i514 i515 i516 i517 i518 i519 i520 i521 i522 i523 i524 i525 i526 i527 i528 i529 i530 i531 i532 i533 i534 i535 i536 i537 i538 i539 i540 i541 i542 i543 i544 i545 i546 i547 i548 i549 i550 i551 i552 i553 i554 i555 i556 i557 i558 i559 i560 i561 i562 i563 i564 i565 i566 i567 i568 i569 i570 i571 i572 i573 i574 i575 i576 i577 i578 i579 i580 i581 i582 i583 i584 i585 i586 i587 i588 i589 i590 i591 i592 i593 i594 i595 i596 i597 i598 i599 i600 i601 i602 i603 i604 i605 i606 i607 i608 i609 i610 i611 i612 i613 i614 i615 i616 i617 i618 i619 i620 i621 i622 i623 i624 i625 i626 i627 i628 i629 i630 i631 i632 i633 i634 i635 i636 i637 i638 i639 i640 i641 i642 i643 i644 i645 i646 i647 i648 i649 i650 i651 i652 i653 i654 i655 i656 i657 i658 i659 i660 i661 i662 i663 i664 i665 i666 i667 i668 i669 i670 i671 i672 i673 i674 i675 i676 i677 i678 i679 i680 i681 i682 i683 i684 i685 i686 i687 i688 i689 i690 i691 i692 i693 i694 i695 i696 i697 i698 i699 i700 i701 i702 i703 i704 i705 i706 i707 i708 i709 i710 i711 i712 i713 i714 i715 i716 i717 i718 i719 i720 i721 i722 i723 i724 i725 i726 i727 i728 i729 i730 i731 i732 i733 i734 i735 i736 i737 i738 i739 i740 i741 i742 i743 i744 i745 i746 i747 i748 i749 i750 i751 i752 i753 i754 i755 i756 i757 i758 i759 i760 i761 i762 i763 i764 i765 i766 i767 i768 i769 i770 i771 i772 i773 i774 i775 i776 i777 i778 i779 i780 i781 i782 i783 i784 i785 i786 i787 i788 i789 i790 i791 i792 i793 i794 i795 i796 i797 i798 i799 i800 i801 i802 i803 i804 i805 i806 i807 i808 i809 i810 i811 i812 i813 i814 i815 i816 i817 i818 i819 i820 i821 i822 i823 i824 i825 i826 i827 i828 i829 i830 i831 i832 i833 i834 i835 i836 i837 i838 i839 i840 i841 i842 i843 i844 i845 i846 i847 i848 i849 i850 i851 i852 i853 i854 i855 i856 i857 i858 i859 i860 i861 i862 i863 i864 i865 i866 i867 i868 i869 i870 i871 i872 i873 i874 i875 i876 i877 i878 i879 i880 i881 i882 i883 i884 i885 i886 i887 i888 i889 i890 i891 i892 i893 i894 i895 i896 i897 i898 i899 i900 i901 i902 i903 i904 i905 i906 i907 i908 i909 i910 i911 i912 i913 i914 i915 i916 i917 i918 i919 i920 i921 i922 i923 i924 i925 i926 i927 i928 i929 i930 i931 i932 i933 i934 i935 i936 i937 i938 i939 i940 i941 i942 i943 i944 i945 i946 i947 i948 i949 i950 i951 i952 i953 i954 i955 i956 i957 i958 i959 i960 i961 i962 i963 i964 i965 i966 i967 i968 i969 i970 i971 i972 i973 i974 i975 i976 i977 i978 i979 i980 i981 i982 i983 i984 i985 i986 i987 i988 i989 i990 i991 i992 i993 i994 i995 i996 i997 i998 i999 i1000 b
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2003-03-03 03:03:03');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2004-04-04 04:04:04');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04');
select * from federated.t1;
id code fileguts creation_date entered_time
1 ASDFWERQWETWETAWETA *()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[ 2003-03-03 03:03:03 2004-04-04 04:04:04
2 DEUEUEUEUEUEUEUEUEU *()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[ 2004-04-04 04:04:04 2004-04-04 04:04:04
3 DEUEUEUEUEUEUEUEUEU jimbob 2004-04-04 04:04:04 2004-04-04 04:04:04
select * from federated.t1 where fileguts = 'jimbob';
id code fileguts creation_date entered_time
3 DEUEUEUEUEUEUEUEUEU jimbob 2004-04-04 04:04:04 2004-04-04 04:04:04
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id));
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111);
insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222);
insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333);
insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333);
insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333);
drop table if exists federated.countries;
Warnings:
Note 1051 Unknown table 'countries'
CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id));
insert into federated.countries (country) values ('India');
insert into federated.countries (country) values ('Germany');
insert into federated.countries (country) values ('Italy');
insert into federated.countries (country) values ('Finland');
insert into federated.countries (country) values ('Ukraine');
select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id;
id country_id name other country
1 1 Kumar 11111 India
2 2 Lenz 22222 Germany
3 3 Marizio 33333 Italy
4 4 Monty 33333 Finland
5 5 Sanja 33333 Ukraine
drop table federated.countries;
drop table if exists federated.t1;
drop database if exists federated;
drop table if exists federated.t1;
......
Variable_name Value
have_federated_db YES
have_federated_engine YES
......@@ -68,12 +68,14 @@ select * from federated.t1 where id = 5;
delete from federated.t1;
select * from federated.t1 where id = 5;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) );
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', 11111);
insert into federated.t1 (name, other) values ('Second Name', NULL);
insert into federated.t1 (name, other) values ('Third Name', 33333);
......@@ -90,19 +92,78 @@ select * from federated.t1 where name IS NULL;
select * from federated.t1 where name IS NULL and other IS NULL;
select * from federated.t1 where name IS NULL or other IS NULL;
update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL;
update federated.t1 set other = 'two two two two' where name = 'Secend Name';
update federated.t1 set other = 'two two two two' where name = 'Second Name';
update federated.t1 set other = 'seven seven' where name like 'Sec%';
update federated.t1 set other = 'seven seven' where name = 'Seventh Name';
update federated.t1 set name = 'Tenth Name' where other like 'fee fie%';
select * from federated.t1 where name IS NULL or other IS NULL ;
select * from federated.t1;
# test multi-keys
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name`
varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) );
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', '1111');
insert into federated.t1 (name, other) values ('Second Name', '2222');
insert into federated.t1 (name, other) values ('Third Name', '3333');
select * from federated.t1 where name = 'Second Name';
select * from federated.t1 where other = '2222';
select * from federated.t1 where name = 'Third Name';
select * from federated.t1 where name = 'Third Name' and other = '3333';
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name, other),
key bincol(bincol),
key floatval(floatval));
# test other types of indexes
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name,other),
key bincol(bincol),
key floatval(floatval))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111);
insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222);
insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222);
select * from federated.t1;
select * from federated.t1 where name = 'second';
select * from federated.t1 where bincol= 'f';
select * from federated.t1 where bincol= 0x66;
select * from federated.t1 where bincol= 0x67;
select * from federated.t1 where bincol= 'g';
select * from federated.t1 where floatval=11.11;
select * from federated.t1 where name='third';
select * from federated.t1 where other=2222;
select * from federated.t1 where name='third' and other=2222;
# test NULLs
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
# these both should be the same
......@@ -452,15 +513,17 @@ select * from federated.t1;
connection slave;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2003-03-03 03:03:03');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2004-04-04 04:04:04');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04');
select * from federated.t1;
drop table if exists federated.t1;
select * from federated.t1 where fileguts = 'jimbob';
# test blob indexes
# TODO
#
......@@ -490,11 +553,36 @@ drop table if exists federated.t1;
# drop table if exists federated.t1;
#
# test joins with non-federated table
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id));
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111);
insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222);
insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333);
insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333);
insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333);
drop table if exists federated.countries;
CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id));
insert into federated.countries (country) values ('India');
insert into federated.countries (country) values ('Germany');
insert into federated.countries (country) values ('Italy');
insert into federated.countries (country) values ('Finland');
insert into federated.countries (country) values ('Ukraine');
select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id;
drop table federated.countries;
connection master;
--disable_warnings
drop table if exists federated.t1;
drop database if exists federated;
--enable_warnings
......
......@@ -524,6 +524,115 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table,
return tmp;
}
/*
SYNOPSIS
Field::quote_data()
unquoted_string Pointer pointing to the value of a field
DESCRIPTION
Simple method that passes the field type to the method "type_quote"
To get a true/false value as to whether the value in string1 needs
to be enclosed with quotes. This ensures that values in the final
sql statement to be passed to the remote server will be quoted properly
RETURN_VALUE
void Immediately - if string doesn't need quote
void Upon prepending/appending quotes on each side of variable
*/
bool Field::quote_data(String *unquoted_string)
{
char escaped_string[IO_SIZE];
char *unquoted_string_buffer= (char *)(unquoted_string->ptr());
uint need_quotes;
DBUG_ENTER("Field::quote_data");
// this is the same call that mysql_real_escape_string() calls
escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
unquoted_string->ptr(), unquoted_string->length());
if (is_null())
DBUG_RETURN(0);
need_quotes= needs_quotes();
if (need_quotes == 0)
{
DBUG_RETURN(0);
}
else
{
// reset string, then re-append with quotes and escaped values
unquoted_string->length(0);
if (unquoted_string->append("'"))
DBUG_RETURN(1);
if (unquoted_string->append((char *)escaped_string))
DBUG_RETURN(1);
if (unquoted_string->append("'"))
DBUG_RETURN(1);
}
//DBUG_PRINT("Field::quote_data",
// ("FINAL quote_flag %d unquoted_string %s escaped_string %s",
//needs_quotes, unquoted_string->c_ptr_quick(), escaped_string));
DBUG_RETURN(0);
}
/*
Quote a field type if needed
SYNOPSIS
Field::type_quote
DESCRIPTION
Simple method to give true/false whether a field should be quoted.
Used when constructing INSERT and UPDATE queries to the remote server
see write_row and update_row
RETURN VALUE
0 if value is of type NOT needing quotes
1 if value is of type needing quotes
*/
bool Field::needs_quotes(void)
{
DBUG_ENTER("Field::type_quote");
switch(type()) {
//FIX this when kernel is fixed
case MYSQL_TYPE_VARCHAR :
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
case FIELD_TYPE_YEAR :
case FIELD_TYPE_NEWDATE :
case FIELD_TYPE_TIME :
case FIELD_TYPE_TIMESTAMP :
case FIELD_TYPE_DATE :
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
case FIELD_TYPE_GEOMETRY :
DBUG_RETURN(1);
case FIELD_TYPE_DECIMAL :
case FIELD_TYPE_TINY :
case FIELD_TYPE_SHORT :
case FIELD_TYPE_INT24 :
case FIELD_TYPE_LONG :
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
case FIELD_TYPE_LONGLONG :
case FIELD_TYPE_NULL :
case FIELD_TYPE_SET :
case FIELD_TYPE_ENUM :
DBUG_RETURN(0);
default: DBUG_RETURN(0);
}
DBUG_RETURN(0);
}
/****************************************************************************
Field_null, a field that always return NULL
......
......@@ -228,6 +228,8 @@ public:
ptr= old_ptr;
return str;
}
bool quote_data(String *unquoted_string);
bool needs_quotes(void);
virtual bool send_binary(Protocol *protocol);
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
{
......
......@@ -123,8 +123,8 @@
ha_federated::write_row
<for every field/column>
ha_federated::quote_data
ha_federated::quote_data
Field::quote_data
Field::quote_data
</for every field/column>
ha_federated::reset
......@@ -136,18 +136,18 @@
ha_federated::index_init
ha_federated::index_read
ha_federated::index_read_idx
ha_federated::quote_data
Field::quote_data
ha_federated::rnd_next
ha_federated::convert_row_to_internal_format
ha_federated::update_row
<quote 3 cols, new and old data>
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
<ha_federated::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
Field::quote_data
</quote 3 cols, new and old data>
ha_federated::extra
......@@ -415,7 +415,7 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
share->scheme= my_strdup(table->s->comment, MYF(0));
if (share->username= strstr(share->scheme, "://"))
if ((share->username= strstr(share->scheme, "://")))
{
share->scheme[share->username - share->scheme] = '\0';
if (strcmp(share->scheme, "mysql") != 0)
......@@ -429,18 +429,18 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
}
share->username+= 3;
if (share->hostname= strchr(share->username, '@'))
if ((share->hostname= strchr(share->username, '@')))
{
share->username[share->hostname - share->username]= '\0';
share->hostname++;
if (share->password= strchr(share->username, ':'))
if ((share->password= strchr(share->username, ':')))
{
share->username[share->password - share->username]= '\0';
share->password++;
share->username= share->username;
// make sure there isn't an extra / or @
if (strchr(share->password, '/') || strchr(share->hostname, '@'))
if ((strchr(share->password, '/') || strchr(share->hostname, '@')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
......@@ -453,14 +453,14 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
user:@hostname:port/database/table
Then password is a null string, so set to NULL
*/
if (share->password[0] == '\0')
if ((share->password[0] == '\0'))
share->password= NULL;
}
else
share->username= share->username;
// make sure there isn't an extra / or @
if (strchr(share->username, '/') || strchr(share->hostname, '@'))
if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
......@@ -469,12 +469,12 @@ Then password is a null string, so set to NULL
DBUG_RETURN(-1);
}
if (share->database= strchr(share->hostname, '/'))
if ((share->database= strchr(share->hostname, '/')))
{
share->hostname[share->database - share->hostname]= '\0';
share->database++;
if (share->sport= strchr(share->hostname, ':'))
if ((share->sport= strchr(share->hostname, ':')))
{
share->hostname[share->sport - share->hostname]= '\0';
share->sport++;
......@@ -484,7 +484,7 @@ Then password is a null string, so set to NULL
share->port= atoi(share->sport);
}
if (share->table_base_name= strchr(share->database, '/'))
if ((share->table_base_name= strchr(share->database, '/')))
{
share->database[share->table_base_name - share->database]= '\0';
share->table_base_name++;
......@@ -507,7 +507,7 @@ Then password is a null string, so set to NULL
DBUG_RETURN(-1);
}
// make sure there's not an extra /
if (strchr(share->table_base_name, '/'))
if ((strchr(share->table_base_name, '/')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
......@@ -586,126 +586,117 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row)
DBUG_RETURN(0);
}
/*
SYNOPSIS
quote_data()
unquoted_string Pointer pointing to the value of a field
field MySQL Field pointer to field being checked for type
DESCRIPTION
Simple method that passes the field type to the method "type_quote"
To get a true/false value as to whether the value in string1 needs
to be enclosed with quotes. This ensures that values in the final
sql statement to be passed to the remote server will be quoted properly
RETURN_VALUE
void Immediately - if string doesn't need quote
void Upon prepending/appending quotes on each side of variable
*/
void ha_federated::quote_data(String *unquoted_string, Field *field )
bool ha_federated::create_where_from_key(
String *to,
KEY *key_info,
const byte *key,
uint key_length
)
{
char escaped_string[IO_SIZE];
char *unquoted_string_buffer;
unquoted_string_buffer= unquoted_string->c_ptr_quick();
int quote_flag;
DBUG_ENTER("ha_federated::quote_data");
// this is the same call that mysql_real_escape_string() calls
escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
unquoted_string->c_ptr_quick(), unquoted_string->length());
DBUG_PRINT("ha_federated::quote_data",
("escape_string_for_mysql unescaped %s escaped %s",
unquoted_string->c_ptr_quick(), escaped_string));
if (field->is_null())
{
DBUG_PRINT("ha_federated::quote_data",
("NULL, no quoted needed for unquoted_string %s, returning.",
unquoted_string->c_ptr_quick()));
DBUG_VOID_RETURN;
}
uint second_loop= 0;
KEY_PART_INFO *key_part;
bool needs_quotes;
quote_flag= type_quote(field->type());
if (quote_flag == 0)
{
DBUG_PRINT("ha_federated::quote_data",
("quote flag 0 no quoted needed for unquoted_string %s, returning.",
unquoted_string->c_ptr_quick()));
DBUG_VOID_RETURN;
}
else
DBUG_ENTER("ha_federated::create_where_from_key");
for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++)
{
// reset string, then re-append with quotes and escaped values
unquoted_string->length(0);
unquoted_string->append("'");
unquoted_string->append((char *)escaped_string);
unquoted_string->append("'");
}
DBUG_PRINT("ha_federated::quote_data",
("FINAL quote_flag %d unquoted_string %s escaped_string %s",
quote_flag, unquoted_string->c_ptr_quick(), escaped_string));
DBUG_VOID_RETURN;
}
/*
Quote a field type if needed
Field *field= key_part->field;
needs_quotes= field->needs_quotes();
//bool needs_quotes= type_quote(field->type());
DBUG_PRINT("ha_federated::create_where_from_key", ("key name %s type %d", field->field_name, field->type()));
uint length= key_part->length;
if (second_loop++ && to->append(" AND ",5))
DBUG_RETURN(1);
if (to->append('`') || to->append(field->field_name) ||
to->append("` ",2))
DBUG_RETURN(1); // Out of memory
if (key_part->null_bit)
{
if (*key++)
{
if (to->append("IS NULL",7))
DBUG_PRINT("ha_federated::create_where_from_key", ("NULL type %s", to->c_ptr_quick()));
DBUG_RETURN(1);
key_length-= key_part->store_length;
key+= key_part->store_length-1;
continue;
}
key_length--;
}
if (to->append("= "))
DBUG_RETURN(1);
if (needs_quotes && to->append("'"))
DBUG_RETURN(1);
if (key_part->type == HA_KEYTYPE_BIT)
{
/* This is can be threated as a hex string */
Field_bit *field= (Field_bit *) (key_part->field);
char buff[64+2], *ptr;
byte *end= (byte *)(key) + length;
buff[0]='0';
buff[1]='x';
for (ptr= buff+2 ; key < end ; key++)
{
uint tmp= (uint) (uchar) *key;
*ptr++=_dig_vec_upper[tmp >> 4];
*ptr++=_dig_vec_upper[tmp & 15];
}
if (to->append(buff, (uint) (ptr-buff)))
DBUG_RETURN(1);
SYNOPSIS
ha_federated::type_quote
int field Enumerated field type number
DBUG_PRINT("ha_federated::create_where_from_key", ("bit type %s", to->c_ptr_quick()));
key_length-= length;
continue;
}
if (key_part->key_part_flag & HA_BLOB_PART)
{
uint blob_length= uint2korr(key);
key+= HA_KEY_BLOB_LENGTH;
key_length-= HA_KEY_BLOB_LENGTH;
if (append_escaped(to, (char *)(key), blob_length))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("blob type %s", to->c_ptr_quick()));
length= key_part->length;
}
else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
length= uint2korr(key);
key+= HA_KEY_BLOB_LENGTH;
if (append_escaped(to, (char *)(key), length))
DBUG_RETURN(1);
DESCRIPTION
Simple method to give true/false whether a field should be quoted.
Used when constructing INSERT and UPDATE queries to the remote server
see write_row and update_row
DBUG_PRINT("ha_federated::create_where_from_key", ("varchar type %s", to->c_ptr_quick()));
}
else
{
DBUG_PRINT("ha_federated::create_where_from_key", ("else block, unknown type so far"));
char buff[MAX_FIELD_WIDTH];
String str(buff, sizeof(buff), field->charset()), *res;
RETURN VALUE
0 if value is of type NOT needing quotes
1 if value is of type needing quotes
*/
uint ha_federated::type_quote(int type)
{
DBUG_ENTER("ha_federated::type_quote");
DBUG_PRINT("ha_federated::type_quote", ("field type %d", type));
switch(type) {
//FIX this is a bug, fix when kernel is fixed
case MYSQL_TYPE_VARCHAR :
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
case FIELD_TYPE_YEAR :
case FIELD_TYPE_NEWDATE :
case FIELD_TYPE_TIME :
case FIELD_TYPE_TIMESTAMP :
case FIELD_TYPE_DATE :
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
case FIELD_TYPE_GEOMETRY :
DBUG_RETURN(1);
res= field->val_str(&str, (char *)(key));
if (field->result_type() == STRING_RESULT)
{
if (append_escaped(to, (char *) res->ptr(), res->length()))
DBUG_RETURN(1);
res= field->val_str(&str, (char *)(key));
case FIELD_TYPE_DECIMAL :
case FIELD_TYPE_TINY :
case FIELD_TYPE_SHORT :
case FIELD_TYPE_INT24 :
case FIELD_TYPE_LONG :
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
case FIELD_TYPE_LONGLONG :
case FIELD_TYPE_NULL :
case FIELD_TYPE_SET :
case FIELD_TYPE_ENUM :
DBUG_PRINT("ha_federated::create_where_from_key", ("else block, string type", to->c_ptr_quick()));
}
else if (to->append(res->ptr(), res->length()))
DBUG_RETURN(1);
}
if (needs_quotes && to->append("'"))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("final value for 'to' %s", to->c_ptr_quick()));
key+= length;
key_length-= length;
DBUG_RETURN(0);
default: DBUG_RETURN(0);
}
DBUG_RETURN(0);
DBUG_RETURN(1);
}
int load_conn_info(FEDERATED_SHARE *share, TABLE *table)
......@@ -975,7 +966,7 @@ int ha_federated::write_row(byte * buf)
int x= 0, num_fields= 0;
Field **field;
ulong current_query_id= 1;
ulong tmp_query_id;
ulong tmp_query_id= 1;
int all_fields_have_same_query_id= 1;
char insert_buffer[IO_SIZE];
......@@ -1060,7 +1051,8 @@ int ha_federated::write_row(byte * buf)
insert_string.append((*field)->field_name);
// quote these fields if they require it
quote_data(&insert_field_value_string, *field);
(*field)->quote_data(&insert_field_value_string);
// append the value
values_string.append(insert_field_value_string);
insert_field_value_string.length(0);
......@@ -1068,9 +1060,10 @@ int ha_federated::write_row(byte * buf)
// append commas between both fields and fieldnames
insert_string.append(',');
values_string.append(',');
DBUG_PRINT("ha_federated::write_row",
("insert_string %s values_string %s insert_field_value_string %s",
insert_string.c_ptr_quick(), values_string.c_ptr_quick(), insert_field_value_string.c_ptr_quick()));
DBUG_PRINT("ha_federated::write_row",
("insert_string %s values_string %s insert_field_value_string %s",
insert_string.c_ptr_quick(), values_string.c_ptr_quick(),
insert_field_value_string.c_ptr_quick()));
}
}
......@@ -1137,8 +1130,8 @@ int ha_federated::update_row(
byte * new_data
)
{
uint x= 0;
uint has_a_primary_key;
int x= 0;
uint has_a_primary_key= 0;
int primary_key_field_num;
char old_field_value_buffer[IO_SIZE], new_field_value_buffer[IO_SIZE];
char update_buffer[IO_SIZE], where_buffer[IO_SIZE];
......@@ -1205,7 +1198,7 @@ int ha_federated::update_row(
{
// otherwise =
(*field)->val_str(&new_field_value);
quote_data(&new_field_value, *field);
(*field)->quote_data(&new_field_value);
if ( has_a_primary_key )
{
......@@ -1223,7 +1216,7 @@ int ha_federated::update_row(
{
(*field)->val_str(&old_field_value,
(char *)(old_data + (*field)->offset()));
quote_data(&old_field_value, *field);
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
}
......@@ -1235,7 +1228,7 @@ int ha_federated::update_row(
{
(*field)->val_str(&old_field_value,
(char *)(old_data + (*field)->offset()));
quote_data(&old_field_value, *field);
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
}
......@@ -1312,7 +1305,7 @@ int ha_federated::delete_row(const byte * buf)
{
delete_string.append("=");
(*field)->val_str(&data_string);
quote_data(&data_string, *field);
(*field)->quote_data(&data_string);
}
delete_string.append(data_string);
......@@ -1366,8 +1359,11 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
__attribute__((unused)))
{
char index_value[IO_SIZE];
char key_value[IO_SIZE];
char test_value[IO_SIZE];
String index_string(index_value, sizeof(index_value), &my_charset_bin);
index_string.length(0);
uint keylen;
char sql_query_buffer[IO_SIZE];
String sql_query(sql_query_buffer, sizeof(sql_query_buffer), &my_charset_bin);
......@@ -1376,20 +1372,20 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
DBUG_ENTER("ha_federated::index_read_idx");
statistic_increment(table->in_use->status_var.ha_read_key_count,&LOCK_status);
index_string.length(0);
sql_query.length(0);
sql_query.append(share->select_query);
sql_query.append(" WHERE ");
sql_query.append(table->key_info[index].key_part->field->field_name);
sql_query.append(" = ");
table->key_info[index].key_part->field->val_str(&index_string, (char *)(key));
quote_data(&index_string, table->key_info[index].key_part->field);
keylen= strlen((char *)(key));
create_where_from_key(&index_string, &table->key_info[index], key, keylen);
sql_query.append(index_string);
DBUG_PRINT("ha_federated::index_read_idx",
("sql_query %s", sql_query.c_ptr_quick()));
("current key %d key value %s index_string value %s length %d", index, (char *)(key),index_string.c_ptr_quick(),
index_string.length()));
DBUG_PRINT("ha_federated::index_read_idx",
("current position %d sql_query %s", current_position,
sql_query.c_ptr_quick()));
if (mysql_real_query(mysql, sql_query.c_ptr_quick(), sql_query.length()))
{
......@@ -1540,7 +1536,7 @@ int ha_federated::rnd_pos(byte * buf, byte *pos)
{
DBUG_ENTER("ha_federated::rnd_pos");
statistic_increment(table->in_use->status_var.ha_read_rnd_count,&LOCK_status);
memcpy(current_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos is not aligned
memcpy_fixed(&current_position, pos, sizeof(MYSQL_ROW_OFFSET)); // pos is not aligned
result->current_row= 0;
result->data_cursor= current_position;
DBUG_RETURN(rnd_next(buf));
......
......@@ -71,10 +71,8 @@ private:
return 0 on success
return errorcode otherwise
*/
//FIX
uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row);
uint type_quote(int type);
void quote_data(String *string1, Field *field);
bool ha_federated::create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length);
public:
ha_federated(TABLE *table): handler(table),
......@@ -104,7 +102,7 @@ public:
{
return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_AUTO_PART_KEY |
HA_TABLE_SCAN_ON_INDEX);
HA_TABLE_SCAN_ON_INDEX | HA_CAN_INDEX_BLOBS);
}
/*
This is a bitmap of flags that says how the storage engine
......@@ -132,7 +130,7 @@ public:
/*
The next method will never be called if you do not implement indexes.
*/
virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; }
virtual double read_time(uint index, uint ranges, ha_rows rows) { return (double) rows / 20.0+1; }
/*
Everything below are methods that we implment in ha_federated.cc.
......
......@@ -712,6 +712,10 @@ void free_des_key_file();
/* sql_do.cc */
bool mysql_do(THD *thd, List<Item> &values);
/* sql_analyse.h */
bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, char *from, uint from_len);
/* sql_show.cc */
bool mysqld_show_open_tables(THD *thd,const char *wild);
bool mysqld_show_logs(THD *thd);
......
......@@ -733,7 +733,7 @@ struct show_var_st init_vars[]= {
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
{"have_federated_db", (char*) &have_federated_db, SHOW_HAVE},
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
{"have_geometry", (char*) &have_geometry, SHOW_HAVE},
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
{"have_isam", (char*) &have_isam, SHOW_HAVE},
......
......@@ -59,7 +59,8 @@ int compare_ulonglong2(void* cmp_arg __attribute__((unused)),
return compare_ulonglong(s,t);
}
static bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, char *from, uint from_len);
Procedure *
proc_analyse_init(THD *thd, ORDER *param, select_result *result,
......@@ -1052,7 +1053,7 @@ uint check_ulonglong(const char *str, uint length)
1 Out of memory
*/
static bool append_escaped(String *to_str, String *from_str)
bool append_escaped(String *to_str, String *from_str)
{
char *from, *end, c;
......@@ -1086,3 +1087,38 @@ static bool append_escaped(String *to_str, String *from_str)
}
return 0;
}
bool append_escaped(String *to_str, char *from, uint from_len)
{
char *end, c;
if (to_str->realloc(to_str->length() + from_len))
return 1;
end= from + from_len;
for (; from < end; from++)
{
c= *from;
switch (c) {
case '\0':
c= '0';
break;
case '\032':
c= 'Z';
break;
case '\\':
case '\'':
break;
default:
goto normal_character;
}
if (to_str->append('\\'))
return 1;
normal_character:
if (to_str->append(c))
return 1;
}
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment