summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <harrison@bud.lordblink.com>2003-10-15 02:11:03 -0400
committerunknown <harrison@bud.lordblink.com>2003-10-15 02:11:03 -0400
commitacb47c93be78fbc59ca75fc1195444e7d8dc3568 (patch)
tree61ece9d1249d602850409cb88d9ac7e67a14362f
parenta14c1e411cb763688a0673b326cdd09c589fecf0 (diff)
downloadmariadb-git-acb47c93be78fbc59ca75fc1195444e7d8dc3568.tar.gz
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
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--sql/item_sum.cc23
-rw-r--r--sql/item_sum.h12
-rw-r--r--sql/lex.h1
-rw-r--r--sql/sql_yacc.yy3
5 files changed, 40 insertions, 0 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 177107f8779..9df789c0340 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -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.
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 6a213962c6a..672126a2664 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -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()
{
diff --git a/sql/item_sum.h b/sql/item_sum.h
index d6184bcdbac..e5061e1e05a 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -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
*/
diff --git a/sql/lex.h b/sql/lex.h
index 859f92dd752..f8bb34c5c5b 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -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)},
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 569fa984973..51df4e358b4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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 ')'