mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
fix for bug #1993 'bit functions do not return unsigned values'
introduced base class Item_func_bit for bit functions
This commit is contained in:
@@ -7,3 +7,21 @@ select 1 | (1+1),5 & 3,bit_count(7) ;
|
||||
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
|
||||
1 << 32 1 << 63 1 << 64 4 >> 2 4 >> 63 1<< 63 >> 60
|
||||
4294967296 9223372036854775808 0 1 0 8
|
||||
select -1 | 0, -1 ^ 0, -1 & 0;
|
||||
-1 | 0 -1 ^ 0 -1 & 0
|
||||
18446744073709551615 18446744073709551615 0
|
||||
select -1 | 1, -1 ^ 1, -1 & 1;
|
||||
-1 | 1 -1 ^ 1 -1 & 1
|
||||
18446744073709551615 18446744073709551614 1
|
||||
select 1 | -1, 1 ^ -1, 1 & -1;
|
||||
1 | -1 1 ^ -1 1 & -1
|
||||
18446744073709551615 18446744073709551614 1
|
||||
select 0 | -1, 0 ^ -1, 0 & -1;
|
||||
0 | -1 0 ^ -1 0 & -1
|
||||
18446744073709551615 18446744073709551615 0
|
||||
select -1 >> 0, -1 << 0;
|
||||
-1 >> 0 -1 << 0
|
||||
18446744073709551615 18446744073709551615
|
||||
select -1 >> 1, -1 << 1;
|
||||
-1 >> 1 -1 << 1
|
||||
9223372036854775807 18446744073709551614
|
||||
|
||||
@@ -5,3 +5,12 @@
|
||||
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
|
||||
select 1 | (1+1),5 & 3,bit_count(7) ;
|
||||
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
|
||||
#
|
||||
# bug #1993: bit functions must be unsigned
|
||||
#
|
||||
select -1 | 0, -1 ^ 0, -1 & 0;
|
||||
select -1 | 1, -1 ^ 1, -1 & 1;
|
||||
select 1 | -1, 1 ^ -1, 1 & -1;
|
||||
select 0 | -1, 0 ^ -1, 0 & -1;
|
||||
select -1 >> 0, -1 << 0;
|
||||
select -1 >> 1, -1 << 1;
|
||||
|
||||
@@ -642,23 +642,30 @@ public:
|
||||
unsigned int size_of() { return sizeof(*this);}
|
||||
};
|
||||
|
||||
/* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */
|
||||
|
||||
class Item_func_bit_or :public Item_int_func
|
||||
class Item_func_bit: public Item_int_func
|
||||
{
|
||||
public:
|
||||
Item_func_bit_or(Item *a,Item *b) :Item_int_func(a,b) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "|"; }
|
||||
void fix_length_and_dec() { unsigned_flag=1; }
|
||||
Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {}
|
||||
Item_func_bit(Item *a) :Item_int_func(a) {}
|
||||
void fix_length_and_dec() { unsigned_flag= 1; }
|
||||
};
|
||||
|
||||
class Item_func_bit_and :public Item_int_func
|
||||
class Item_func_bit_or :public Item_func_bit
|
||||
{
|
||||
public:
|
||||
Item_func_bit_and(Item *a,Item *b) :Item_int_func(a,b) {}
|
||||
Item_func_bit_or(Item *a, Item *b) :Item_func_bit(a, b) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "|"; }
|
||||
};
|
||||
|
||||
class Item_func_bit_and :public Item_func_bit
|
||||
{
|
||||
public:
|
||||
Item_func_bit_and(Item *a, Item *b) :Item_func_bit(a, b) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "&"; }
|
||||
void fix_length_and_dec() { unsigned_flag=1; }
|
||||
};
|
||||
|
||||
class Item_func_bit_count :public Item_int_func
|
||||
@@ -670,30 +677,28 @@ public:
|
||||
void fix_length_and_dec() { max_length=2; }
|
||||
};
|
||||
|
||||
class Item_func_shift_left :public Item_int_func
|
||||
class Item_func_shift_left :public Item_func_bit
|
||||
{
|
||||
public:
|
||||
Item_func_shift_left(Item *a,Item *b) :Item_int_func(a,b) {}
|
||||
Item_func_shift_left(Item *a, Item *b) :Item_func_bit(a, b) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "<<"; }
|
||||
void fix_length_and_dec() { unsigned_flag=1; }
|
||||
};
|
||||
|
||||
class Item_func_shift_right :public Item_int_func
|
||||
class Item_func_shift_right :public Item_func_bit
|
||||
{
|
||||
public:
|
||||
Item_func_shift_right(Item *a,Item *b) :Item_int_func(a,b) {}
|
||||
Item_func_shift_right(Item *a, Item *b) :Item_func_bit(a, b) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return ">>"; }
|
||||
};
|
||||
|
||||
class Item_func_bit_neg :public Item_int_func
|
||||
class Item_func_bit_neg :public Item_func_bit
|
||||
{
|
||||
public:
|
||||
Item_func_bit_neg(Item *a) :Item_int_func(a) {}
|
||||
Item_func_bit_neg(Item *a) :Item_func_bit(a) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "~"; }
|
||||
void fix_length_and_dec() { unsigned_flag=1; }
|
||||
};
|
||||
|
||||
class Item_func_set_last_insert_id :public Item_int_func
|
||||
@@ -1018,13 +1023,12 @@ enum Item_cast
|
||||
Item *create_func_cast(Item *a, Item_cast cast_type);
|
||||
|
||||
|
||||
class Item_func_bit_xor : public Item_int_func
|
||||
class Item_func_bit_xor : public Item_func_bit
|
||||
{
|
||||
public:
|
||||
Item_func_bit_xor(Item *a,Item *b) :Item_int_func(a,b) {}
|
||||
Item_func_bit_xor(Item *a, Item *b) :Item_func_bit(a, b) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "^"; }
|
||||
void fix_length_xor_dec() { unsigned_flag=1; }
|
||||
};
|
||||
|
||||
class Item_func_is_free_lock :public Item_int_func
|
||||
|
||||
Reference in New Issue
Block a user