Commit e3f8c2f5 authored by patg@krsna.patg.net's avatar patg@krsna.patg.net

Merge mysqldev@production.mysql.com:/data0/mysqldev/my/mysql-5.0-merge

into krsna.patg.net:/home/patg/mysql-5.0
parents 7110f21c 0aec332b
......@@ -1115,25 +1115,6 @@ mysql_fetch_field(MYSQL_RES *result)
}
/**************************************************************************
Get column lengths of the current row
If one uses mysql_use_result, res->lengths contains the length information,
else the lengths are calculated from the offset between pointers.
**************************************************************************/
ulong * STDCALL
mysql_fetch_lengths(MYSQL_RES *res)
{
MYSQL_ROW column;
if (!(column=res->current_row))
return 0; /* Something is wrong */
if (res->data)
(*res->methods->fetch_lengths)(res->lengths, column, res->field_count);
return res->lengths;
}
/**************************************************************************
Move to a specific row and column
**************************************************************************/
......
......@@ -5,23 +5,40 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
drop database if exists federated;
create database federated;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL default '', `other` int(20) NOT NULL default '0', created datetime default '2004-04-04 04:04:04', PRIMARY KEY (`id`), KEY `name` (`name`), KEY `other_key` (`other`)) DEFAULT CHARSET=latin1;
drop database if exists federated;
create database federated;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL default '', `other` int(20) NOT NULL default '0', created datetime default '2004-04-04 04:04:04', PRIMARY KEY (`id`), KEY `name` (`name`), KEY `other_key` (`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', 11111);
insert into federated.t1 (name, other) values ('Second Name', 22222);
insert into federated.t1 (name, other) values ('Third Name', 33333);
insert into federated.t1 (name, other) values ('Fourth Name', 44444);
insert into federated.t1 (name, other) values ('Fifth Name', 55555);
insert into federated.t1 (name, other) values ('Sixth Name', 66666);
insert into federated.t1 (name, other) values ('Seventh Name', 77777);
insert into federated.t1 (name, other) values ('Eigth Name', 88888);
insert into federated.t1 (name, other) values ('Ninth Name', 99999);
insert into federated.t1 (name, other) values ('Tenth Name', 101010);
select * from federated.t1;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL auto_increment,
`name` varchar(32) NOT NULL default '',
`other` int(20) NOT NULL default '0',
`created` datetime default '2004-04-04 04:04:04',
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `other_key` (`other`))
DEFAULT CHARSET=latin1;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL auto_increment,
`name` varchar(32) NOT NULL default '',
`other` int(20) NOT NULL default '0',
`created` datetime default '2004-04-04 04:04:04',
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `other_key` (`other`))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
INSERT INTO federated.t1 (name, other) VALUES ('First Name', 11111);
INSERT INTO federated.t1 (name, other) VALUES ('Second Name', 22222);
INSERT INTO federated.t1 (name, other) VALUES ('Third Name', 33333);
INSERT INTO federated.t1 (name, other) VALUES ('Fourth Name', 44444);
INSERT INTO federated.t1 (name, other) VALUES ('Fifth Name', 55555);
INSERT INTO federated.t1 (name, other) VALUES ('Sixth Name', 66666);
INSERT INTO federated.t1 (name, other) VALUES ('Seventh Name', 77777);
INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888);
INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999);
INSERT INTO federated.t1 (name, other) VALUES ('Tenth Name', 101010);
SELECT * FROM federated.t1;
id name other created
1 First Name 11111 2004-04-04 04:04:04
2 Second Name 22222 2004-04-04 04:04:04
......@@ -33,19 +50,19 @@ id name other created
8 Eigth Name 88888 2004-04-04 04:04:04
9 Ninth Name 99999 2004-04-04 04:04:04
10 Tenth Name 101010 2004-04-04 04:04:04
select * from federated.t1 where id = 5;
SELECT * FROM federated.t1 WHERE id = 5;
id name other created
5 Fifth Name 55555 2004-04-04 04:04:04
select * from federated.t1 where name = 'Sixth Name';
SELECT * FROM federated.t1 WHERE name = 'Sixth Name';
id name other created
6 Sixth Name 66666 2004-04-04 04:04:04
select * from federated.t1 where id = 6 and name = 'Sixth Name';
SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name';
id name other created
6 Sixth Name 66666 2004-04-04 04:04:04
select * from federated.t1 where other = 44444;
SELECT * FROM federated.t1 WHERE other = 44444;
id name other created
4 Fourth Name 44444 2004-04-04 04:04:04
select * from federated.t1 where name like '%th%';
SELECT * FROM federated.t1 WHERE name like '%th%';
id name other created
3 Third Name 33333 2004-04-04 04:04:04
4 Fourth Name 44444 2004-04-04 04:04:04
......@@ -55,15 +72,15 @@ id name other created
8 Eigth Name 88888 2004-04-04 04:04:04
9 Ninth Name 99999 2004-04-04 04:04:04
10 Tenth Name 101010 2004-04-04 04:04:04
update federated.t1 set name = '3rd name' where id = 3;
select * from federated.t1 where name = '3rd name';
UPDATE federated.t1 SET name = '3rd name' WHERE id = 3;
SELECT * FROM federated.t1 WHERE name = '3rd name';
id name other created
3 3rd name 33333 2004-04-04 04:04:04
update federated.t1 set name = 'Third name' where name = '3rd name';
select * from federated.t1 where name = 'Third name';
UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name';
SELECT * FROM federated.t1 WHERE name = 'Third name';
id name other created
3 Third name 33333 2004-04-04 04:04:04
select * from federated.t1 order by id DESC;
SELECT * FROM federated.t1 ORDER BY id DESC;
id name other created
10 Tenth Name 101010 2004-04-04 04:04:04
9 Ninth Name 99999 2004-04-04 04:04:04
......@@ -75,7 +92,7 @@ id name other created
3 Third name 33333 2004-04-04 04:04:04
2 Second Name 22222 2004-04-04 04:04:04
1 First Name 11111 2004-04-04 04:04:04
select * from federated.t1 order by name;
SELECT * FROM federated.t1 ORDER BY name;
id name other created
8 Eigth Name 88888 2004-04-04 04:04:04
5 Fifth Name 55555 2004-04-04 04:04:04
......@@ -87,7 +104,7 @@ id name other created
6 Sixth Name 66666 2004-04-04 04:04:04
10 Tenth Name 101010 2004-04-04 04:04:04
3 Third name 33333 2004-04-04 04:04:04
select * from federated.t1 order by name DESC;
SELECT * FROM federated.t1 ORDER BY name DESC;
id name other created
3 Third name 33333 2004-04-04 04:04:04
10 Tenth Name 101010 2004-04-04 04:04:04
......@@ -99,7 +116,7 @@ id name other created
1 First Name 11111 2004-04-04 04:04:04
5 Fifth Name 55555 2004-04-04 04:04:04
8 Eigth Name 88888 2004-04-04 04:04:04
select * from federated.t1 order by name ASC;
SELECT * FROM federated.t1 ORDER BY name ASC;
id name other created
8 Eigth Name 88888 2004-04-04 04:04:04
5 Fifth Name 55555 2004-04-04 04:04:04
......@@ -111,7 +128,7 @@ id name other created
6 Sixth Name 66666 2004-04-04 04:04:04
10 Tenth Name 101010 2004-04-04 04:04:04
3 Third name 33333 2004-04-04 04:04:04
select * from federated.t1 group by other;
SELECT * FROM federated.t1 GROUP BY other;
id name other created
1 First Name 11111 2004-04-04 04:04:04
2 Second Name 22222 2004-04-04 04:04:04
......@@ -123,52 +140,65 @@ id name other created
8 Eigth Name 88888 2004-04-04 04:04:04
9 Ninth Name 99999 2004-04-04 04:04:04
10 Tenth Name 101010 2004-04-04 04:04:04
delete from federated.t1 where id = 5;
select * from federated.t1 where id = 5;
DELETE FROM federated.t1 WHERE id = 5;
SELECT * FROM federated.t1 WHERE id = 5;
id name other created
delete from federated.t1;
select * from federated.t1 where id = 5;
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`) );
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);
insert into federated.t1 (name, other) values (NULL, NULL);
insert into federated.t1 (name, other) values ('Fifth Name', 55555);
insert into federated.t1 (name, other) values ('Sixth Name', 66666);
insert into federated.t1 (name) values ('Seventh Name');
insert into federated.t1 (name, other) values ('Eigth Name', 88888);
insert into federated.t1 (name, other) values ('Ninth Name', 99999);
insert into federated.t1 (other) values ('fee fie foe fum');
select * from federated.t1 where other IS NULL;
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:SLAVE_PORT/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);
INSERT INTO federated.t1 (name, other) VALUES (NULL, NULL);
INSERT INTO federated.t1 (name, other) VALUES ('Fifth Name', 55555);
INSERT INTO federated.t1 (name, other) VALUES ('Sixth Name', 66666);
INSERT INTO federated.t1 (name) VALUES ('Seventh Name');
INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888);
INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999);
INSERT INTO federated.t1 (other) VALUES ('fee fie foe fum');
SELECT * FROM federated.t1 WHERE other IS NULL;
id name other
2 Second Name NULL
4 NULL NULL
7 Seventh Name NULL
select * from federated.t1 where name IS NULL;
SELECT * FROM federated.t1 WHERE name IS NULL;
id name other
4 NULL NULL
10 NULL fee fie foe fum
select * from federated.t1 where name IS NULL and other IS NULL;
SELECT * FROM federated.t1 WHERE name IS NULL and other IS NULL;
id name other
4 NULL NULL
select * from federated.t1 where name IS NULL or other IS NULL;
SELECT * FROM federated.t1 WHERE name IS NULL or other IS NULL;
id name other
2 Second Name NULL
4 NULL NULL
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 = '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 ;
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 = '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 ;
id name other
select * from federated.t1;
SELECT * FROM federated.t1;
id name other
1 First Name 11111
2 Second Name seven seven
......@@ -180,149 +210,206 @@ id name other
8 Eigth Name 88888
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';
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:SLAVE_PORT/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';
SELECT * FROM federated.t1 WHERE other = '2222';
id name other
2 Second Name 2222
select * from federated.t1 where name = 'Third Name';
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';
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;
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:SLAVE_PORT/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';
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';
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;
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;
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';
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;
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';
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;
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;
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';
insert into federated.t1 values (NULL, NULL, NULL, NULL);
insert into federated.t1 values ();
insert into federated.t1 (id) values (1);
insert into federated.t1 (name, floatval, other) values ('foo', 33.33333332, NULL);
insert into federated.t1 (name, floatval, other) values (0, 00.3333, NULL);
select * from federated.t1;
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:SLAVE_PORT/federated/t1';
INSERT INTO federated.t1 values (NULL, NULL, NULL, NULL);
INSERT INTO federated.t1 values ();
INSERT INTO federated.t1 (id) VALUES (1);
INSERT INTO federated.t1 (name, floatval, other)
VALUES ('foo', 33.33333332, NULL);
INSERT INTO federated.t1 (name, floatval, other)
VALUES (0, 00.3333, NULL);
SELECT * FROM federated.t1;
id name floatval other
NULL NULL NULL NULL
NULL NULL NULL NULL
1 NULL NULL NULL
NULL foo 33.3333 NULL
NULL 0 0.3333 NULL
select count(*) from federated.t1 where id IS NULL and name IS NULL and floatval IS NULL and other IS NULL;
SELECT count(*) FROM federated.t1
WHERE id IS NULL
AND name IS NULL
AND floatval IS NULL
AND other IS NULL;
count(*)
2
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( blurb_id int NOT NULL DEFAULT 0, blurb text default '', primary key(blurb_id)) DEFAULT CHARSET=latin1;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( blurb_id int NOT NULL DEFAULT 0, blurb text default '', primary key(blurb_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 (
`blurb_id` int NOT NULL DEFAULT 0,
`blurb` text default '',
PRIMARY KEY (blurb_id))
DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`blurb_id` int NOT NULL DEFAULT 0,
`blurb` text default '',
PRIMARY KEY (blurb_id))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.");
INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.");
INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. ");
INSERT INTO federated.t1 VALUES(4, "Die bersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest fr jemanden, der seine Zielsprache ernst nimmt:");
select * from federated.t1;
SELECT * FROM federated.t1;
blurb_id blurb
1 MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.
2 All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.
3 A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined.
4 Die bersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest fr jemanden, der seine Zielsprache ernst nimmt:
drop table if exists federated.t1;
create table federated.t1 (a int not null, b int not null, c int not null, primary key (a),key(b));
drop table if exists federated.t1;
create table federated.t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from federated.t1 order by a;
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`a` int NOT NULL,
`b` int NOT NULL,
`c` int NOT NULL,
PRIMARY KEY (a),key(b));
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`a` int NOT NULL,
`b` int NOT NULL,
`c` int NOT NULL,
PRIMARY KEY (a),
KEY (b))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
INSERT INTO federated.t1 VALUES (3,3,3),(1,1,1),(2,2,2),(4,4,4);
EXPLAIN SELECT * FROM federated.t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using filesort
explain select * from federated.t1 order by b;
EXPLAIN SELECT * FROM federated.t1 ORDER BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using filesort
explain select * from federated.t1 order by c;
EXPLAIN SELECT * FROM federated.t1 ORDER BY c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using filesort
explain select a from federated.t1 order by a;
EXPLAIN SELECT a FROM federated.t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using filesort
explain select b from federated.t1 order by b;
EXPLAIN SELECT b FROM federated.t1 ORDER BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using filesort
explain select a,b from federated.t1 order by b;
EXPLAIN SELECT a,b FROM federated.t1 ORDER BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using filesort
explain select a,b from federated.t1;
EXPLAIN SELECT a,b FROM federated.t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000
explain select a,b,c from federated.t1;
EXPLAIN SELECT a,b,c FROM federated.t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000
drop table if exists federated.t1;
create table federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
......@@ -447,10 +534,11 @@ int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
int, i999 int, i1000 int, b blob) row_format=dynamic;
drop table if exists federated.t1;
create table federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1
(i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int,
i17 int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int,
i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51
......@@ -572,8 +660,13 @@ int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
int, i999 int, i1000 int, b blob) row_format=dynamic ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
int, i999 int, i1000 int, b blob)
row_format=dynamic
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
INSERT INTO federated.t1
values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
......@@ -612,64 +705,108 @@ insert into federated.t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "PatrickG");
update federated.t1 set b=repeat('a',256);
update federated.t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0;
select * from federated.t1 where i9=0 and i10=0;
UPDATE federated.t1 SET b=repeat('a',256);
UPDATE federated.t1 SET i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0;
SELECT * FROM federated.t1 WHERE i9=0 and i10=0;
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
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 PatrickG
update federated.t1 set i50=20;
select * from federated.t1;
UPDATE federated.t1 SET 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
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 PatrickG
delete from federated.t1 where i51=20;
select * from federated.t1;
DELETE FROM federated.t1 WHERE i51=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
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 PatrickG
delete from federated.t1 where i50=20;
select * from federated.t1;
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 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 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;
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 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:SLAVE_PORT/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';
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;
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (`a` BLOB);
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`a` BLOB)
ENGINE="FEDERATED"
COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
INSERT INTO federated.t1 VALUES (0x00);
INSERT INTO federated.t1 VALUES (0x0001);
INSERT INTO federated.t1 VALUES (0x0100);
SELECT HEX(a) FROM federated.t1;
HEX(a)
00
0001
0100
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.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;
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');
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:SLAVE_PORT/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);
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;
drop database if exists federated;
DROP TABLE federated.countries;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
......@@ -10,206 +10,304 @@ stop slave;
--disable_warnings
# at this point, we are connected to master
drop database if exists federated;
DROP DATABASE IF EXISTS federated;
--enable_warnings
create database federated;
CREATE DATABASE federated;
# I wanted to use timestamp, but results will fail if so!!!
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL default '', `other` int(20) NOT NULL default '0', created datetime default '2004-04-04 04:04:04', PRIMARY KEY (`id`), KEY `name` (`name`), KEY `other_key` (`other`)) DEFAULT CHARSET=latin1;
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL auto_increment,
`name` varchar(32) NOT NULL default '',
`other` int(20) NOT NULL default '0',
`created` datetime default '2004-04-04 04:04:04',
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `other_key` (`other`))
DEFAULT CHARSET=latin1;
connection master;
--disable_warnings
drop database if exists federated;
DROP DATABASE IF EXISTS federated;
--enable_warnings
create database federated;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL default '', `other` int(20) NOT NULL default '0', created datetime default '2004-04-04 04:04:04', PRIMARY KEY (`id`), KEY `name` (`name`), KEY `other_key` (`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', 11111);
insert into federated.t1 (name, other) values ('Second Name', 22222);
insert into federated.t1 (name, other) values ('Third Name', 33333);
insert into federated.t1 (name, other) values ('Fourth Name', 44444);
insert into federated.t1 (name, other) values ('Fifth Name', 55555);
insert into federated.t1 (name, other) values ('Sixth Name', 66666);
insert into federated.t1 (name, other) values ('Seventh Name', 77777);
insert into federated.t1 (name, other) values ('Eigth Name', 88888);
insert into federated.t1 (name, other) values ('Ninth Name', 99999);
insert into federated.t1 (name, other) values ('Tenth Name', 101010);
CREATE DATABASE federated;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (
`id` int(20) NOT NULL auto_increment,
`name` varchar(32) NOT NULL default '',
`other` int(20) NOT NULL default '0',
`created` datetime default '2004-04-04 04:04:04',
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `other_key` (`other`))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
INSERT INTO federated.t1 (name, other) VALUES ('First Name', 11111);
INSERT INTO federated.t1 (name, other) VALUES ('Second Name', 22222);
INSERT INTO federated.t1 (name, other) VALUES ('Third Name', 33333);
INSERT INTO federated.t1 (name, other) VALUES ('Fourth Name', 44444);
INSERT INTO federated.t1 (name, other) VALUES ('Fifth Name', 55555);
INSERT INTO federated.t1 (name, other) VALUES ('Sixth Name', 66666);
INSERT INTO federated.t1 (name, other) VALUES ('Seventh Name', 77777);
INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888);
INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999);
INSERT INTO federated.t1 (name, other) VALUES ('Tenth Name', 101010);
# basic select
select * from federated.t1;
# with primary key index_read_idx
select * from federated.t1 where id = 5;
SELECT * FROM federated.t1;
# with PRIMARY KEY index_read_idx
SELECT * FROM federated.t1 WHERE id = 5;
# with regular key index_read -> index_read_idx
select * from federated.t1 where name = 'Sixth Name';
# regular and primary key index_read_idx
select * from federated.t1 where id = 6 and name = 'Sixth Name';
SELECT * FROM federated.t1 WHERE name = 'Sixth Name';
# regular and PRIMARY KEY index_read_idx
SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name';
# with regular key index_read -> index_read_idx
select * from federated.t1 where other = 44444;
select * from federated.t1 where name like '%th%';
SELECT * FROM federated.t1 WHERE other = 44444;
SELECT * FROM federated.t1 WHERE name like '%th%';
# update - update_row, index_read_idx
update federated.t1 set name = '3rd name' where id = 3;
select * from federated.t1 where name = '3rd name';
UPDATE federated.t1 SET name = '3rd name' WHERE id = 3;
SELECT * FROM federated.t1 WHERE name = '3rd name';
# update - update_row, index_read -> index_read_idx
update federated.t1 set name = 'Third name' where name = '3rd name';
select * from federated.t1 where name = 'Third name';
UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name';
SELECT * FROM federated.t1 WHERE name = 'Third name';
# rnd_post, ::position
select * from federated.t1 order by id DESC;
select * from federated.t1 order by name;
select * from federated.t1 order by name DESC;
select * from federated.t1 order by name ASC;
select * from federated.t1 group by other;
SELECT * FROM federated.t1 ORDER BY id DESC;
SELECT * FROM federated.t1 ORDER BY name;
SELECT * FROM federated.t1 ORDER BY name DESC;
SELECT * FROM federated.t1 ORDER BY name ASC;
SELECT * FROM federated.t1 GROUP BY other;
# ::delete_row
delete from federated.t1 where id = 5;
select * from federated.t1 where id = 5;
DELETE FROM federated.t1 WHERE id = 5;
SELECT * FROM federated.t1 WHERE id = 5;
# ::delete_all_rows
delete from federated.t1;
select * from federated.t1 where id = 5;
DELETE FROM federated.t1;
SELECT * FROM federated.t1 WHERE id = 5;
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`) );
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);
insert into federated.t1 (name, other) values (NULL, NULL);
insert into federated.t1 (name, other) values ('Fifth Name', 55555);
insert into federated.t1 (name, other) values ('Sixth Name', 66666);
insert into federated.t1 (name) values ('Seventh Name');
insert into federated.t1 (name, other) values ('Eigth Name', 88888);
insert into federated.t1 (name, other) values ('Ninth Name', 99999);
insert into federated.t1 (other) values ('fee fie foe fum');
select * from federated.t1 where other IS NULL;
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 = '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;
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval 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:$SLAVE_MYPORT/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);
INSERT INTO federated.t1 (name, other) VALUES (NULL, NULL);
INSERT INTO federated.t1 (name, other) VALUES ('Fifth Name', 55555);
INSERT INTO federated.t1 (name, other) VALUES ('Sixth Name', 66666);
INSERT INTO federated.t1 (name) VALUES ('Seventh Name');
INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888);
INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999);
INSERT INTO federated.t1 (other) VALUES ('fee fie foe fum');
SELECT * FROM federated.t1 WHERE other IS NULL;
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 = '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(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) );
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';
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval 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:$SLAVE_MYPORT/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));
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;
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval 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:$SLAVE_MYPORT/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;
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';
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval 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:$SLAVE_MYPORT/federated/t1';
# these both should be the same
insert into federated.t1 values (NULL, NULL, NULL, NULL);
insert into federated.t1 values ();
insert into federated.t1 (id) values (1);
insert into federated.t1 (name, floatval, other) values ('foo', 33.33333332, NULL);
insert into federated.t1 (name, floatval, other) values (0, 00.3333, NULL);
select * from federated.t1;
select count(*) from federated.t1 where id IS NULL and name IS NULL and floatval IS NULL and other IS NULL;
INSERT INTO federated.t1 values (NULL, NULL, NULL, NULL);
INSERT INTO federated.t1 values ();
INSERT INTO federated.t1 (id) VALUES (1);
INSERT INTO federated.t1 (name, floatval, other)
VALUES ('foo', 33.33333332, NULL);
INSERT INTO federated.t1 (name, floatval, other)
VALUES (0, 00.3333, NULL);
SELECT * FROM federated.t1;
SELECT count(*) FROM federated.t1
WHERE id IS NULL
AND name IS NULL
AND floatval IS NULL
AND other IS NULL;
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( blurb_id int NOT NULL DEFAULT 0, blurb text default '', primary key(blurb_id)) DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`blurb_id` int NOT NULL DEFAULT 0,
`blurb` text default '',
PRIMARY KEY (blurb_id))
DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( blurb_id int NOT NULL DEFAULT 0, blurb text default '', primary key(blurb_id)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (
`blurb_id` int NOT NULL DEFAULT 0,
`blurb` text default '',
PRIMARY KEY (blurb_id))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.");
INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.");
INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. ");
INSERT INTO federated.t1 VALUES(4, "Die bersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest fr jemanden, der seine Zielsprache ernst nimmt:");
select * from federated.t1;
SELECT * FROM federated.t1;
connection slave;
drop table if exists federated.t1;
create table federated.t1 (a int not null, b int not null, c int not null, primary key (a),key(b));
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`a` int NOT NULL,
`b` int NOT NULL,
`c` int NOT NULL,
PRIMARY KEY (a),key(b));
connection master;
drop table if exists federated.t1;
create table federated.t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from federated.t1 order by a;
explain select * from federated.t1 order by b;
explain select * from federated.t1 order by c;
explain select a from federated.t1 order by a;
explain select b from federated.t1 order by b;
explain select a,b from federated.t1 order by b;
explain select a,b from federated.t1;
explain select a,b,c from federated.t1;
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (
`a` int NOT NULL,
`b` int NOT NULL,
`c` int NOT NULL,
PRIMARY KEY (a),
KEY (b))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
INSERT INTO federated.t1 VALUES (3,3,3),(1,1,1),(2,2,2),(4,4,4);
EXPLAIN SELECT * FROM federated.t1 ORDER BY a;
EXPLAIN SELECT * FROM federated.t1 ORDER BY b;
EXPLAIN SELECT * FROM federated.t1 ORDER BY c;
EXPLAIN SELECT a FROM federated.t1 ORDER BY a;
EXPLAIN SELECT b FROM federated.t1 ORDER BY b;
EXPLAIN SELECT a,b FROM federated.t1 ORDER BY b;
EXPLAIN SELECT a,b FROM federated.t1;
EXPLAIN SELECT a,b,c FROM federated.t1;
connection slave;
drop table if exists federated.t1;
create table federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
......@@ -336,10 +434,12 @@ int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
int, i999 int, i1000 int, b blob) row_format=dynamic;
connection master;
drop table if exists federated.t1;
create table federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1
(i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int,
i17 int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int,
i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51
......@@ -461,8 +561,14 @@ int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
int, i999 int, i1000 int, b blob) row_format=dynamic ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
int, i999 int, i1000 int, b blob)
row_format=dynamic
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
INSERT INTO federated.t1
values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
......@@ -501,93 +607,145 @@ insert into federated.t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "PatrickG");
update federated.t1 set b=repeat('a',256);
update federated.t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0;
select * from federated.t1 where i9=0 and i10=0;
update federated.t1 set i50=20;
select * from federated.t1;
delete from federated.t1 where i51=20;
select * from federated.t1;
delete from federated.t1 where i50=20;
select * from federated.t1;
UPDATE federated.t1 SET b=repeat('a',256);
UPDATE federated.t1 SET i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0;
SELECT * FROM federated.t1 WHERE i9=0 and i10=0;
UPDATE federated.t1 SET i50=20;
SELECT * FROM federated.t1;
DELETE FROM federated.t1 WHERE i51=20;
SELECT * FROM federated.t1;
DELETE FROM federated.t1 WHERE i50=20;
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 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 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 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;
select * from federated.t1 where fileguts = 'jimbob';
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval 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:$SLAVE_MYPORT/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;
# test blob indexes
SELECT * FROM federated.t1 WHERE fileguts = 'jimbob';
# test blob with binary
connection slave;
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (`a` BLOB);
connection master;
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE federated.t1 (
`a` BLOB)
ENGINE="FEDERATED"
COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
INSERT INTO federated.t1 VALUES (0x00);
INSERT INTO federated.t1 VALUES (0x0001);
INSERT INTO federated.t1 VALUES (0x0100);
SELECT HEX(a) FROM federated.t1;
# TODO
#
# create table federated.t1 (a char(20)) charset=cp1251 ENGINE="FEDERATED" COMMENT="mysql://root@127.0.0.1:9308/federated/t1";
# CREATE TABLE federated.t1
# (a char(20)) charset=cp1251
# ENGINE="FEDERATED" COMMENT="mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1";
#
# connection slave;
# drop table if exists federated.t1;
# create table federated.t1 (a char(20)) charset=cp1251;
# DROP TABLE IF EXISTS federated.t1;
# CREATE TABLE federated.t1 (a char(20)) charset=cp1251;
#
# connection master;
# insert into federated.t1 values (_cp1251'À-ÁÂÃ-1');
# insert into federated.t1 values (_cp1251'Á-ÂÃÄ-2');
# set names cp1251;
# insert into federated.t1 values ('Â-ÃÄÅ-3');
# insert into federated.t1 values ('Ã-ŨÆ-4');
# select * from federated.t1;
# INSERT INTO federated.t1 values (_cp1251'--1');
# INSERT INTO federated.t1 values (_cp1251'--2');
# SET names cp1251;
# INSERT INTO federated.t1 values ('--3');
# INSERT INTO federated.t1 values ('-Ũ-4');
# SELECT * FROM federated.t1;
# select hex(a) from federated.t1;
# select hex(a) from federated.t1 order by a desc;
# update federated.t1 set a='À-ÁÂÃ-1íîâûé' where a='À-ÁÂÃ-1';
# select * from federated.t1;
# delete from federated.t1 where a='Ã-ŨÆ-4';
# select * from federated.t1;
# delete from federated.t1 where a>'Â-';
# select * from federated.t1;
# set names default;
# select hex(a) from federated.t1 ORDER BY a desc;
# update federated.t1 SET a='--1' WHERE a='--1';
# SELECT * FROM federated.t1;
# DELETE FROM federated.t1 WHERE a='-Ũ-4';
# SELECT * FROM federated.t1;
# DELETE FROM federated.t1 WHERE a>'-';
# SELECT * FROM federated.t1;
# SET names default;
#
# 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));
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;
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');
DROP TABLE IF EXISTS federated.t1;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval 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:$SLAVE_MYPORT/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);
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;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
--enable_warnings
connection slave;
--disable_warnings
drop table if exists federated.t1;
drop database if exists federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
--enable_warnings
......@@ -2628,6 +2628,25 @@ mysql_fetch_row(MYSQL_RES *res)
}
/**************************************************************************
Get column lengths of the current row
If one uses mysql_use_result, res->lengths contains the length information,
else the lengths are calculated from the offset between pointers.
**************************************************************************/
ulong * STDCALL
mysql_fetch_lengths(MYSQL_RES *res)
{
MYSQL_ROW column;
if (!(column=res->current_row))
return 0; /* Something is wrong */
if (res->data)
(*res->methods->fetch_lengths)(res->lengths, column, res->field_count);
return res->lengths;
}
int STDCALL
mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
{
......
......@@ -21,27 +21,27 @@
ha_federated.cc - MySQL Federated Storage Engine
Patrick Galbraith and Brian Aker, 2004
This is a handler which uses a remote database as the data file, as
This is a handler which uses a foreign database as the data file, as
opposed to a handler like MyISAM, which uses .MYD files locally.
How this handler works
----------------------------------
Normal database files are local and as such: You create a table called
'users', a file such as 'users.MYD' is created. A handler reads, inserts,
Normal database files are local and as such: You create a table called
'users', a file such as 'users.MYD' is created. A handler reads, inserts,
deletes, updates data in this file. The data is stored in particular format,
so to read, that data has to be parsed into fields, to write, fields have to
be stored in this format to write to this data file.
be stored in this format to write to this data file.
With MySQL Federated storage engine, there will be no local files for each
table's data (such as .MYD). A remote database will store the data that would
normally be in this file. This will necessitate the use of MySQL client API
table's data (such as .MYD). A foreign database will store the data that would
normally be in this file. This will necessitate the use of MySQL client API
to read, delete, update, insert this data. The data will have to be retrieve
via an SQL call "SELECT * FROM users". Then, to read this data, it will have
to be retrieved via mysql_fetch_row one row at a time, then converted from
to be retrieved via mysql_fetch_row one row at a time, then converted from
the column in this select into the format that the handler expects.
The create table will simply create the .frm file, and within the
"CREATE TABLE" SQL, there SHALL be any of the following :
The create table will simply create the .frm file, and within the
"CREATE TABLE" SQL, there SHALL be any of the following :
comment=scheme://username:password@hostname:port/database/tablename
comment=scheme://username@hostname/database/tablename
......@@ -57,41 +57,41 @@
Only 'mysql://' is supported at this release.
This comment connection string is necessary for the handler to be
able to connect to the remote server.
This comment connection string is necessary for the handler to be
able to connect to the foreign server.
The basic flow is this:
SQL calls issues locally ->
mysql handler API (data in handler format) ->
mysql client API (data converted to SQL calls) ->
remote database -> mysql client API ->
mysql handler API (data in handler format) ->
mysql client API (data converted to SQL calls) ->
foreign database -> mysql client API ->
convert result sets (if any) to handler format ->
handler API -> results or rows affected to local
What this handler does and doesn't support
------------------------------------------
* Tables MUST be created on the remote server prior to any action on those
tables via the handler, first version. IMPORTANT: IF you MUST use the
* Tables MUST be created on the foreign server prior to any action on those
tables via the handler, first version. IMPORTANT: IF you MUST use the
federated storage engine type on the REMOTE end, MAKE SURE [ :) ] That
the table you connect to IS NOT a table pointing BACK to your ORIGNAL
the table you connect to IS NOT a table pointing BACK to your ORIGNAL
table! You know and have heard the screaching of audio feedback? You
know putting two mirror in front of each other how the reflection
know putting two mirror in front of each other how the reflection
continues for eternity? Well, need I say more?!
* There will not be support for transactions.
* There is no way for the handler to know if the database on the remote end
* There is no way for the handler to know if the foreign database or table
has changed. The reason for this is that this database has to work like a
data file that would never be written to by anything other than the
database. The integrity of the data in the local table could be breached
if there was any change to the remote database.
data file that would never be written to by anything other than the
database. The integrity of the data in the local table could be breached
if there was any change to the foreign database.
* Support for SELECT, INSERT, UPDATE , DELETE, indexes.
* No ALTER TABLE, DROP TABLE or any other Data Definition Language calls.
* Prepared statements will not be used in the first implementation, it
* Prepared statements will not be used in the first implementation, it
remains to to be seen whether the limited subset of the client API for the
server supports this.
* This uses SELECT, INSERT, UPDATE, DELETE and not HANDLER for its
implementation.
* This uses SELECT, INSERT, UPDATE, DELETE and not HANDLER for its
implementation.
* This will not work with the query cache.
Method calls
......@@ -100,7 +100,7 @@
(SELECT)
"SELECT * FROM foo"
"SELECT * FROM foo"
ha_federated::info
ha_federated::scan_time:
ha_federated::rnd_init: share->select_query SELECT * FROM foo
......@@ -140,7 +140,7 @@
ha_federated::rnd_next
ha_federated::convert_row_to_internal_format
ha_federated::update_row
<quote 3 cols, new and old data>
Field::quote_data
Field::quote_data
......@@ -149,7 +149,7 @@
Field::quote_data
Field::quote_data
</quote 3 cols, new and old data>
ha_federated::extra
ha_federated::extra
ha_federated::extra
......@@ -160,53 +160,53 @@
How do I use this handler?
--------------------------
First of all, you need to build this storage engine:
./configure --with-federated-storage-engine
make
Next, to use this handler, it's very simple. You must
Next, to use this handler, it's very simple. You must
have two databases running, either both on the same host, or
on different hosts.
One the server that will be connecting to the remote
One the server that will be connecting to the foreign
host (client), you create your table as such:
CREATE TABLE test_table (
CREATE TABLE test_table (
id int(20) NOT NULL auto_increment,
name varchar(32) NOT NULL default '',
other int(20) NOT NULL default '0',
PRIMARY KEY (id),
KEY name (name),
KEY other_key (other))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
KEY other_key (other))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
COMMENT='root@127.0.0.1:9306/federated/test_federated';
Notice the "COMMENT" and "ENGINE" field? This is where you
respectively set the engine type, "FEDERATED" and remote
host information, this being the database your 'client' database
will connect to and use as the "data file". Obviously, the remote
database is running on port 9306, so you want to start up your other
database so that it is indeed on port 9306, and your federated
database on a port other than that. In my setup, I use port 5554
for federated, and port 5555 for the remote.
Notice the "COMMENT" and "ENGINE" field? This is where you
respectively set the engine type, "FEDERATED" and foreign
host information, this being the database your 'client' database
will connect to and use as the "data file". Obviously, the foreign
database is running on port 9306, so you want to start up your other
database so that it is indeed on port 9306, and your federated
database on a port other than that. In my setup, I use port 5554
for federated, and port 5555 for the foreign database.
Then, on the remote database:
Then, on the foreign database:
CREATE TABLE test_table (
CREATE TABLE test_table (
id int(20) NOT NULL auto_increment,
name varchar(32) NOT NULL default '',
other int(20) NOT NULL default '0',
PRIMARY KEY (id),
KEY name (name),
KEY other_key (other))
KEY other_key (other))
ENGINE="<NAME>" <-- whatever you want, or not specify
DEFAULT CHARSET=latin1 ;
This table is exactly the same (and must be exactly the same),
except that it is not using the federated handler and does
except that it is not using the federated handler and does
not need the URL.
How to see the handler in action
--------------------------------
......@@ -214,17 +214,17 @@
When developing this handler, I compiled the federated database with
debugging:
./configure --with-federated-storage-engine
./configure --with-federated-storage-engine
--prefix=/home/mysql/mysql-build/federated/ --with-debug
Once compiled, I did a 'make install' (not for the purpose of installing
the binary, but to install all the files the binary expects to see in the
diretory I specified in the build with --prefix,
"/home/mysql/mysql-build/federated".
Then, I started the remote server:
diretory I specified in the build with --prefix,
"/home/mysql/mysql-build/federated".
Then, I started the foreign server:
/usr/local/mysql/bin/mysqld_safe
/usr/local/mysql/bin/mysqld_safe
--user=mysql --log=/tmp/mysqld.5555.log -P 5555
Then, I went back to the directory containing the newly compiled mysqld,
......@@ -238,18 +238,18 @@
Next, I open several windows for each:
1. Tail the debug trace: tail -f /tmp/mysqld.trace|grep ha_fed
2. Tail the SQL calls to the remote database: tail -f /tmp/mysqld.5555.log
2. Tail the SQL calls to the foreign database: tail -f /tmp/mysqld.5555.log
3. A window with a client open to the federated server on port 5554
4. A window with a client open to the federated server on port 5555
I would create a table on the client to the remote server on port
I would create a table on the client to the foreign server on port
5555, and then to the federated server on port 5554. At this point,
I would run whatever queries I wanted to on the federated server,
just always remembering that whatever changes I wanted to make on
just always remembering that whatever changes I wanted to make on
the table, or if I created new tables, that I would have to do that
on the remote server.
Another thing to look for is 'show variables' to show you that you have
on the foreign server.
Another thing to look for is 'show variables' to show you that you have
support for federated handler support:
show variables like '%federat%'
......@@ -264,26 +264,26 @@
Testing
-------
There is a test for MySQL Federated Storage Handler in ./mysql-test/t,
There is a test for MySQL Federated Storage Handler in ./mysql-test/t,
federatedd.test It starts both a slave and master database using
the same setup that the replication tests use, with the exception that
it turns off replication, and sets replication to ignore the test tables.
After ensuring that you actually do have support for the federated storage
handler, numerous queries/inserts/updates/deletes are run, many derived
After ensuring that you actually do have support for the federated storage
handler, numerous queries/inserts/updates/deletes are run, many derived
from the MyISAM tests, plus som other tests which were meant to reveal
any issues that would be most likely to affect this handler. All tests
should work! ;)
To run these tests, go into ./mysql-test (based in the directory you
To run these tests, go into ./mysql-test (based in the directory you
built the server in)
./mysql-test-run federatedd
To run the test, or if you want to run the test and have debug info:
./mysql-test-run --debug federated
This will run the test in debug mode, and you can view the trace and
This will run the test in debug mode, and you can view the trace and
log files in the ./mysql-test/var/log directory
ls -l mysql-test/var/log/
......@@ -307,10 +307,10 @@
Of course, again, you can tail the trace log:
tail -f mysql-test/var/log/master.trace |grep ha_fed
tail -f mysql-test/var/log/master.trace |grep ha_fed
As well as the slave query log:
tail -f mysql-test/var/log/slave.log
Files that comprise the test suit
......@@ -324,7 +324,7 @@
Other tidbits
-------------
These were the files that were modified or created for this
These were the files that were modified or created for this
Federated handler to work:
./configure.in
......@@ -342,11 +342,11 @@
./mysql-test/include/have_federated_db.inc
./sql/ha_federated.cc
./sql/ha_federated.h
*/
*/
#ifdef __GNUC__
#pragma implementation // gcc: Class implementation
#pragma implementation // gcc: Class implementation
#endif
#include <mysql_priv.h>
......@@ -355,40 +355,86 @@
#include "ha_federated.h"
#define MAX_REMOTE_SIZE IO_SIZE
/* Variables for federated share methods */
static HASH federated_open_tables; // Hash used to track open tables
pthread_mutex_t federated_mutex; // This is the mutex we use to init the hash
static int federated_init= 0; // Variable for checking the init state of hash
static HASH federated_open_tables; // Hash used to track open
// tables
pthread_mutex_t federated_mutex; // This is the mutex we use to
// init the hash
static int federated_init= FALSE; // Variable for checking the
// init state of hash
/*
Function we use in the creation of our hash to get key.
*/
static byte* federated_get_key(FEDERATED_SHARE *share,uint *length,
my_bool not_used __attribute__((unused)))
/* Function we use in the creation of our hash to get key. */
static byte *federated_get_key(FEDERATED_SHARE *share, uint *length,
my_bool not_used __attribute__ ((unused)))
{
*length= share->table_name_length;
return (byte*) share->table_name;
}
/*
Initialize the federated handler.
SYNOPSIS
federated_db_init()
void
RETURN
FALSE OK
TRUE Error
*/
bool federated_db_init()
{
federated_init= 1;
VOID(pthread_mutex_init(&federated_mutex, MY_MUTEX_INIT_FAST));
return (hash_init(&federated_open_tables, system_charset_info, 32, 0, 0,
(hash_get_key) federated_get_key, 0, 0));
}
/*
Release the federated handler.
SYNOPSIS
federated_db_end()
void
RETURN
FALSE OK
*/
bool federated_db_end()
{
if (federated_init)
{
hash_free(&federated_open_tables);
VOID(pthread_mutex_destroy(&federated_mutex));
}
federated_init= 0;
return FALSE;
}
/*
Parse connection info from table->s->comment
SYNOPSIS
parse_url()
share pointer to FEDERATED share
table pointer to current TABLE class
share pointer to FEDERATED share
table pointer to current TABLE class
table_create_flag determines what error to throw
DESCRIPTION
populates the share with information about the connection
to the remote database that will serve as the data source.
to the foreign database that will serve as the data source.
This string must be specified (currently) in the "comment" field,
listed in the CREATE TABLE statement.
This string MUST be in the format of any of these:
scheme://username:password@hostname:port/database/table
scheme://username@hostname/database/table
scheme://username@hostname:port/database/table
scheme://username:password@hostname/database/table
scheme://username:password@hostname:port/database/table
scheme://username@hostname/database/table
scheme://username@hostname:port/database/table
scheme://username:password@hostname/database/table
An Example:
......@@ -401,32 +447,28 @@ scheme://username:password@hostname/database/table
RETURN VALUE
0 success
-1 failure, wrong string format
1 failure, wrong string format
*/
static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_flag)
static int parse_url(FEDERATED_SHARE *share, TABLE *table,
uint table_create_flag)
{
DBUG_ENTER("ha_federated::parse_url");
// This either get set or will remain the same.
share->port= 0;
uint error_num= table_create_flag ? ER_CANT_CREATE_TABLE : ER_CONNECT_TO_MASTER ;
uint error_num= (table_create_flag ? ER_CANT_CREATE_TABLE :
ER_CONNECT_TO_MASTER);
share->scheme= my_strdup(table->s->comment, MYF(0));
if ((share->username= strstr(share->scheme, "://")))
{
share->scheme[share->username - share->scheme] = '\0';
share->scheme[share->username - share->scheme]= '\0';
if (strcmp(share->scheme, "mysql") != 0)
{
DBUG_PRINT("ha_federated::parse_url",
("The federated handler currently only supports connecting\
to a MySQL database!!!\n"));
my_error(error_num, MYF(0),
"ERROR: federated handler only supports remote 'mysql://' database");
DBUG_RETURN(-1);
}
goto error;
share->username+= 3;
if ((share->hostname= strchr(share->username, '@')))
......@@ -439,35 +481,23 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_fla
share->username[share->password - share->username]= '\0';
share->password++;
share->username= share->username;
// make sure there isn't an extra / or @
/* make sure there isn't an extra / or @ */
if ((strchr(share->password, '/') || strchr(share->hostname, '@')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
}
/*
goto error;
/*
Found that if the string is:
user:@hostname:port/database/table
Then password is a null string, so set to NULL
*/
user:@hostname:port/database/table
Then password is a null string, so set to NULL
*/
if ((share->password[0] == '\0'))
share->password= NULL;
}
else
share->username= share->username;
// make sure there isn't an extra / or @
/* make sure there isn't an extra / or @ */
if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
}
goto error;
if ((share->database= strchr(share->hostname, '/')))
{
......@@ -490,102 +520,112 @@ Then password is a null string, so set to NULL
share->table_base_name++;
}
else
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
}
goto error;
}
else
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
}
// make sure there's not an extra /
goto error;
/* make sure there's not an extra / */
if ((strchr(share->table_base_name, '/')))
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
}
goto error;
if (share->hostname[0] == '\0')
share->hostname= NULL;
DBUG_PRINT("ha_federated::parse_url",
("scheme %s username %s password %s \
hostname %s port %d database %s tablename %s\n",
share->scheme, share->username, share->password, share->hostname,
share->port, share->database, share->table_base_name));
}
else
{
if (!share->port)
{
if (strcmp(share->hostname, my_localhost) == 0)
share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
else
share->port= MYSQL_PORT;
}
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
("scheme %s username %s password %s \
hostname %s port %d database %s tablename %s\n",
share->scheme, share->username, share->password,
share->hostname, share->port, share->database,
share->table_base_name));
}
else
goto error;
}
else
{
DBUG_PRINT("ha_federated::parse_url",
("this connection string is not in the correct format!!!\n"));
my_error(error_num, MYF(0),
"this connection string is not in the correct format!!!\n");
DBUG_RETURN(-1);
}
goto error;
DBUG_RETURN(0);
error:
my_error(error_num, MYF(0),
"this connection string is not in the correct format!\n");
DBUG_RETURN(1);
}
/*
/*
Convert MySQL result set row to handler internal format
SYNOPSIS
convert_row_to_internal_format()
record Byte pointer to record
record Byte pointer to record
row MySQL result set row from fetchrow()
DESCRIPTION
This method simply iterates through a row returned via fetchrow with
This method simply iterates through a row returned via fetchrow with
values from a successful SELECT , and then stores each column's value
in the field object via the field object pointer (pointing to the table's
array of field object pointers). This is how the handler needs the data
array of field object pointers). This is how the handler needs the data
to be stored to then return results back to the user
RETURN VALUE
0 After fields have had field values stored from record
0 After fields have had field values stored from record
*/
uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row)
{
unsigned long len;
int x= 0;
ulong *lengths;
uint num_fields;
uint x= 0;
DBUG_ENTER("ha_federated::convert_row_to_internal_format");
// Question this
memset(record, 0, table->s->null_bytes);
num_fields= mysql_num_fields(result);
lengths= mysql_fetch_lengths(result);
memset(record, 0, table->s->null_bytes);
for (Field **field=table->field; *field ; field++, x++)
for (Field **field= table->field; *field; field++, x++)
{
if (!row[x])
if (!row[x])
(*field)->set_null();
else
/*
changed system_charset_info to default_charset_info because
testing revealed that german text was not being retrieved properly
*/
(*field)->store(row[x], strlen(row[x]), &my_charset_bin);
(*field)->store(row[x], lengths[x], &my_charset_bin);
}
DBUG_RETURN(0);
}
/*
Create a WHERE clause based off of values in keys
Note: This code was inspired by key_copy from key.cc
SYNOPSIS
create_where_from_key ()
to String object to store WHERE clause
key_info KEY struct pointer
key byte pointer containing key
key_length length of key
DESCRIPTION
Using iteration through all the keys via a KEY_PART_INFO pointer,
This method 'extracts' the value of each key in the byte pointer
*key, and for each key found, constructs an appropriate WHERE clause
RETURN VALUE
0 After all keys have been accounted for to create the WHERE clause
1 No keys found
*/
bool ha_federated::create_where_from_key(String *to, KEY *key_info,
const byte *key, uint key_length)
{
......@@ -595,29 +635,28 @@ bool ha_federated::create_where_from_key(String *to, KEY *key_info,
String tmp;
DBUG_ENTER("ha_federated::create_where_from_key");
for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++)
for (key_part= key_info->key_part; (int) key_length > 0; key_part++)
{
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))
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 (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()));
if (to->append("IS NULL", 7))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key",
("NULL type %s", to->c_ptr_quick()));
key_length-= key_part->store_length;
key+= key_part->store_length-1;
key+= key_part->store_length - 1;
continue;
}
key_length--;
......@@ -628,23 +667,24 @@ bool ha_federated::create_where_from_key(String *to, KEY *key_info,
DBUG_RETURN(1);
if (key_part->type == HA_KEYTYPE_BIT)
{
/* This is can be threated as a hex string */
/* This is can be treated as a hex string */
Field_bit *field= (Field_bit *) (key_part->field);
char buff[64+2], *ptr;
byte *end= (byte *)(key) + length;
char buff[64 + 2], *ptr;
byte *end= (byte*)(key)+length;
buff[0]='0';
buff[1]='x';
for (ptr= buff+2 ; key < end ; key++)
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];
uint tmp= (uint)(uchar) *key;
*ptr++= _dig_vec_upper[tmp >> 4];
*ptr++= _dig_vec_upper[tmp & 15];
}
if (to->append(buff, (uint) (ptr-buff)))
if (to->append(buff, (uint)(ptr - buff)))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("bit type %s", to->c_ptr_quick()));
DBUG_PRINT("ha_federated::create_where_from_key",
("bit type %s", to->c_ptr_quick()));
key_length-= length;
continue;
}
......@@ -658,7 +698,8 @@ bool ha_federated::create_where_from_key(String *to, KEY *key_info,
if (append_escaped(to, &tmp))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("blob type %s", to->c_ptr_quick()));
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)
......@@ -669,29 +710,33 @@ bool ha_federated::create_where_from_key(String *to, KEY *key_info,
if (append_escaped(to, &tmp))
DBUG_RETURN(1);
DBUG_PRINT("ha_federated::create_where_from_key", ("varchar type %s", to->c_ptr_quick()));
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"));
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;
res= field->val_str(&str, (char *)(key));
res= field->val_str(&str, (char*) (key));
if (field->result_type() == STRING_RESULT)
{
if (append_escaped(to, res))
DBUG_RETURN(1);
res= field->val_str(&str, (char *)(key));
res= field->val_str(&str, (char*) (key));
DBUG_PRINT("ha_federated::create_where_from_key", ("else block, string type", to->c_ptr_quick()));
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()));
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);
......@@ -699,37 +744,12 @@ bool ha_federated::create_where_from_key(String *to, KEY *key_info,
DBUG_RETURN(1);
}
int load_conn_info(FEDERATED_SHARE *share, TABLE *table)
{
DBUG_ENTER("ha_federated::load_conn_info");
int retcode;
retcode= parse_url(share, table, 0);
if (retcode < 0)
{
DBUG_PRINT("ha_federated::load_conn_info",
("retcode %d, setting defaults", retcode));
/* sanity checks to make sure all needed pieces are present */
if (!share->port)
{
if (strcmp(share->hostname, "localhost") == 0)
share->socket= my_strdup("/tmp/mysql.sock",MYF(0));
else
share->port= 3306;
}
}
DBUG_PRINT("ha_federated::load_conn_info",
("returned from retcode %d", retcode));
DBUG_RETURN(retcode);
}
/*
Example of simple lock controls. The "share" it creates is structure we will
pass to each federated handler. Do you have to have one of these? Well, you
have pieces that are used for locking, and they are needed to function.
*/
static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
{
FEDERATED_SHARE *share;
......@@ -740,79 +760,67 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
uint table_name_length, table_base_name_length;
char *tmp_table_name, *tmp_table_base_name, *table_base_name, *select_query;
// share->table_name has the file location - we want the actual table's
// name!
table_base_name= (char *)table->s->table_name;
DBUG_PRINT("ha_federated::get_share",("table_name %s", table_base_name));
/* share->table_name has the file location - we want the table's name! */
table_base_name= (char*) table->s->table_name;
DBUG_PRINT("ha_federated::get_share", ("table_name %s", table_base_name));
/*
So why does this exist? There is no way currently to init a storage engine.
Innodb and BDB both have modifications to the server to allow them to
do this. Since you will not want to do this, this is probably the next
best method.
*/
if (!federated_init)
{
/* Hijack a mutex for init'ing the storage engine */
pthread_mutex_lock(&LOCK_mysql_create_db);
if (!federated_init)
{
federated_init++;
VOID(pthread_mutex_init(&federated_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&federated_open_tables,system_charset_info,32,0,0,
(hash_get_key) federated_get_key,0,0);
}
pthread_mutex_unlock(&LOCK_mysql_create_db);
}
pthread_mutex_lock(&federated_mutex);
table_name_length= (uint) strlen(table_name);
table_base_name_length= (uint) strlen(table_base_name);
if (!(share= (FEDERATED_SHARE*) hash_search(&federated_open_tables,
(byte*) table_name,
table_name_length)))
if (!(share= (FEDERATED_SHARE *) hash_search(&federated_open_tables,
(byte*) table_name,
table_name_length)))
{
query.set_charset(system_charset_info);
query.append("SELECT * FROM ");
query.append(table_base_name);
if (!(share= (FEDERATED_SHARE *)
my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
&share, sizeof(*share),
&tmp_table_name, table_name_length+1,
&tmp_table_base_name, table_base_name_length+1,
&select_query, query.length()+1,
NullS)))
&tmp_table_name, table_name_length + 1,
&tmp_table_base_name, table_base_name_length + 1,
&select_query, query.length() + 1, NullS)))
{
pthread_mutex_unlock(&federated_mutex);
return NULL;
}
load_conn_info(share, table);
if (parse_url(share, table, 0))
goto error;
share->use_count= 0;
share->table_name_length= table_name_length;
share->table_name= tmp_table_name;
share->table_base_name_length= table_base_name_length;
share->table_base_name= tmp_table_base_name;
share->select_query= select_query;
strmov(share->table_name,table_name);
strmov(share->table_base_name,table_base_name);
strmov(share->select_query,query.c_ptr_quick());
DBUG_PRINT("ha_federated::get_share",("share->select_query %s", share->select_query));
strmov(share->table_name, table_name);
strmov(share->table_base_name, table_base_name);
strmov(share->select_query, query.ptr());
DBUG_PRINT("ha_federated::get_share",
("share->select_query %s", share->select_query));
if (my_hash_insert(&federated_open_tables, (byte*) share))
goto error;
thr_lock_init(&share->lock);
pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
}
share->use_count++;
pthread_mutex_unlock(&federated_mutex);
return share;
error2:
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
error:
pthread_mutex_unlock(&federated_mutex);
if (share->scheme)
my_free((gptr) share->scheme, MYF(0));
VOID(pthread_mutex_destroy(&share->mutex));
my_free((gptr) share, MYF(0));
return NULL;
......@@ -820,18 +828,23 @@ error:
/*
Free lock controls. We call this whenever we close a table.
Free lock controls. We call this whenever we close a table.
If the table had the last reference to the share then we
free memory associated with it.
*/
static int free_share(FEDERATED_SHARE *share)
{
pthread_mutex_lock(&federated_mutex);
if (!--share->use_count)
{
if (share->scheme)
my_free((gptr) share->scheme, MYF(0));
hash_delete(&federated_open_tables, (byte*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
VOID(pthread_mutex_destroy(&share->mutex));
my_free((gptr) share, MYF(0));
}
pthread_mutex_unlock(&federated_mutex);
......@@ -842,12 +855,19 @@ static int free_share(FEDERATED_SHARE *share)
/*
If frm_error() is called then we will use this to to find out
what file extentions exist for the storage engine. This is
also used by the default rename_table and delete_table method
what file extentions exist for the storage engine. This is
also used by the default rename_table and delete_table method
in handler.cc.
*/
const char **ha_federated::bas_ext() const
{ static const char *ext[]= { NullS }; return ext; }
{
static const char *ext[]=
{
NullS
};
return ext;
}
/*
......@@ -860,30 +880,30 @@ const char **ha_federated::bas_ext() const
all tables by calling ha_open() which then calls the handler
specific open().
*/
int ha_federated::open(const char *name, int mode, uint test_if_locked)
{
DBUG_ENTER("ha_federated::open");
int rc;
DBUG_ENTER("ha_federated::open");
if (!(share= get_share(name, table)))
DBUG_RETURN(1);
thr_lock_data_init(&share->lock,&lock,NULL);
/* Connect to remote database mysql_real_connect() */
mysql= mysql_init(0);
DBUG_PRINT("ha_federated::open",("hostname %s", share->hostname));
DBUG_PRINT("ha_federated::open",("username %s", share->username));
DBUG_PRINT("ha_federated::open",("password %s", share->password));
DBUG_PRINT("ha_federated::open",("database %s", share->database));
DBUG_PRINT("ha_federated::open",("port %d", share->port));
thr_lock_data_init(&share->lock, &lock, NULL);
/* Connect to foreign database mysql_real_connect() */
mysql= mysql_init(0);
DBUG_PRINT("ha_federated::open", ("hostname %s", share->hostname));
DBUG_PRINT("ha_federated::open", ("username %s", share->username));
DBUG_PRINT("ha_federated::open", ("password %s", share->password));
DBUG_PRINT("ha_federated::open", ("database %s", share->database));
DBUG_PRINT("ha_federated::open", ("port %d", share->port));
if (!mysql_real_connect(mysql,
share->hostname,
share->username,
share->password,
share->database,
share->port,
NULL,
0))
share->hostname,
share->username,
share->password,
share->database,
share->port,
share->socket, 0))
{
my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_CONNECT_TO_MASTER);
......@@ -902,9 +922,19 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
myisam table.
For sql_base.cc look at close_data_tables().
*/
int ha_federated::close(void)
{
DBUG_ENTER("ha_federated::close");
/* free the result set */
if (result)
{
DBUG_PRINT("ha_federated::close",
("mysql_free_result result at address %lx", result));
mysql_free_result(result);
result= 0;
}
/* Disconnect from mysql */
mysql_close(mysql);
DBUG_RETURN(free_share(share));
......@@ -913,7 +943,7 @@ int ha_federated::close(void)
/*
Checks if a field in a record is SQL NULL.
Checks if a field in a record is SQL NULL.
SYNOPSIS
field_in_record_is_null()
......@@ -923,16 +953,16 @@ int ha_federated::close(void)
DESCRIPTION
This method uses the record format information in table to track
the null bit in record.
the null bit in record.
RETURN VALUE
1 if NULL
0 otherwise
0 otherwise
*/
inline uint field_in_record_is_null (
TABLE* table, /* in: MySQL table object */
Field* field, /* in: MySQL field object */
char* record) /* in: a row in MySQL format */
inline uint field_in_record_is_null(TABLE *table,
Field *field,
char *record)
{
int null_offset;
DBUG_ENTER("ha_federated::field_in_record_is_null");
......@@ -940,7 +970,7 @@ inline uint field_in_record_is_null (
if (!field->null_ptr)
DBUG_RETURN(0);
null_offset= (uint) ((char*) field->null_ptr - (char*) table->record[0]);
null_offset= (uint) ((char*)field->null_ptr - (char*)table->record[0]);
if (record[null_offset] & field->null_bit)
DBUG_RETURN(1);
......@@ -961,59 +991,58 @@ inline uint field_in_record_is_null (
Called from item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc,
sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc.
*/
int ha_federated::write_row(byte * buf)
int ha_federated::write_row(byte *buf)
{
int x= 0, num_fields= 0;
uint x= 0, num_fields= 0;
Field **field;
ulong current_query_id= 1;
ulong tmp_query_id= 1;
int all_fields_have_same_query_id= 1;
uint all_fields_have_same_query_id= 1;
char insert_buffer[IO_SIZE];
char values_buffer[IO_SIZE], insert_field_value_buffer[IO_SIZE];
// The main insert query string
/* The main insert query string */
String insert_string(insert_buffer, sizeof(insert_buffer), &my_charset_bin);
insert_string.length(0);
// The string containing the values to be added to the insert
/* The string containing the values to be added to the insert */
String values_string(values_buffer, sizeof(values_buffer), &my_charset_bin);
values_string.length(0);
// The actual value of the field, to be added to the values_string
/* The actual value of the field, to be added to the values_string */
String insert_field_value_string(insert_field_value_buffer,
sizeof(insert_field_value_buffer), &my_charset_bin);
sizeof(insert_field_value_buffer),
&my_charset_bin);
insert_field_value_string.length(0);
DBUG_ENTER("ha_federated::write_row");
/*
I want to use this and the next line, but the repository needs to be
updated to do so
*/
statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
statistic_increment(table->in_use->status_var.ha_write_count, &LOCK_status);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time();
/*
get the current query id - the fields that we add to the insert
statement to send to the remote will not be appended unless they match
this query id
get the current query id - the fields that we add to the insert
statement to send to the foreign will not be appended unless they match
this query id
*/
current_query_id= table->in_use->query_id;
DBUG_PRINT("ha_federated::write_row", ("current query id %d",
current_query_id));
// start off our string
insert_string.append("INSERT INTO ");
/* start off our string */
insert_string.append("INSERT INTO ");
insert_string.append(share->table_base_name);
// start both our field and field values strings
/* start both our field and field values strings */
insert_string.append(" (");
values_string.append(" VALUES (");
/*
/*
Even if one field is different, all_fields_same_query_id can't remain
0 if it remains 0, then that means no fields were specified in the query
such as in the case of INSERT INTO table VALUES (val1, val2, valN)
*/
for (field= table->field; *field ; field++, x++)
for (field= table->field; *field; field++, x++)
{
if (x > 0 && tmp_query_id != (*field)->query_id)
all_fields_have_same_query_id= 0;
......@@ -1024,15 +1053,15 @@ int ha_federated::write_row(byte * buf)
loop through the field pointer array, add any fields to both the values
list and the fields list that match the current query id
*/
for (field= table->field; *field ; field++, x++)
for (field= table->field; *field; field++, x++)
{
DBUG_PRINT("ha_federated::write_row", ("field type %d", (*field)->type()));
// if there is a query id and if it's equal to the current query id
if ( ((*field)->query_id && (*field)->query_id == current_query_id )
|| all_fields_have_same_query_id)
if (((*field)->query_id && (*field)->query_id == current_query_id)
|| all_fields_have_same_query_id)
{
num_fields++;
if ((*field)->is_null())
{
DBUG_PRINT("ha_federated::write_row",
......@@ -1046,24 +1075,23 @@ int ha_federated::write_row(byte * buf)
("current query id %d field is not null query ID %d",
current_query_id, (*field)->query_id));
(*field)->val_str(&insert_field_value_string);
/* quote these fields if they require it */
(*field)->quote_data(&insert_field_value_string);
}
// append the field name
/* append the field name */
insert_string.append((*field)->field_name);
// quote these fields if they require it
(*field)->quote_data(&insert_field_value_string);
// append the value
/* append the value */
values_string.append(insert_field_value_string);
insert_field_value_string.length(0);
// append commas between both fields and fieldnames
/* 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()));
}
}
......@@ -1072,38 +1100,35 @@ int ha_federated::write_row(byte * buf)
chop of the trailing comma, or if there were no fields, a '('
So, "INSERT INTO foo (" becomes "INSERT INTO foo "
or, with fields, "INSERT INTO foo (field1, field2," becomes
"INSERT INTO foo (field1, field2"
"INSERT INTO foo (field1, field2"
*/
insert_string.chop();
/*
if there were no fields, we don't want to add a closing paren
AND, we don't want to chop off the last char '('
insert will be "INSERT INTO t1 VALUES ();"
*/
DBUG_PRINT("ha_federated::write_row",("x %d num fields %d",
x, num_fields));
DBUG_PRINT("ha_federated::write_row", ("x %d num fields %d", x, num_fields));
if (num_fields > 0)
{
// chops off leading commas
/* chops off leading commas */
values_string.chop();
insert_string.append(')');
}
// we always want to append this, even if there aren't any fields
/* we always want to append this, even if there aren't any fields */
values_string.append(')');
// add the values
/* add the values */
insert_string.append(values_string);
DBUG_PRINT("ha_federated::write_row",("insert query %s",
insert_string.c_ptr_quick()));
DBUG_PRINT("ha_federated::write_row", ("insert query %s",
insert_string.c_ptr_quick()));
if (mysql_real_query(mysql, insert_string.c_ptr_quick(),
insert_string.length()))
if (mysql_real_query(mysql, insert_string.ptr(), insert_string.length()))
{
my_error(ER_QUERY_ON_MASTER,MYF(0),mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
my_error(ER_QUERY_ON_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
DBUG_RETURN(0);
......@@ -1125,54 +1150,54 @@ int ha_federated::write_row(byte * buf)
Called from sql_select.cc, sql_acl.cc, sql_update.cc, and sql_insert.cc.
*/
int ha_federated::update_row(
const byte * old_data,
byte * new_data
)
int ha_federated::update_row(const byte *old_data, byte *new_data)
{
int x= 0;
uint x= 0;
uint has_a_primary_key= 0;
int primary_key_field_num;
uint 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];
// stores the value to be replaced of the field were are updating
String old_field_value(old_field_value_buffer, sizeof(old_field_value_buffer), &my_charset_bin);
/* stores the value to be replaced of the field were are updating */
String old_field_value(old_field_value_buffer, sizeof(old_field_value_buffer),
&my_charset_bin);
old_field_value.length(0);
// stores the new value of the field
String new_field_value(new_field_value_buffer, sizeof(new_field_value_buffer), &my_charset_bin);
/* stores the new value of the field */
String new_field_value(new_field_value_buffer, sizeof(new_field_value_buffer),
&my_charset_bin);
new_field_value.length(0);
// stores the update query
/* stores the update query */
String update_string(update_buffer, sizeof(update_buffer), &my_charset_bin);
update_string.length(0);
// stores the WHERE clause
/* stores the WHERE clause */
String where_string(where_buffer, sizeof(where_buffer), &my_charset_bin);
where_string.length(0);
DBUG_ENTER("ha_federated::update_row");
has_a_primary_key= table->s->primary_key == 0 ? 1 : 0;
primary_key_field_num= has_a_primary_key ?
table->key_info[table->s->primary_key].key_part->fieldnr -1 : -1;
has_a_primary_key= (table->s->primary_key == 0 ? 1 : 0);
primary_key_field_num= has_a_primary_key ?
table->key_info[table->s->primary_key].key_part->fieldnr - 1 : -1;
if (has_a_primary_key)
DBUG_PRINT("ha_federated::update_row", ("has a primary key"));
DBUG_PRINT("ha_federated::update_row", ("has a primary key"));
update_string.append("UPDATE ");
update_string.append(share->table_base_name);
update_string.append(" SET ");
/*
In this loop, we want to match column names to values being inserted
(while building INSERT statement).
In this loop, we want to match column names to values being inserted
(while building INSERT statement).
Iterate through table->field (new data) and share->old_filed (old_data)
using the same index to created an SQL UPDATE statement, new data is
used to create SET field=value and old data is used to create WHERE
field=oldvalue
Iterate through table->field (new data) and share->old_filed (old_data)
using the same index to created an SQL UPDATE statement, new data is
used to create SET field=value and old data is used to create WHERE
field=oldvalue
*/
for (Field **field= table->field ; *field ; field++, x++)
for (Field **field= table->field; *field; field++, x++)
{
/*
In all of these tests for 'has_a_primary_key', what I'm trying to
......@@ -1181,9 +1206,9 @@ int ha_federated::update_row(
in which case we have to use all the fields to create a WHERE clause
using the old/current values, as well as adding a LIMIT statement
*/
if (has_a_primary_key)
if (has_a_primary_key)
{
if (x == primary_key_field_num)
if (x == primary_key_field_num)
where_string.append((*field)->field_name);
}
else
......@@ -1196,65 +1221,63 @@ int ha_federated::update_row(
new_field_value.append("NULL");
else
{
// otherwise =
/* otherwise = */
(*field)->val_str(&new_field_value);
(*field)->quote_data(&new_field_value);
if ( has_a_primary_key )
if (has_a_primary_key)
{
if (x == primary_key_field_num)
where_string.append("=");
}
else
if (! field_in_record_is_null(table, *field, (char*) old_data))
where_string.append("=");
else if (!field_in_record_is_null(table, *field, (char*) old_data))
where_string.append("=");
}
if ( has_a_primary_key)
if (has_a_primary_key)
{
if (x == primary_key_field_num)
{
(*field)->val_str(&old_field_value,
(char *)(old_data + (*field)->offset()));
(char*) (old_data + (*field)->offset()));
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
}
else
{
if (field_in_record_is_null(table, *field, (char*) old_data))
where_string.append(" IS NULL ");
else
{
(*field)->val_str(&old_field_value,
(char *)(old_data + (*field)->offset()));
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
if (field_in_record_is_null(table, *field, (char*) old_data))
where_string.append(" IS NULL ");
else
{
(*field)->val_str(&old_field_value,
(char*) (old_data + (*field)->offset()));
(*field)->quote_data(&old_field_value);
where_string.append(old_field_value);
}
}
update_string.append(new_field_value);
new_field_value.length(0);
if ((uint) x+1 < table->s->fields)
if (x + 1 < table->s->fields)
{
update_string.append(", ");
if (! has_a_primary_key)
if (!has_a_primary_key)
where_string.append(" AND ");
}
old_field_value.length(0);
}
update_string.append(" WHERE ");
update_string.append(where_string.c_ptr_quick());
update_string.append(where_string);
if (! has_a_primary_key)
update_string.append(" LIMIT 1");
DBUG_PRINT("ha_federated::update_row", ("Final update query: %s",
update_string.c_ptr_quick()));
if (mysql_real_query(mysql, update_string.c_ptr_quick(),
update_string.length()))
if (mysql_real_query(mysql, update_string.ptr(), update_string.length()))
{
my_error(ER_QUERY_ON_MASTER,MYF(0),mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
my_error(ER_QUERY_ON_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
......@@ -1271,13 +1294,14 @@ int ha_federated::update_row(
ORDER BY clauses can be used.
Called in sql_acl.cc and sql_udf.cc to manage internal table information.
Called in sql_delete.cc, sql_insert.cc, and sql_select.cc. In sql_select
Called in sql_delete.cc, sql_insert.cc, and sql_select.cc. In sql_select
it is used for removing duplicates while in insert it is used for REPLACE
calls.
*/
int ha_federated::delete_row(const byte * buf)
int ha_federated::delete_row(const byte *buf)
{
int x= 0;
uint x= 0;
char delete_buffer[IO_SIZE];
char data_buffer[IO_SIZE];
......@@ -1292,7 +1316,7 @@ int ha_federated::delete_row(const byte * buf)
delete_string.append(share->table_base_name);
delete_string.append(" WHERE ");
for (Field **field= table->field; *field; field++, x++)
for (Field **field= table->field; *field; field++, x++)
{
delete_string.append((*field)->field_name);
......@@ -1307,22 +1331,21 @@ int ha_federated::delete_row(const byte * buf)
(*field)->val_str(&data_string);
(*field)->quote_data(&data_string);
}
delete_string.append(data_string);
data_string.length(0);
if ((uint) x+1 < table->s->fields)
if (x + 1 < table->s->fields)
delete_string.append(" AND ");
}
delete_string.append(" LIMIT 1");
DBUG_PRINT("ha_federated::delete_row",
("Delete sql: %s", delete_string.c_ptr_quick()));
if ( mysql_real_query(mysql, delete_string.c_ptr_quick(),
delete_string.length()))
if (mysql_real_query(mysql, delete_string.ptr(), delete_string.length()))
{
my_error(ER_QUERY_ON_MASTER,MYF(0),mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
my_error(ER_QUERY_ON_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
DBUG_RETURN(0);
......@@ -1335,10 +1358,11 @@ int ha_federated::delete_row(const byte * buf)
index. This method, which is called in the case of an SQL statement having
a WHERE clause on a non-primary key index, simply calls index_read_idx.
*/
int ha_federated::index_read(byte * buf, const byte * key,
uint key_len __attribute__((unused)),
enum ha_rkey_function find_flag
__attribute__((unused)))
int ha_federated::index_read(byte *buf, const byte *key,
uint key_len __attribute__ ((unused)),
enum ha_rkey_function find_flag
__attribute__ ((unused)))
{
DBUG_ENTER("ha_federated::index_read");
DBUG_RETURN(index_read_idx(buf, active_index, key, key_len, find_flag));
......@@ -1350,13 +1374,14 @@ int ha_federated::index_read(byte * buf, const byte * key,
row if any. This is only used to read whole keys.
This method is called via index_read in the case of a WHERE clause using
a regular non-primary key index, OR is called DIRECTLY when the WHERE clause
a regular non-primary key index, OR is called DIRECTLY when the WHERE clause
uses a PRIMARY KEY index.
*/
int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
uint key_len __attribute__((unused)),
enum ha_rkey_function find_flag
__attribute__((unused)))
int ha_federated::index_read_idx(byte *buf, uint index, const byte *key,
uint key_len __attribute__ ((unused)),
enum ha_rkey_function find_flag
__attribute__ ((unused)))
{
char index_value[IO_SIZE];
char key_value[IO_SIZE];
......@@ -1370,27 +1395,34 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
sql_query.length(0);
DBUG_ENTER("ha_federated::index_read_idx");
statistic_increment(table->in_use->status_var.ha_read_key_count,&LOCK_status);
statistic_increment(table->in_use->status_var.ha_read_key_count,
&LOCK_status);
sql_query.append(share->select_query);
sql_query.append(" WHERE ");
keylen= strlen((char *)(key));
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",
("current key %d key value %s index_string value %s length %d", index, (char *)(key),index_string.c_ptr_quick(),
index_string.length()));
("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()));
("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()))
if (result)
{
mysql_free_result(result);
result= 0;
}
if (mysql_real_query(mysql, sql_query.ptr(), sql_query.length()))
{
my_error(ER_QUERY_ON_MASTER,MYF(0),mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
my_error(ER_QUERY_ON_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
result= mysql_store_result(mysql);
......@@ -1403,15 +1435,13 @@ int ha_federated::index_read_idx(byte * buf, uint index, const byte * key,
if (mysql_errno(mysql))
{
table->status= STATUS_NOT_FOUND;
DBUG_RETURN(mysql_errno(mysql));
DBUG_RETURN(mysql_errno(mysql));
}
DBUG_RETURN(rnd_next(buf));
}
/*
Initialized at each key walk (called multiple times unlike ::rnd_init())
*/
/* Initialized at each key walk (called multiple times unlike rnd_init()) */
int ha_federated::index_init(uint keynr)
{
int error;
......@@ -1422,10 +1452,8 @@ int ha_federated::index_init(uint keynr)
DBUG_RETURN(0);
}
/*
Used to read forward through the index.
*/
int ha_federated::index_next(byte * buf)
/* Used to read forward through the index. */
int ha_federated::index_next(byte *buf)
{
DBUG_ENTER("ha_federated::index_next");
DBUG_RETURN(rnd_next(buf));
......@@ -1444,28 +1472,84 @@ int ha_federated::index_next(byte * buf)
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc,
sql_table.cc, and sql_update.cc.
*/
int ha_federated::rnd_init(bool scan)
{
DBUG_ENTER("ha_federated::rnd_init");
int num_fields, rows;
DBUG_PRINT("ha_federated::rnd_init",
("share->select_query %s", share->select_query));
if (mysql_real_query(mysql, share->select_query, strlen(share->select_query)))
/*
This 'scan' flag is incredibly important for this handler to work
properly, especially with updates containing WHERE clauses using
indexed columns.
When the initial query contains a WHERE clause of the query using an
indexed column, it's index_read_idx that selects the exact record from
the foreign database.
When there is NO index in the query, either due to not having a WHERE
clause, or the WHERE clause is using columns that are not indexed, a
'full table scan' done by rnd_init, which in this situation simply means
a 'select * from ...' on the foreign table.
In other words, this 'scan' flag gives us the means to ensure that if
there is an index involved in the query, we want index_read_idx to
retrieve the exact record (scan flag is 0), and do not want rnd_init
to do a 'full table scan' and wipe out that result set.
Prior to using this flag, the problem was most apparent with updates.
An initial query like 'UPDATE tablename SET anything = whatever WHERE
indexedcol = someval', index_read_idx would get called, using a query
constructed with a WHERE clause built from the values of index ('indexcol'
in this case, having a value of 'someval'). mysql_store_result would
then get called (this would be the result set we want to use).
After this rnd_init (from sql_update.cc) would be called, it would then
unecessarily call "select * from table" on the foreign table, then call
mysql_store_result, which would wipe out the correct previous result set
from the previous call of index_read_idx's that had the result set
containing the correct record, hence update the wrong row!
*/
scan_flag= scan;
if (scan)
{
my_error(ER_QUERY_ON_MASTER,MYF(0),mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
result= mysql_store_result(mysql);
DBUG_PRINT("ha_federated::rnd_init",
("share->select_query %s", share->select_query));
if (result)
{
DBUG_PRINT("ha_federated::rnd_init",
("mysql_free_result address %lx", result));
mysql_free_result(result);
result= 0;
}
if (mysql_errno(mysql))
DBUG_RETURN(mysql_errno(mysql));
if (mysql_real_query
(mysql, share->select_query, strlen(share->select_query)))
{
my_error(ER_QUERY_ON_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
result= mysql_store_result(mysql);
if (mysql_errno(mysql))
DBUG_RETURN(mysql_errno(mysql));
}
DBUG_RETURN(0);
}
int ha_federated::rnd_end()
{
DBUG_ENTER("ha_federated::rnd_end");
if (result)
{
DBUG_PRINT("ha_federated::index_end",
("mysql_free_result address %lx", result));
mysql_free_result(result);
result= 0;
}
mysql_free_result(result);
DBUG_RETURN(index_end());
}
......@@ -1486,17 +1570,20 @@ int ha_federated::index_end(void)
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc,
sql_table.cc, and sql_update.cc.
*/
int ha_federated::rnd_next(byte *buf)
{
MYSQL_ROW row;
DBUG_ENTER("ha_federated::rnd_next");
// Fetch a row, insert it back in a row format.
/* Fetch a row, insert it back in a row format. */
current_position= result->data_cursor;
if (! (row= mysql_fetch_row(result)))
DBUG_PRINT("ha_federated::rnd_next",
("current position %d", current_position));
if (!(row= mysql_fetch_row(result)))
DBUG_RETURN(HA_ERR_END_OF_FILE);
DBUG_RETURN(convert_row_to_internal_format(buf,row));
DBUG_RETURN(convert_row_to_internal_format(buf, row));
}
......@@ -1513,11 +1600,12 @@ int ha_federated::rnd_next(byte *buf)
Called from filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc.
*/
void ha_federated::position(const byte *record)
{
DBUG_ENTER("ha_federated::position");
//my_store_ptr Add seek storage
*(MYSQL_ROW_OFFSET *)ref=current_position; // ref is always aligned
/* my_store_ptr Add seek storage */
*(MYSQL_ROW_OFFSET *) ref= current_position; // ref is always aligned
DBUG_VOID_RETURN;
}
......@@ -1532,14 +1620,25 @@ void ha_federated::position(const byte *record)
Called from filesort.cc records.cc sql_insert.cc sql_select.cc sql_update.cc.
*/
int ha_federated::rnd_pos(byte * buf, byte *pos)
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_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));
/*
we do not need to do any of this if there has been a scan performed
already, or if this is an update and index_read_idx already has a result
set in which to build it's update query from
*/
if (scan_flag)
{
statistic_increment(table->in_use->status_var.ha_read_rnd_count,
&LOCK_status);
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));
}
DBUG_RETURN(0);
}
......@@ -1586,11 +1685,12 @@ int ha_federated::rnd_pos(byte * buf, byte *pos)
sql_update.cc
*/
// FIX: later version provide better information to the optimizer
/* FIX: later version provide better information to the optimizer */
void ha_federated::info(uint flag)
{
DBUG_ENTER("ha_federated::info");
records= 10000; // Fake!
records= 10000; // fix later
DBUG_VOID_RETURN;
}
......@@ -1606,6 +1706,7 @@ void ha_federated::info(uint flag)
Called from sql_select.cc by JOIN::reinit().
Called from sql_union.cc by st_select_lex_unit::exec().
*/
int ha_federated::delete_all_rows()
{
DBUG_ENTER("ha_federated::delete_all_rows");
......@@ -1618,9 +1719,10 @@ int ha_federated::delete_all_rows()
query.append("TRUNCATE ");
query.append(share->table_base_name);
if (mysql_real_query(mysql, query.c_ptr_quick(), query.length())) {
my_error(ER_QUERY_ON_MASTER,MYF(0),mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
if (mysql_real_query(mysql, query.ptr(), query.length()))
{
my_error(ER_QUERY_ON_MASTER, MYF(0), mysql_error(mysql));
DBUG_RETURN(ER_QUERY_ON_MASTER);
}
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
......@@ -1656,33 +1758,33 @@ int ha_federated::delete_all_rows()
Called from lock.cc by get_lock_data().
*/
THR_LOCK_DATA **ha_federated::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
{
/*
/*
Here is where we get into the guts of a row level lock.
If TL_UNLOCK is set
If TL_UNLOCK is set
If we are not doing a LOCK TABLE or DISCARD/IMPORT
TABLESPACE, then allow multiple writers
TABLESPACE, then allow multiple writers
*/
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
lock_type <= TL_WRITE) && !thd->in_lock_tables
&& !thd->tablespace_op)
lock_type <= TL_WRITE) && !thd->in_lock_tables && !thd->tablespace_op)
lock_type= TL_WRITE_ALLOW_WRITE;
/*
/*
In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
MySQL would use the lock TL_READ_NO_INSERT on t2, and that
would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
to t2. Convert the lock to a normal read lock to allow
concurrent inserts to t2.
concurrent inserts to t2.
*/
if (lock_type == TL_READ_NO_INSERT && !thd->in_lock_tables)
if (lock_type == TL_READ_NO_INSERT && !thd->in_lock_tables)
lock_type= TL_READ;
lock.type= lock_type;
......@@ -1695,23 +1797,20 @@ THR_LOCK_DATA **ha_federated::store_lock(THD *thd,
/*
create() does nothing, since we have no local setup of our own.
FUTURE: We should potentially connect to the remote database and
create tables if they do not exist.
FUTURE: We should potentially connect to the foreign database and
*/
int ha_federated::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info)
HA_CREATE_INFO *create_info)
{
int retcode;
FEDERATED_SHARE tmp;
DBUG_ENTER("ha_federated::create");
retcode= parse_url(&tmp, table_arg, 1);
if (retcode < 0)
if (parse_url(&tmp, table_arg, 1))
{
DBUG_PRINT("ha_federated::create",
("ERROR: on table creation for %s called parse_url, retcode %d",
create_info->data_file_name, retcode));
my_error(ER_CANT_CREATE_TABLE, MYF(0));
DBUG_RETURN(ER_CANT_CREATE_TABLE);
}
my_free((gptr) tmp.scheme, MYF(0));
DBUG_RETURN(0);
}
#endif /* HAVE_FEDERATED_DB */
......@@ -32,13 +32,16 @@
FEDERATED_SHARE is a structure that will be shared amoung all open handlers
The example implements the minimum of what you will probably need.
*/
//FIX document
typedef struct st_federated_share {
char *table_name;
char *table_base_name;
// the primary select query to be used in rnd_init
/*
the primary select query to be used in rnd_init
*/
char *select_query;
// remote host info, parse_url supplies
/*
remote host info, parse_url supplies
*/
char *scheme;
char *hostname;
char *username;
......@@ -62,6 +65,7 @@ class ha_federated: public handler
FEDERATED_SHARE *share; /* Shared lock info */
MYSQL *mysql;
MYSQL_RES *result;
bool scan_flag;
uint ref_length;
uint fetch_num; // stores the fetch num
MYSQL_ROW_OFFSET current_position; // Current position used by ::position()
......@@ -72,11 +76,12 @@ private:
return errorcode otherwise
*/
uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row);
bool create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length);
bool create_where_from_key(String *to, KEY *key_info,
const byte *key, uint key_length);
public:
ha_federated(TABLE *table): handler(table),
mysql(0),
mysql(0), result(0), scan_flag(0),
ref_length(sizeof(MYSQL_ROW_OFFSET)), current_position(0)
{
}
......@@ -100,9 +105,9 @@ public:
*/
ulong table_flags() const
{
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_CAN_INDEX_BLOBS);
return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED |
HA_AUTO_PART_KEY | HA_CAN_INDEX_BLOBS);
}
/*
This is a bitmap of flags that says how the storage engine
......@@ -126,11 +131,16 @@ public:
/*
Called in test_quick_select to determine if indexes should be used.
*/
virtual double scan_time() { DBUG_PRINT("ha_federated::scan_time", ("rows %d", records)); return (double)(records*2); }
virtual double scan_time()
{
DBUG_PRINT("ha_federated::scan_time",
("rows %d", records)); return (double)(records*2);
}
/*
The next method will never be called if you do not implement indexes.
*/
virtual double read_time(uint index, uint ranges, 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.
......@@ -173,3 +183,6 @@ public:
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type); //required
};
bool federated_db_init(void);
bool federated_db_end(void);
......@@ -395,6 +395,16 @@ int ha_init()
ha_was_inited_ok(ht++);
}
#endif
#ifdef HAVE_FEDERATED_DB
if (have_federated_db == SHOW_OPTION_YES)
{
if (federated_db_init())
{
have_federated_db= SHOW_OPTION_DISABLED;
error= 1;
}
}
#endif
#ifdef HAVE_ARCHIVE_DB
if (have_archive_db == SHOW_OPTION_YES)
{
......@@ -441,6 +451,10 @@ int ha_panic(enum ha_panic_function flag)
if (have_ndbcluster == SHOW_OPTION_YES)
error|=ndbcluster_end();
#endif
#ifdef HAVE_FEDERATED_DB
if (have_federated_db == SHOW_OPTION_YES)
error|= federated_db_end();
#endif
#ifdef HAVE_ARCHIVE_DB
if (have_archive_db == SHOW_OPTION_YES)
error|= archive_db_end();
......
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