mariadb/mysql-test/suite/federated
Venkata Sidagam aef1982be0 Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE
Problem description:
Table 't' created with two colums having compound index on both the 
columns under innodb/myisam engine at remote machine. In the local 
machine same table is created undet the federated engine.
A select having where clause with along 'AND' operation gives wrong 
results on local machine.

Analysis: 
The given query at federated engine is wrongly transformed by 
federated::create_where_from_key() function and the same was sent to 
the remote machine. Hence the local machine is showing wrong results.

Given query "select c1 from t where c1 <= 2 and c2 = 1;"
Query transformed, after ha_federated::create_where_from_key() function is:
SELECT `c1`, `c2` FROM `t` WHERE  (`c1` IS NOT NULL ) AND 
( (`c1` >= 2)  AND  (`c2` <= 1) ) and the same sent to real_query().
In the above the '<=' and '=' conditions were transformed to '>=' and 
'<=' respectively.

ha_federated::create_where_from_key() function behaving as below:
The key_range is having both the start_key and end_key. The start_key 
is used to get "(`c1` IS NOT NULL )" part of the where clause, this 
transformation is correct. The end_key is used to get "( (`c1` >= 2) 
AND  (`c2` <= 1) )", which is wrong, here the given conditions('<=' and '=') 
are changed as wrong conditions('>=' and '<=').
The end_key is having {key = 0x39fa6d0 "", length = 10, keypart_map = 3, 
flag = HA_READ_AFTER_KEY}

The store_length is having value '5'. Based on store_length and length 
values the condition values is applied in HA_READ_AFTER_KEY switch case.
The switch case 'HA_READ_AFTER_KEY' is applicable to only the last part of 
the end_key and for previous parts it is going to 'HA_READ_KEY_OR_NEXT' case, 
here the '>=' is getting added as a condition instead of '<='.

Fix:
Updated the 'if' condition in 'HA_READ_AFTER_KEY' case to affect for all 
parts of the end_key. i.e 'i > 0' will used for end_key, Hence added it in 
the if condition.


mysql-test/suite/federated/federated.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_archive.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_bug_13118.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_bug_25714.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_bug_35333.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_debug.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_innodb.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_server.test:
  modified the federated.inc file location
mysql-test/suite/federated/federated_transactions.test:
  modified the federated.inc file location
mysql-test/suite/federated/include/federated.inc:
  moved the file from federated suite to federated/include folder
mysql-test/suite/federated/include/federated_cleanup.inc:
  moved the file from federated suite to federated/include folder
mysql-test/suite/federated/include/have_federated_db.inc:
  moved the file from federated suite to federated/include folder
storage/federated/ha_federated.cc:
  updated the 'if condition' in ha_federated::create_where_from_key() 
  function.
2012-07-26 15:09:22 +05:30
..
include Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
disabled.def Changed to Oracle bug numbers 2011-05-24 12:08:13 +05:30
federated.result Fix for bug#32426: "FEDERATED query returns corrupt results 2010-03-05 14:51:37 +04:00
federated.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_archive.result fixed system_mysql_db_fix30020 test faiilure 2009-02-02 13:36:03 +02:00
federated_archive.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_bug_13118.result fixed system_mysql_db_fix30020 test faiilure 2009-02-02 13:36:03 +02:00
federated_bug_13118.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_bug_25714.result fixed system_mysql_db_fix30020 test faiilure 2009-02-02 13:36:03 +02:00
federated_bug_25714.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_bug_35333.result Bug#35333, "If Federated table can't connect to remote host, can't retrieve 2010-11-29 22:46:43 -06:00
federated_bug_35333.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_debug-master.opt Manual merge. 2009-09-30 19:25:06 -03:00
federated_debug.result Manual merge. 2009-09-30 19:25:06 -03:00
federated_debug.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_innodb-slave.opt WL#4189 2007-12-12 18:19:24 +01:00
federated_innodb.result fixed system_mysql_db_fix30020 test faiilure 2009-02-02 13:36:03 +02:00
federated_innodb.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_plugin-master.opt Bug #11750417 40942: UNABLE TO INSTALL FEDERATED PLUGIN 2011-09-05 14:38:20 +02:00
federated_plugin.result Bug #11750417 40942: UNABLE TO INSTALL FEDERATED PLUGIN 2011-09-05 14:38:20 +02:00
federated_plugin.test Test federated_plugin must have ps-protocol off 2011-09-15 12:20:43 +02:00
federated_server.result Bug#12872803 - 62154: FEDERATED.FEDERATED_SERVER TEST FAILS WITH RUN --REPEAT=2 2012-01-06 16:28:24 +05:30
federated_server.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
federated_transactions-slave.opt WL#4189 2007-12-12 18:19:24 +01:00
federated_transactions.result WL#4189 2007-12-12 18:19:24 +01:00
federated_transactions.test Bug #12876932 - INCORRECT SELECT RESULT ON FEDERATED TABLE 2012-07-26 15:09:22 +05:30
my.cnf Manual merge. 2009-09-30 19:25:06 -03:00