Commit c955e3bf authored by unknown's avatar unknown

Added support for different int sizes in condition pushdown

parent 2a7bf81e
......@@ -5554,8 +5554,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
{
// Currently only support for unsigned int
if (field->result_type() == INT_RESULT &&
(field->type() != MYSQL_TYPE_LONG ||
!(field->flags & UNSIGNED_FLAG)))
!(field->flags & UNSIGNED_FLAG))
*context->supported_ptr= FALSE;
else
{
......@@ -5778,7 +5777,12 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b
: NULL;
if (!value || !field) break;
DBUG_PRINT("info", ("Generating EQ filter"));
DBUG_PRINT("info", ("Generating EQ filter %s",
field->isBig() ? "64 bit" : ""));
if (field->isBig())
filter->eq(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->eq(field->getFieldNo(),
(Uint32) value->getIntValue());
DBUG_RETURN(cond->next->next->next);
......@@ -5796,7 +5800,12 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b
: NULL;
if (!value || !field) break;
DBUG_PRINT("info", ("Generating NE filter"));
DBUG_PRINT("info", ("Generating NE filter %s",
field->isBig() ? "64 bit" : ""));
if (field->isBig())
filter->ne(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->ne(field->getFieldNo(),
(Uint32) value->getIntValue());
DBUG_RETURN(cond->next->next->next);
......@@ -5814,13 +5823,26 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b
: NULL;
if (!value || !field) break;
DBUG_PRINT("info", ("Generating LT filter"));
DBUG_PRINT("info", ("Generating LT filter %s",
field->isBig() ? "64 bit" : ""));
if (a == field)
{
if (field->isBig())
filter->lt(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->lt(field->getFieldNo(),
(Uint32) value->getIntValue());
}
else
{
if (field->isBig())
filter->gt(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->gt(field->getFieldNo(),
(Uint32) value->getIntValue());
}
DBUG_RETURN(cond->next->next->next);
}
case(Item_func::LE_FUNC): {
......@@ -5836,13 +5858,26 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b
: NULL;
if (!value || !field) break;
DBUG_PRINT("info", ("Generating LE filter"));
DBUG_PRINT("info", ("Generating LE filter %s",
field->isBig() ? "64 bit" : ""));
if (a == field)
{
if (field->isBig())
filter->le(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->le(field->getFieldNo(),
(Uint32) value->getIntValue());
}
else
{
if (field->isBig())
filter->ge(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->ge(field->getFieldNo(),
(Uint32) value->getIntValue());
}
DBUG_RETURN(cond->next->next->next);
}
case(Item_func::GE_FUNC): {
......@@ -5858,13 +5893,26 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b
: NULL;
if (!value || !field) break;
DBUG_PRINT("info", ("Generating GE filter"));
DBUG_PRINT("info", ("Generating GE filter %s",
field->isBig() ? "64 bit" : ""));
if (a == field)
{
if (field->isBig())
filter->ge(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->ge(field->getFieldNo(),
(Uint32) value->getIntValue());
}
else
{
if (field->isBig())
filter->le(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->le(field->getFieldNo(),
(Uint32) value->getIntValue());
}
DBUG_RETURN(cond->next->next->next);
}
case(Item_func::GT_FUNC): {
......@@ -5880,13 +5928,26 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond *cond,
: (b->type == NDB_FIELD)? b
: NULL;
if (!value || !field) break;
DBUG_PRINT("info", ("Generating GT filter"));
DBUG_PRINT("info", ("Generating GT filter %s",
field->isBig() ? "64 bit" : ""));
if (a == field)
{
if (field->isBig())
filter->gt(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->gt(field->getFieldNo(),
(Uint32) value->getIntValue());
}
else
{
if (field->isBig())
filter->lt(field->getFieldNo(),
(Uint64) value->getIntValue());
else
filter->lt(field->getFieldNo(),
(Uint32) value->getIntValue());
}
DBUG_RETURN(cond->next->next->next);
}
case(Item_func::LIKE_FUNC): {
......
......@@ -103,6 +103,11 @@ class Ndb_item {
Ndb_item(Item_func::Functype func_type);
~Ndb_item();
void print(String *str);
bool isBig()
{
enum_field_types type= value.field_value->field->type();
return (type == MYSQL_TYPE_LONGLONG || type == MYSQL_TYPE_INT24);
}
// Getters and Setters
longlong getIntValue() { return value.int_value; };
double getRealValue() { return value.real_value; };
......
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