Commit 8ecceaf2 authored by unknown's avatar unknown

Merge mysql.com:/home/svoj/devel/mysql/BUG33946/mysql-5.0-engines

into  mysql.com:/home/svoj/devel/mysql/BUG33946/mysql-5.1-engines


mysql-test/r/federated.result:
  Manual merge.
mysql-test/t/federated.test:
  Manual merge.
storage/federated/ha_federated.cc:
  Manual merge.
parents b8f4976d 55f6727b
...@@ -2066,6 +2066,30 @@ select 1 from t1 order by a; ...@@ -2066,6 +2066,30 @@ select 1 from t1 order by a;
drop table t1; drop table t1;
drop table t1; drop table t1;
drop view v1; drop view v1;
CREATE TABLE t1 (a INT, b INT, KEY(a,b));
INSERT INTO t1 VALUES(NULL,1),(1,NULL),(NULL,NULL),(1,1),(2,2);
CREATE TABLE t1 (a INT, b INT, KEY(a,b)) ENGINE=federated
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
SELECT * FROM t1 WHERE a IS NULL;
a b
NULL NULL
NULL 1
SELECT * FROM t1 WHERE a IS NOT NULL;
a b
1 NULL
1 1
2 2
SELECT * FROM t1 WHERE a=1 AND b=1;
a b
1 1
SELECT * FROM t1 WHERE a IS NULL AND b=1;
a b
NULL 1
SELECT * FROM t1 WHERE a IS NOT NULL AND b=1;
a b
1 1
DROP TABLE t1;
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
......
...@@ -1794,5 +1794,27 @@ connection slave; ...@@ -1794,5 +1794,27 @@ connection slave;
drop table t1; drop table t1;
drop view v1; drop view v1;
#
# BUG#33946 - Join on Federated tables with Unique index gives error 1430
# from storage engine
#
connection slave;
CREATE TABLE t1 (a INT, b INT, KEY(a,b));
INSERT INTO t1 VALUES(NULL,1),(1,NULL),(NULL,NULL),(1,1),(2,2);
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE t1 (a INT, b INT, KEY(a,b)) ENGINE=federated
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
SELECT * FROM t1 WHERE a IS NULL;
SELECT * FROM t1 WHERE a IS NOT NULL;
SELECT * FROM t1 WHERE a=1 AND b=1;
SELECT * FROM t1 WHERE a IS NULL AND b=1;
SELECT * FROM t1 WHERE a IS NOT NULL AND b=1;
DROP TABLE t1;
connection slave;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
source include/federated_cleanup.inc; source include/federated_cleanup.inc;
...@@ -1292,10 +1292,21 @@ bool ha_federated::create_where_from_key(String *to, ...@@ -1292,10 +1292,21 @@ bool ha_federated::create_where_from_key(String *to,
{ {
if (*ptr++) if (*ptr++)
{ {
/*
We got "IS [NOT] NULL" condition against nullable column. We
distinguish between "IS NOT NULL" and "IS NULL" by flag. For
"IS NULL", flag is set to HA_READ_KEY_EXACT.
*/
if (emit_key_part_name(&tmp, key_part) || if (emit_key_part_name(&tmp, key_part) ||
tmp.append(STRING_WITH_LEN(" IS NULL "))) tmp.append(ranges[i]->flag == HA_READ_KEY_EXACT ?
STRING_WITH_LEN(" IS NULL ") :
STRING_WITH_LEN(" IS NOT NULL ")))
goto err; goto err;
continue; /*
We need to adjust pointer and length to be prepared for next
key part. As well as check if this was last key part.
*/
goto prepare_for_next_key_part;
} }
} }
...@@ -1403,12 +1414,18 @@ bool ha_federated::create_where_from_key(String *to, ...@@ -1403,12 +1414,18 @@ bool ha_federated::create_where_from_key(String *to,
if (tmp.append(STRING_WITH_LEN(") "))) if (tmp.append(STRING_WITH_LEN(") ")))
goto err; goto err;
prepare_for_next_key_part:
if (store_length >= length) if (store_length >= length)
break; break;
DBUG_PRINT("info", ("remainder %d", remainder)); DBUG_PRINT("info", ("remainder %d", remainder));
DBUG_ASSERT(remainder > 1); DBUG_ASSERT(remainder > 1);
length-= store_length; length-= store_length;
ptr+= store_length; /*
For nullable columns, null-byte is already skipped before, that is
ptr was incremented by 1. Since store_length still counts null-byte,
we need to subtract 1 from store_length.
*/
ptr+= store_length - test(key_part->null_bit);
if (tmp.append(STRING_WITH_LEN(" AND "))) if (tmp.append(STRING_WITH_LEN(" AND ")))
goto err; goto err;
......
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