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
592e0806
Commit
592e0806
authored
Jun 17, 2006
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge moonbone.local:/home/evgen/bk-trees/mysql-4.1-opt
into moonbone.local:/work/tmp_merge-5.0-opt-mysql
parents
28cf3c3e
b8b9738e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
24 deletions
+58
-24
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+15
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+12
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+11
-21
sql/item_strfunc.cc
sql/item_strfunc.cc
+20
-3
No files found.
mysql-test/r/func_str.result
View file @
592e0806
...
...
@@ -1023,6 +1023,21 @@ NULL
select ifnull(load_file("lkjlkj"),"it's null");
ifnull(load_file("lkjlkj"),"it's null")
it's null
create table t1 (f1 varchar(4), f2 varchar(64), unique key k1 (f1,f2));
insert into t1 values ( 'test',md5('test')), ('test', sha('test'));
select * from t1 where f1='test' and (f2= md5("test") or f2= md5("TEST"));
f1 f2
test 098f6bcd4621d373cade4e832627b4f6
select * from t1 where f1='test' and (f2= md5("TEST") or f2= md5("test"));
f1 f2
test 098f6bcd4621d373cade4e832627b4f6
select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
f1 f2
test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
f1 f2
test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
drop table t1;
End of 4.1 tests
create table t1 (d decimal default null);
insert into t1 values (null);
...
...
mysql-test/t/func_str.test
View file @
592e0806
...
...
@@ -673,6 +673,18 @@ drop table t1;
select
load_file
(
"lkjlkj"
);
select
ifnull
(
load_file
(
"lkjlkj"
),
"it's null"
);
#
# Bug#15351: Wrong collation used for comparison of md5() and sha()
# parameter can lead to a wrong result.
#
create
table
t1
(
f1
varchar
(
4
),
f2
varchar
(
64
),
unique
key
k1
(
f1
,
f2
));
insert
into
t1
values
(
'test'
,
md5
(
'test'
)),
(
'test'
,
sha
(
'test'
));
select
*
from
t1
where
f1
=
'test'
and
(
f2
=
md5
(
"test"
)
or
f2
=
md5
(
"TEST"
));
select
*
from
t1
where
f1
=
'test'
and
(
f2
=
md5
(
"TEST"
)
or
f2
=
md5
(
"test"
));
select
*
from
t1
where
f1
=
'test'
and
(
f2
=
sha
(
"test"
)
or
f2
=
sha
(
"TEST"
));
select
*
from
t1
where
f1
=
'test'
and
(
f2
=
sha
(
"TEST"
)
or
f2
=
sha
(
"test"
));
drop
table
t1
;
--
echo
End
of
4.1
tests
#
...
...
sql/item_cmpfunc.cc
View file @
592e0806
...
...
@@ -85,21 +85,21 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
items will be used for aggregation.
If there are DATE/TIME fields/functions in the list and no string
fields/functions in the list then:
The INT_RESULT type will be used for aggregation instead of orginal
The INT_RESULT type will be used for aggregation instead of or
i
ginal
result type of any DATE/TIME field/function in the list
All constant items in the list will be converted to a DATE/TIME using
found field or result field of found function.
Implementation notes:
The code is equvalent to:
1. Check the list for presen
s
e of a STRING field/function.
The code is equ
i
valent to:
1. Check the list for presen
c
e of a STRING field/function.
Collect the is_const flag.
2. Get a Field* object to use for type coercion
3. Perform type conversion.
1 and 2 are implemented in 2 loops. The first searches for a DATE/TIME
field/function and checks presen
s
e of a STRING field/function.
field/function and checks presen
c
e of a STRING field/function.
The second loop works only if a DATE/TIME field/function is found.
It checks presen
s
e of a STRING field/function in the rest of the list.
It checks presen
c
e of a STRING field/function in the rest of the list.
TODO
1) The current implementation can produce false comparison results for
...
...
@@ -122,8 +122,9 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems)
static
void
agg_cmp_type
(
THD
*
thd
,
Item_result
*
type
,
Item
**
items
,
uint
nitems
)
{
uint
i
;
Item
::
Type
res
;
char
*
buff
=
NULL
;
Item
::
Type
res
=
(
Item
::
Type
)
0
;
/* Used only for date/time fields, max_length = 19 */
char
buff
[
20
];
uchar
null_byte
;
Field
*
field
=
NULL
;
...
...
@@ -149,28 +150,20 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
{
field
=
items
[
i
]
->
tmp_table_field_from_field_type
(
0
);
if
(
field
)
buff
=
alloc_root
(
thd
->
mem_root
,
field
->
max_length
());
if
(
!
buff
||
!
field
)
{
if
(
field
)
delete
field
;
if
(
buff
)
my_free
(
buff
,
MYF
(
MY_WME
));
field
=
0
;
}
else
field
->
move_field
(
buff
,
&
null_byte
,
0
);
break
;
}
}
if
(
field
)
{
/* Check the rest of the list for presen
s
e of a string field/function. */
/* Check the rest of the list for presen
c
e of a string field/function. */
for
(
i
++
;
i
<
nitems
;
i
++
)
{
if
(
!
items
[
i
]
->
const_item
()
&&
items
[
i
]
->
result_type
()
==
STRING_RESULT
&&
!
items
[
i
]
->
result_as_longlong
())
{
if
(
res
==
Item
::
FUNC_ITEM
)
delete
field
;
field
=
0
;
break
;
}
...
...
@@ -207,10 +200,7 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
}
if
(
res
==
Item
::
FUNC_ITEM
&&
field
)
{
delete
field
;
my_free
(
buff
,
MYF
(
MY_WME
));
}
}
...
...
sql/item_strfunc.cc
View file @
592e0806
...
...
@@ -154,7 +154,15 @@ String *Item_func_md5::val_str(String *str)
void
Item_func_md5
::
fix_length_and_dec
()
{
max_length
=
32
;
max_length
=
32
;
/*
The MD5() function treats its parameter as being a case sensitive. Thus
we set binary collation on it so different instances of MD5() will be
compared properly.
*/
args
[
0
]
->
collation
.
set
(
get_charset_by_csname
(
args
[
0
]
->
collation
.
collation
->
csname
,
MY_CS_BINSORT
,
MYF
(
0
)),
DERIVATION_COERCIBLE
);
}
...
...
@@ -195,7 +203,15 @@ String *Item_func_sha::val_str(String *str)
void
Item_func_sha
::
fix_length_and_dec
()
{
max_length
=
SHA1_HASH_SIZE
*
2
;
// size of hex representation of hash
max_length
=
SHA1_HASH_SIZE
*
2
;
// size of hex representation of hash
/*
The SHA() function treats its parameter as being a case sensitive. Thus
we set binary collation on it so different instances of MD5() will be
compared properly.
*/
args
[
0
]
->
collation
.
set
(
get_charset_by_csname
(
args
[
0
]
->
collation
.
collation
->
csname
,
MY_CS_BINSORT
,
MYF
(
0
)),
DERIVATION_COERCIBLE
);
}
...
...
@@ -294,7 +310,8 @@ String *Item_func_concat::val_str(String *str)
if
(
!
(
res
=
args
[
0
]
->
val_str
(
str
)))
goto
null
;
use_as_buff
=
&
tmp_value
;
is_const
=
args
[
0
]
->
const_item
();
/* Item_subselect in --ps-protocol mode will state it as a non-const */
is_const
=
args
[
0
]
->
const_item
()
||
!
args
[
0
]
->
used_tables
();
for
(
i
=
1
;
i
<
arg_count
;
i
++
)
{
if
(
res
->
length
()
==
0
)
...
...
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