MDEV-9676: RANGE-type frames for window functions

Support RANGE ... CURRENT ROW as frame's first and second bound.
This commit is contained in:
Sergei Petrunia 2016-03-06 23:10:20 +03:00
commit 1fa12cdfb7
5 changed files with 575 additions and 75 deletions

View file

@ -98,6 +98,25 @@ bool Cached_item_str::cmp(void)
return tmp;
}
int Cached_item_str::cmp_read_only()
{
String *res= item->val_str(&tmp_value);
if (null_value)
{
if (item->null_value)
return 0;
else
return -1;
}
if (item->null_value)
return 1;
return sortcmp(&value, res, item->collation.collation);
}
Cached_item_str::~Cached_item_str()
{
item=0; // Safety
@ -115,6 +134,23 @@ bool Cached_item_real::cmp(void)
return FALSE;
}
int Cached_item_real::cmp_read_only()
{
double nr= item->val_real();
if (null_value)
{
if (item->null_value)
return 0;
else
return -1;
}
if (item->null_value)
return 1;
return (nr == value)? 0 : ((nr < value)? 1: -1);
}
bool Cached_item_int::cmp(void)
{
longlong nr=item->val_int();
@ -128,6 +164,22 @@ bool Cached_item_int::cmp(void)
}
int Cached_item_int::cmp_read_only()
{
longlong nr= item->val_int();
if (null_value)
{
if (item->null_value)
return 0;
else
return -1;
}
if (item->null_value)
return 1;
return (nr == value)? 0 : ((nr < value)? 1: -1);
}
bool Cached_item_field::cmp(void)
{
bool tmp= FALSE; // Value is identical
@ -148,6 +200,22 @@ bool Cached_item_field::cmp(void)
}
int Cached_item_field::cmp_read_only()
{
if (null_value)
{
if (field->is_null())
return 0;
else
return -1;
}
if (field->is_null())
return 1;
return field->cmp(buff);
}
Cached_item_decimal::Cached_item_decimal(Item *it)
:item(it)
{
@ -174,3 +242,20 @@ bool Cached_item_decimal::cmp()
return FALSE;
}
int Cached_item_decimal::cmp_read_only()
{
my_decimal tmp;
my_decimal *ptmp= item->val_decimal(&tmp);
if (null_value)
{
if (item->null_value)
return 0;
else
return -1;
}
if (item->null_value)
return 1;
return my_decimal_cmp(&value, ptmp);
}