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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d7ecb3ff
Commit
d7ecb3ff
authored
Aug 18, 2004
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/jonas/src/mysql-4.1-ndb
parents
029ce2f0
83dc887b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
246 additions
and
8 deletions
+246
-8
mysql-test/r/range.result
mysql-test/r/range.result
+86
-0
mysql-test/t/range.test
mysql-test/t/range.test
+43
-0
sql/item.h
sql/item.h
+4
-2
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+104
-1
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+5
-1
sql/mysqld.cc
sql/mysqld.cc
+4
-4
No files found.
mysql-test/r/range.result
View file @
d7ecb3ff
...
@@ -475,3 +475,89 @@ id name uid id name uid
...
@@ -475,3 +475,89 @@ id name uid id name uid
1025 Y 25 1025 Y 25
1025 Y 25 1025 Y 25
1026 Z 26 1026 Z 26
1026 Z 26 1026 Z 26
drop table t1,t2;
drop table t1,t2;
create table t1 (x bigint unsigned not null);
insert into t1(x) values (0xfffffffffffffff0);
insert into t1(x) values (0xfffffffffffffff1);
select * from t1;
x
18446744073709551600
18446744073709551601
select count(*) from t1 where x>0;
count(*)
2
select count(*) from t1 where x=0;
count(*)
0
select count(*) from t1 where x<0;
count(*)
0
select count(*) from t1 where x < -16;
count(*)
0
select count(*) from t1 where x = -16;
count(*)
0
select count(*) from t1 where x > -16;
count(*)
2
select count(*) from t1 where x = 18446744073709551601;
count(*)
1
create table t2 (x bigint not null);
insert into t2(x) values (0xfffffffffffffff0);
insert into t2(x) values (0xfffffffffffffff1);
select * from t2;
x
-16
-15
select count(*) from t2 where x>0;
count(*)
0
select count(*) from t2 where x=0;
count(*)
0
select count(*) from t2 where x<0;
count(*)
2
select count(*) from t2 where x < -16;
count(*)
0
select count(*) from t2 where x = -16;
count(*)
1
select count(*) from t2 where x > -16;
count(*)
1
select count(*) from t2 where x = 18446744073709551601;
count(*)
0
drop table t1;
create table t1 (x bigint unsigned not null primary key) engine=innodb;
insert into t1(x) values (0xfffffffffffffff0);
insert into t1(x) values (0xfffffffffffffff1);
select * from t1;
x
18446744073709551600
18446744073709551601
select count(*) from t1 where x>0;
count(*)
2
select count(*) from t1 where x=0;
count(*)
0
select count(*) from t1 where x<0;
count(*)
0
select count(*) from t1 where x < -16;
count(*)
0
select count(*) from t1 where x = -16;
count(*)
0
select count(*) from t1 where x > -16;
count(*)
1
select count(*) from t1 where x = 18446744073709551601;
count(*)
1
drop table t1;
mysql-test/t/range.test
View file @
d7ecb3ff
...
@@ -383,3 +383,46 @@ select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
...
@@ -383,3 +383,46 @@ select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
select
*
from
t1
,
t2
where
t1
.
uid
=
t2
.
uid
AND
t1
.
uid
!=
0
;
select
*
from
t1
,
t2
where
t1
.
uid
=
t2
.
uid
AND
t1
.
uid
!=
0
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
# Fix for bug#4488
#
create
table
t1
(
x
bigint
unsigned
not
null
);
insert
into
t1
(
x
)
values
(
0xfffffffffffffff0
);
insert
into
t1
(
x
)
values
(
0xfffffffffffffff1
);
select
*
from
t1
;
select
count
(
*
)
from
t1
where
x
>
0
;
select
count
(
*
)
from
t1
where
x
=
0
;
select
count
(
*
)
from
t1
where
x
<
0
;
select
count
(
*
)
from
t1
where
x
<
-
16
;
select
count
(
*
)
from
t1
where
x
=
-
16
;
select
count
(
*
)
from
t1
where
x
>
-
16
;
select
count
(
*
)
from
t1
where
x
=
18446744073709551601
;
create
table
t2
(
x
bigint
not
null
);
insert
into
t2
(
x
)
values
(
0xfffffffffffffff0
);
insert
into
t2
(
x
)
values
(
0xfffffffffffffff1
);
select
*
from
t2
;
select
count
(
*
)
from
t2
where
x
>
0
;
select
count
(
*
)
from
t2
where
x
=
0
;
select
count
(
*
)
from
t2
where
x
<
0
;
select
count
(
*
)
from
t2
where
x
<
-
16
;
select
count
(
*
)
from
t2
where
x
=
-
16
;
select
count
(
*
)
from
t2
where
x
>
-
16
;
select
count
(
*
)
from
t2
where
x
=
18446744073709551601
;
drop
table
t1
;
create
table
t1
(
x
bigint
unsigned
not
null
primary
key
)
engine
=
innodb
;
insert
into
t1
(
x
)
values
(
0xfffffffffffffff0
);
insert
into
t1
(
x
)
values
(
0xfffffffffffffff1
);
select
*
from
t1
;
select
count
(
*
)
from
t1
where
x
>
0
;
select
count
(
*
)
from
t1
where
x
=
0
;
select
count
(
*
)
from
t1
where
x
<
0
;
select
count
(
*
)
from
t1
where
x
<
-
16
;
select
count
(
*
)
from
t1
where
x
=
-
16
;
select
count
(
*
)
from
t1
where
x
>
-
16
;
select
count
(
*
)
from
t1
where
x
=
18446744073709551601
;
drop
table
t1
;
sql/item.h
View file @
d7ecb3ff
...
@@ -862,7 +862,7 @@ public:
...
@@ -862,7 +862,7 @@ public:
};
};
/*
/*
The following class is used to optimize comparing of date columns
The following class is used to optimize comparing of date
and bigint
columns
We need to save the original item, to be able to set the field to the
We need to save the original item, to be able to set the field to the
original value in 'opt_range'.
original value in 'opt_range'.
*/
*/
...
@@ -872,7 +872,9 @@ class Item_int_with_ref :public Item_int
...
@@ -872,7 +872,9 @@ class Item_int_with_ref :public Item_int
Item
*
ref
;
Item
*
ref
;
public:
public:
Item_int_with_ref
(
longlong
i
,
Item
*
ref_arg
)
:
Item_int
(
i
),
ref
(
ref_arg
)
Item_int_with_ref
(
longlong
i
,
Item
*
ref_arg
)
:
Item_int
(
i
),
ref
(
ref_arg
)
{}
{
unsigned_flag
=
ref_arg
->
unsigned_flag
;
}
int
save_in_field
(
Field
*
field
,
bool
no_conversions
)
int
save_in_field
(
Field
*
field
,
bool
no_conversions
)
{
{
return
ref
->
save_in_field
(
field
,
no_conversions
);
return
ref
->
save_in_field
(
field
,
no_conversions
);
...
...
sql/item_cmpfunc.cc
View file @
d7ecb3ff
...
@@ -315,6 +315,22 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
...
@@ -315,6 +315,22 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
func
=
&
Arg_comparator
::
compare_e_binary_string
;
func
=
&
Arg_comparator
::
compare_e_binary_string
;
}
}
}
}
else
if
(
type
==
INT_RESULT
)
{
if
(
func
==
&
Arg_comparator
::
compare_int_signed
)
{
if
((
*
a
)
->
unsigned_flag
)
func
=
((
*
b
)
->
unsigned_flag
)
?
&
Arg_comparator
::
compare_int_unsigned
:
&
Arg_comparator
::
compare_int_unsigned_signed
;
else
if
((
*
b
)
->
unsigned_flag
)
func
=
&
Arg_comparator
::
compare_int_signed_unsigned
;
}
else
if
(
func
==
&
Arg_comparator
::
compare_e_int
)
{
if
((
*
a
)
->
unsigned_flag
^
(
*
b
)
->
unsigned_flag
)
func
=
&
Arg_comparator
::
compare_e_int_diff_signedness
;
}
}
return
0
;
return
0
;
}
}
...
@@ -416,7 +432,7 @@ int Arg_comparator::compare_e_real()
...
@@ -416,7 +432,7 @@ int Arg_comparator::compare_e_real()
return
test
(
val1
==
val2
);
return
test
(
val1
==
val2
);
}
}
int
Arg_comparator
::
compare_int
()
int
Arg_comparator
::
compare_int
_signed
()
{
{
longlong
val1
=
(
*
a
)
->
val_int
();
longlong
val1
=
(
*
a
)
->
val_int
();
if
(
!
(
*
a
)
->
null_value
)
if
(
!
(
*
a
)
->
null_value
)
...
@@ -434,6 +450,82 @@ int Arg_comparator::compare_int()
...
@@ -434,6 +450,82 @@ int Arg_comparator::compare_int()
return
-
1
;
return
-
1
;
}
}
/*
Compare values as BIGINT UNSIGNED.
*/
int
Arg_comparator
::
compare_int_unsigned
()
{
ulonglong
val1
=
(
*
a
)
->
val_int
();
if
(
!
(
*
a
)
->
null_value
)
{
ulonglong
val2
=
(
*
b
)
->
val_int
();
if
(
!
(
*
b
)
->
null_value
)
{
owner
->
null_value
=
0
;
if
(
val1
<
val2
)
return
-
1
;
if
(
val1
==
val2
)
return
0
;
return
1
;
}
}
owner
->
null_value
=
1
;
return
-
1
;
}
/*
Compare signed (*a) with unsigned (*B)
*/
int
Arg_comparator
::
compare_int_signed_unsigned
()
{
longlong
sval1
=
(
*
a
)
->
val_int
();
if
(
!
(
*
a
)
->
null_value
)
{
ulonglong
uval2
=
(
ulonglong
)(
*
b
)
->
val_int
();
if
(
!
(
*
b
)
->
null_value
)
{
owner
->
null_value
=
0
;
if
(
sval1
<
0
||
(
ulonglong
)
sval1
<
uval2
)
return
-
1
;
if
((
ulonglong
)
sval1
==
uval2
)
return
0
;
return
1
;
}
}
owner
->
null_value
=
1
;
return
-
1
;
}
/*
Compare unsigned (*a) with signed (*B)
*/
int
Arg_comparator
::
compare_int_unsigned_signed
()
{
ulonglong
uval1
=
(
ulonglong
)(
*
a
)
->
val_int
();
if
(
!
(
*
a
)
->
null_value
)
{
longlong
sval2
=
(
*
b
)
->
val_int
();
if
(
!
(
*
b
)
->
null_value
)
{
owner
->
null_value
=
0
;
if
(
sval2
<
0
)
return
1
;
if
(
uval1
<
(
ulonglong
)
sval2
)
return
-
1
;
if
(
uval1
==
(
ulonglong
)
sval2
)
return
0
;
return
1
;
}
}
owner
->
null_value
=
1
;
return
-
1
;
}
int
Arg_comparator
::
compare_e_int
()
int
Arg_comparator
::
compare_e_int
()
{
{
longlong
val1
=
(
*
a
)
->
val_int
();
longlong
val1
=
(
*
a
)
->
val_int
();
...
@@ -443,6 +535,17 @@ int Arg_comparator::compare_e_int()
...
@@ -443,6 +535,17 @@ int Arg_comparator::compare_e_int()
return
test
(
val1
==
val2
);
return
test
(
val1
==
val2
);
}
}
/*
Compare unsigned *a with signed *b or signed *a with unsigned *b.
*/
int
Arg_comparator
::
compare_e_int_diff_signedness
()
{
longlong
val1
=
(
*
a
)
->
val_int
();
longlong
val2
=
(
*
b
)
->
val_int
();
if
((
*
a
)
->
null_value
||
(
*
b
)
->
null_value
)
return
test
((
*
a
)
->
null_value
&&
(
*
b
)
->
null_value
);
return
(
val1
>=
0
)
&&
test
(
val1
==
val2
);
}
int
Arg_comparator
::
compare_row
()
int
Arg_comparator
::
compare_row
()
{
{
...
...
sql/item_cmpfunc.h
View file @
d7ecb3ff
...
@@ -65,12 +65,16 @@ public:
...
@@ -65,12 +65,16 @@ public:
int
compare_string
();
// compare args[0] & args[1]
int
compare_string
();
// compare args[0] & args[1]
int
compare_binary_string
();
// compare args[0] & args[1]
int
compare_binary_string
();
// compare args[0] & args[1]
int
compare_real
();
// compare args[0] & args[1]
int
compare_real
();
// compare args[0] & args[1]
int
compare_int
();
// compare args[0] & args[1]
int
compare_int_signed
();
// compare args[0] & args[1]
int
compare_int_signed_unsigned
();
int
compare_int_unsigned_signed
();
int
compare_int_unsigned
();
int
compare_row
();
// compare args[0] & args[1]
int
compare_row
();
// compare args[0] & args[1]
int
compare_e_string
();
// compare args[0] & args[1]
int
compare_e_string
();
// compare args[0] & args[1]
int
compare_e_binary_string
();
// compare args[0] & args[1]
int
compare_e_binary_string
();
// compare args[0] & args[1]
int
compare_e_real
();
// compare args[0] & args[1]
int
compare_e_real
();
// compare args[0] & args[1]
int
compare_e_int
();
// compare args[0] & args[1]
int
compare_e_int
();
// compare args[0] & args[1]
int
compare_e_int_diff_signedness
();
int
compare_e_row
();
// compare args[0] & args[1]
int
compare_e_row
();
// compare args[0] & args[1]
static
arg_cmp_func
comparator_matrix
[
4
][
2
];
static
arg_cmp_func
comparator_matrix
[
4
][
2
];
...
...
sql/mysqld.cc
View file @
d7ecb3ff
...
@@ -237,10 +237,10 @@ bool opt_help= 0;
...
@@ -237,10 +237,10 @@ bool opt_help= 0;
bool
opt_verbose
=
0
;
bool
opt_verbose
=
0
;
arg_cmp_func
Arg_comparator
::
comparator_matrix
[
4
][
2
]
=
arg_cmp_func
Arg_comparator
::
comparator_matrix
[
4
][
2
]
=
{{
&
Arg_comparator
::
compare_string
,
&
Arg_comparator
::
compare_e_string
},
{{
&
Arg_comparator
::
compare_string
,
&
Arg_comparator
::
compare_e_string
},
{
&
Arg_comparator
::
compare_real
,
&
Arg_comparator
::
compare_e_real
},
{
&
Arg_comparator
::
compare_real
,
&
Arg_comparator
::
compare_e_real
},
{
&
Arg_comparator
::
compare_int
,
&
Arg_comparator
::
compare_e_int
},
{
&
Arg_comparator
::
compare_int
_signed
,
&
Arg_comparator
::
compare_e_int
},
{
&
Arg_comparator
::
compare_row
,
&
Arg_comparator
::
compare_e_row
}};
{
&
Arg_comparator
::
compare_row
,
&
Arg_comparator
::
compare_e_row
}};
/* Global variables */
/* Global variables */
...
...
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