Add in bit_xor function (approved by Sergei)
sql/item_sum.cc: Add in bit_xor class functions. sql/item_sum.h: Add bit_xor class. sql/lex.h: Add in bit_xor symbol. sql/sql_yacc.yy: Add in bit_xor function BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
This commit is contained in:
parent
a14c1e411c
commit
acb47c93be
@ -30,6 +30,7 @@ greg@mysql.com
|
||||
guilhem@mysql.com
|
||||
gweir@build.mysql.com
|
||||
gweir@work.mysql.com
|
||||
harrison@mysql.com
|
||||
heikki@donna.mysql.fi
|
||||
heikki@hundin.mysql.fi
|
||||
heikki@rescue.
|
||||
|
@ -625,6 +625,20 @@ bool Item_sum_or::add()
|
||||
return 0;
|
||||
}
|
||||
|
||||
Item *Item_sum_xor::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_xor(thd, *this);
|
||||
}
|
||||
|
||||
|
||||
bool Item_sum_xor::add()
|
||||
{
|
||||
ulonglong value= (ulonglong) args[0]->val_int();
|
||||
if (!args[0]->null_value)
|
||||
bits^=value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Item *Item_sum_and::copy_or_same(THD* thd)
|
||||
{
|
||||
return new (&thd->mem_root) Item_sum_and(thd, *this);
|
||||
@ -912,6 +926,15 @@ void Item_sum_or::update_field()
|
||||
int8store(res,nr);
|
||||
}
|
||||
|
||||
void Item_sum_xor::update_field()
|
||||
{
|
||||
ulonglong nr;
|
||||
char *res=result_field->ptr;
|
||||
|
||||
nr=uint8korr(res);
|
||||
nr^= (ulonglong) args[0]->val_int();
|
||||
int8store(res,nr);
|
||||
}
|
||||
|
||||
void Item_sum_and::update_field()
|
||||
{
|
||||
|
@ -484,6 +484,18 @@ class Item_sum_and :public Item_sum_bit
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
class Item_sum_xor :public Item_sum_bit
|
||||
{
|
||||
public:
|
||||
Item_sum_xor(Item *item_par) :Item_sum_bit(item_par,LL(0)) {}
|
||||
Item_sum_xor(THD *thd, Item_sum_xor &item) :Item_sum_bit(thd, item) {}
|
||||
bool add();
|
||||
void update_field();
|
||||
const char *func_name() const { return "bit_xor"; }
|
||||
Item *copy_or_same(THD* thd);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** user defined aggregates
|
||||
*/
|
||||
|
@ -465,6 +465,7 @@ static SYMBOL sql_functions[] = {
|
||||
{ "BIT_COUNT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_bit_count)},
|
||||
{ "BIT_OR", SYM(BIT_OR),0,0},
|
||||
{ "BIT_AND", SYM(BIT_AND),0,0},
|
||||
{ "BIT_XOR", SYM(BIT_XOR),0,0},
|
||||
{ "CAST", SYM(CAST_SYM),0,0},
|
||||
{ "CEIL", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)},
|
||||
{ "CEILING", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)},
|
||||
|
@ -449,6 +449,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
|
||||
%token BETWEEN_SYM
|
||||
%token BIT_AND
|
||||
%token BIT_OR
|
||||
%token BIT_XOR
|
||||
%token CASE_SYM
|
||||
%token CONCAT
|
||||
%token CONCAT_WS
|
||||
@ -2846,6 +2847,8 @@ sum_expr:
|
||||
{ $$=new Item_sum_and($3); }
|
||||
| BIT_OR '(' in_sum_expr ')'
|
||||
{ $$=new Item_sum_or($3); }
|
||||
| BIT_XOR '(' in_sum_expr ')'
|
||||
{ $$=new Item_sum_xor($3); }
|
||||
| COUNT_SYM '(' opt_all '*' ')'
|
||||
{ $$=new Item_sum_count(new Item_int((int32) 0L,1)); }
|
||||
| COUNT_SYM '(' in_sum_expr ')'
|
||||
|
Loading…
x
Reference in New Issue
Block a user