Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
38c454b0
Commit
38c454b0
authored
Dec 10, 2003
by
konstantin@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for bug #1993 'bit functions do not return unsigned values'
introduced base class Item_func_bit for bit functions
parent
ea81fd27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
17 deletions
+48
-17
mysql-test/r/func_op.result
mysql-test/r/func_op.result
+18
-0
mysql-test/t/func_op.test
mysql-test/t/func_op.test
+9
-0
sql/item_func.h
sql/item_func.h
+21
-17
No files found.
mysql-test/r/func_op.result
View file @
38c454b0
...
@@ -7,3 +7,21 @@ select 1 | (1+1),5 & 3,bit_count(7) ;
...
@@ -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;
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
1 << 32 1 << 63 1 << 64 4 >> 2 4 >> 63 1<< 63 >> 60
4294967296 9223372036854775808 0 1 0 8
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
mysql-test/t/func_op.test
View file @
38c454b0
...
@@ -5,3 +5,12 @@
...
@@ -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
-
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
|
(
1
+
1
),
5
&
3
,
bit_count
(
7
)
;
select
1
<<
32
,
1
<<
63
,
1
<<
64
,
4
>>
2
,
4
>>
63
,
1
<<
63
>>
60
;
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
;
sql/item_func.h
View file @
38c454b0
...
@@ -642,23 +642,30 @@ class Item_func_find_in_set :public Item_int_func
...
@@ -642,23 +642,30 @@ class Item_func_find_in_set :public Item_int_func
unsigned
int
size_of
()
{
return
sizeof
(
*
this
);}
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:
public:
Item_func_bit_or
(
Item
*
a
,
Item
*
b
)
:
Item_int_func
(
a
,
b
)
{}
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_or
:
public
Item_func_bit
{
public:
Item_func_bit_or
(
Item
*
a
,
Item
*
b
)
:
Item_func_bit
(
a
,
b
)
{}
longlong
val_int
();
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"|"
;
}
const
char
*
func_name
()
const
{
return
"|"
;
}
void
fix_length_and_dec
()
{
unsigned_flag
=
1
;
}
};
};
class
Item_func_bit_and
:
public
Item_
int_func
class
Item_func_bit_and
:
public
Item_
func_bit
{
{
public:
public:
Item_func_bit_and
(
Item
*
a
,
Item
*
b
)
:
Item_int_func
(
a
,
b
)
{}
Item_func_bit_and
(
Item
*
a
,
Item
*
b
)
:
Item_func_bit
(
a
,
b
)
{}
longlong
val_int
();
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"&"
;
}
const
char
*
func_name
()
const
{
return
"&"
;
}
void
fix_length_and_dec
()
{
unsigned_flag
=
1
;
}
};
};
class
Item_func_bit_count
:
public
Item_int_func
class
Item_func_bit_count
:
public
Item_int_func
...
@@ -670,30 +677,28 @@ class Item_func_bit_count :public Item_int_func
...
@@ -670,30 +677,28 @@ class Item_func_bit_count :public Item_int_func
void
fix_length_and_dec
()
{
max_length
=
2
;
}
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:
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
();
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"<<"
;
}
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:
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
();
longlong
val_int
();
const
char
*
func_name
()
const
{
return
">>"
;
}
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:
public:
Item_func_bit_neg
(
Item
*
a
)
:
Item_
int_func
(
a
)
{}
Item_func_bit_neg
(
Item
*
a
)
:
Item_
func_bit
(
a
)
{}
longlong
val_int
();
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"~"
;
}
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
class
Item_func_set_last_insert_id
:
public
Item_int_func
...
@@ -1018,13 +1023,12 @@ enum Item_cast
...
@@ -1018,13 +1023,12 @@ enum Item_cast
Item
*
create_func_cast
(
Item
*
a
,
Item_cast
cast_type
);
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:
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
();
longlong
val_int
();
const
char
*
func_name
()
const
{
return
"^"
;
}
const
char
*
func_name
()
const
{
return
"^"
;
}
void
fix_length_xor_dec
()
{
unsigned_flag
=
1
;
}
};
};
class
Item_func_is_free_lock
:
public
Item_int_func
class
Item_func_is_free_lock
:
public
Item_int_func
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment