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
5c1ba75c
Commit
5c1ba75c
authored
Nov 29, 2005
by
bar@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/usr/home/bar/mysql-4.1.b10446
parents
f0c5aae5
2f72e059
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
15 deletions
+53
-15
mysql-test/r/ctype_recoding.result
mysql-test/r/ctype_recoding.result
+8
-1
mysql-test/t/ctype_recoding.test
mysql-test/t/ctype_recoding.test
+9
-2
sql/item.cc
sql/item.cc
+2
-10
sql/item_strfunc.cc
sql/item_strfunc.cc
+2
-0
sql/item_strfunc.h
sql/item_strfunc.h
+32
-2
No files found.
mysql-test/r/ctype_recoding.result
View file @
5c1ba75c
...
@@ -181,11 +181,18 @@ select * from t1 where a=_koi8r'
...
@@ -181,11 +181,18 @@ select * from t1 where a=_koi8r'
a
a
select * from t1 where a=concat(_koi8r'');
select * from t1 where a=concat(_koi8r'');
ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation '='
a
select * from t1 where a=_latin1'';
select * from t1 where a=_latin1'';
ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
drop table t1;
drop table t1;
set names latin1;
set names latin1;
create table t1 (a char(10) character set utf8 collate utf8_bin);
insert into t1 values (' xxx');
select * from t1 where a=lpad('xxx',10,' ');
a
xxx
drop table t1;
set names koi8r;
set names koi8r;
create table t1 (c1 char(10) character set cp1251);
create table t1 (c1 char(10) character set cp1251);
insert into t1 values ('');
insert into t1 values ('');
...
...
mysql-test/t/ctype_recoding.test
View file @
5c1ba75c
...
@@ -144,8 +144,7 @@ create table t1 (a char(10) character set cp1251);
...
@@ -144,8 +144,7 @@ create table t1 (a char(10) character set cp1251);
insert
into
t1
values
(
_koi8r
''
);
insert
into
t1
values
(
_koi8r
''
);
# this is possible:
# this is possible:
select
*
from
t1
where
a
=
_koi8r
''
;
select
*
from
t1
where
a
=
_koi8r
''
;
# this is not possible, because we have a function, not just a constant:
# this is possible, because we have a function with constant arguments:
--
error
1267
select
*
from
t1
where
a
=
concat
(
_koi8r
''
);
select
*
from
t1
where
a
=
concat
(
_koi8r
''
);
# this is not posible, cannot convert _latin1'' into cp1251:
# this is not posible, cannot convert _latin1'' into cp1251:
--
error
1267
--
error
1267
...
@@ -153,6 +152,14 @@ select * from t1 where a=_latin1'
...
@@ -153,6 +152,14 @@ select * from t1 where a=_latin1'
drop
table
t1
;
drop
table
t1
;
set
names
latin1
;
set
names
latin1
;
#
# Bug#10446 Illegal mix of collations
#
create
table
t1
(
a
char
(
10
)
character
set
utf8
collate
utf8_bin
);
insert
into
t1
values
(
' xxx'
);
select
*
from
t1
where
a
=
lpad
(
'xxx'
,
10
,
' '
);
drop
table
t1
;
#
#
# Check more automatic conversion
# Check more automatic conversion
#
#
...
...
sql/item.cc
View file @
5c1ba75c
...
@@ -211,16 +211,8 @@ bool Item::eq(const Item *item, bool binary_cmp) const
...
@@ -211,16 +211,8 @@ bool Item::eq(const Item *item, bool binary_cmp) const
Item
*
Item
::
safe_charset_converter
(
CHARSET_INFO
*
tocs
)
Item
*
Item
::
safe_charset_converter
(
CHARSET_INFO
*
tocs
)
{
{
/*
Item_func_conv_charset
*
conv
=
new
Item_func_conv_charset
(
this
,
tocs
,
1
);
Allow conversion from and to "binary".
return
conv
->
safe
?
conv
:
NULL
;
Don't allow automatic conversion to non-Unicode charsets,
as it potentially loses data.
*/
if
(
collation
.
collation
!=
&
my_charset_bin
&&
tocs
!=
&
my_charset_bin
&&
!
(
tocs
->
state
&
MY_CS_UNICODE
))
return
NULL
;
// safe conversion is not possible
return
new
Item_func_conv_charset
(
this
,
tocs
);
}
}
...
...
sql/item_strfunc.cc
View file @
5c1ba75c
...
@@ -2252,6 +2252,8 @@ String *Item_func_conv::val_str(String *str)
...
@@ -2252,6 +2252,8 @@ String *Item_func_conv::val_str(String *str)
String
*
Item_func_conv_charset
::
val_str
(
String
*
str
)
String
*
Item_func_conv_charset
::
val_str
(
String
*
str
)
{
{
DBUG_ASSERT
(
fixed
==
1
);
DBUG_ASSERT
(
fixed
==
1
);
if
(
use_cached_value
)
return
null_value
?
0
:
&
str_value
;
String
*
arg
=
args
[
0
]
->
val_str
(
str
);
String
*
arg
=
args
[
0
]
->
val_str
(
str
);
uint
dummy_errors
;
uint
dummy_errors
;
if
(
!
arg
)
if
(
!
arg
)
...
...
sql/item_strfunc.h
View file @
5c1ba75c
...
@@ -614,10 +614,40 @@ public:
...
@@ -614,10 +614,40 @@ public:
class
Item_func_conv_charset
:
public
Item_str_func
class
Item_func_conv_charset
:
public
Item_str_func
{
{
bool
use_cached_value
;
public:
public:
bool
safe
;
CHARSET_INFO
*
conv_charset
;
// keep it public
CHARSET_INFO
*
conv_charset
;
// keep it public
Item_func_conv_charset
(
Item
*
a
,
CHARSET_INFO
*
cs
)
:
Item_str_func
(
a
)
Item_func_conv_charset
(
Item
*
a
,
CHARSET_INFO
*
cs
)
:
Item_str_func
(
a
)
{
conv_charset
=
cs
;
}
{
conv_charset
=
cs
;
use_cached_value
=
0
;
safe
=
0
;
}
Item_func_conv_charset
(
Item
*
a
,
CHARSET_INFO
*
cs
,
bool
cache_if_const
)
:
Item_str_func
(
a
)
{
DBUG_ASSERT
(
args
[
0
]
->
fixed
);
conv_charset
=
cs
;
if
(
cache_if_const
&&
args
[
0
]
->
const_item
())
{
uint
errors
=
0
;
String
tmp
,
*
str
=
args
[
0
]
->
val_str
(
&
tmp
);
if
(
!
str
||
str_value
.
copy
(
str
->
ptr
(),
str
->
length
(),
str
->
charset
(),
conv_charset
,
&
errors
))
null_value
=
1
;
use_cached_value
=
1
;
safe
=
(
errors
==
0
);
}
else
{
use_cached_value
=
0
;
/*
Conversion from and to "binary" is safe.
Conversion to Unicode is safe.
Other kind of conversions are potentially lossy.
*/
safe
=
(
args
[
0
]
->
collation
.
collation
==
&
my_charset_bin
||
cs
==
&
my_charset_bin
||
(
cs
->
state
&
MY_CS_UNICODE
));
}
}
String
*
val_str
(
String
*
);
String
*
val_str
(
String
*
);
void
fix_length_and_dec
();
void
fix_length_and_dec
();
const
char
*
func_name
()
const
{
return
"convert"
;
}
const
char
*
func_name
()
const
{
return
"convert"
;
}
...
...
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