diff options
-rw-r--r-- | BitKeeper/etc/logging_ok | 1 | ||||
-rw-r--r-- | mysql-test/r/federated.result | 95 | ||||
-rw-r--r-- | mysql-test/t/federated.test | 65 | ||||
-rw-r--r-- | sql/ha_federated.cc | 6 |
4 files changed, 163 insertions, 4 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index d8d16aaa1d8..3230f3c119f 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -205,6 +205,7 @@ patg@krsna. patg@krsna.patg.net patg@patrick-galbraiths-computer.local patg@pc248.lfp.kcls.org +patg@radha.local paul@central.snake.net paul@frost.snake.net paul@ice.local diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index 6c815e94b7c..d9c86a89c75 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -906,9 +906,100 @@ 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); +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; +name country_id other country +Kumar 1 11111 India +Lenz 2 22222 Germany +Marizio 3 33333 Italy +Monty 4 33333 Finland +Sanja 5 33333 Ukraine +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; +name country_id other country +Kumar 1 11111 India +Lenz 2 22222 Germany +Marizio 3 33333 Italy +Monty 4 33333 Finland +Sanja 5 33333 Ukraine +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 Using where +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; +name country_id other country +Monty 4 33333 Finland +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort +1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY 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 +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort +1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; +id country_id name other country +4 4 Monty 33333 Finland +2 2 Lenz 22222 Germany +1 1 Kumar 11111 India +3 3 Marizio 33333 Italy +5 5 Sanja 33333 Ukraine +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 SELECT federated.t1.*, federated.countries.country -FROM federated.t1 left join federated.countries -ON federated.t1.country_id = federated.countries.id; +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; id country_id name other country 1 1 Kumar 11111 India 2 2 Lenz 22222 Germany diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index 6a0e0bdac79..1e33efe1c0e 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -861,9 +861,70 @@ 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); +#inner join +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; + +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; + +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; + +#left join +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; + +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; + +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; + +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; + +#right join +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; + SELECT federated.t1.*, federated.countries.country -FROM federated.t1 left join federated.countries -ON federated.t1.country_id = federated.countries.id; +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; DROP TABLE federated.countries; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 8cb6dcb7285..c76034c7986 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1526,6 +1526,12 @@ int ha_federated::index_read_idx(byte *buf, uint index, const byte *key, table->status= STATUS_NOT_FOUND; DBUG_RETURN(mysql_errno(mysql)); } + /* + This basically says that the record in table->record[0] is legal, and that it is + ok to use this record, for whatever reason, such as with a join (without it, joins + will not work) + */ + table->status=0; DBUG_RETURN(rnd_next(buf)); } |