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
7d405e3c
Commit
7d405e3c
authored
Jul 14, 2005
by
bar@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/usr/home/bar/mysql-4.1.num-conv
into mysql.com:/usr/home/bar/mysql-5.0
parents
f3027595
1b612b00
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
4 deletions
+66
-4
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+4
-0
mysql-test/t/ctype_utf8.test
mysql-test/t/ctype_utf8.test
+9
-0
sql/item.cc
sql/item.cc
+43
-1
sql/item.h
sql/item.h
+2
-0
sql/sql_table.cc
sql/sql_table.cc
+8
-3
No files found.
mysql-test/r/ctype_utf8.result
View file @
7d405e3c
...
@@ -905,6 +905,10 @@ select * from t1 where city = 'Durban ';
...
@@ -905,6 +905,10 @@ select * from t1 where city = 'Durban ';
id city
id city
2 Durban
2 Durban
drop table t1;
drop table t1;
create table t1 (x set('A', 'B') default 0) character set utf8;
ERROR 42000: Invalid default value for 'x'
create table t1 (x enum('A', 'B') default 0) character set utf8;
ERROR 42000: Invalid default value for 'x'
SET NAMES UTF8;
SET NAMES UTF8;
CREATE TABLE t1 (
CREATE TABLE t1 (
`id` int(20) NOT NULL auto_increment,
`id` int(20) NOT NULL auto_increment,
...
...
mysql-test/t/ctype_utf8.test
View file @
7d405e3c
...
@@ -747,6 +747,15 @@ select * from t1 where city = 'Durban';
...
@@ -747,6 +747,15 @@ select * from t1 where city = 'Durban';
select
*
from
t1
where
city
=
'Durban '
;
select
*
from
t1
where
city
=
'Durban '
;
drop
table
t1
;
drop
table
t1
;
#
# Bug #11819 CREATE TABLE with a SET DEFAULT 0 and UTF8 crashes server.
#
--
error
1067
create
table
t1
(
x
set
(
'A'
,
'B'
)
default
0
)
character
set
utf8
;
--
error
1067
create
table
t1
(
x
enum
(
'A'
,
'B'
)
default
0
)
character
set
utf8
;
#
#
# Test for bug #11167: join for utf8 varchar value longer than 255 bytes
# Test for bug #11167: join for utf8 varchar value longer than 255 bytes
#
#
...
...
sql/item.cc
View file @
7d405e3c
...
@@ -601,15 +601,43 @@ bool Item::eq(const Item *item, bool binary_cmp) const
...
@@ -601,15 +601,43 @@ 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
)
{
{
/*
/*
Allow conversion from and to "binary".
Don't allow automatic conversion to non-Unicode charsets,
Don't allow automatic conversion to non-Unicode charsets,
as it potentially loses data.
as it potentially loses data.
*/
*/
if
(
!
(
tocs
->
state
&
MY_CS_UNICODE
))
if
(
collation
.
collation
!=
&
my_charset_bin
&&
tocs
!=
&
my_charset_bin
&&
!
(
tocs
->
state
&
MY_CS_UNICODE
))
return
NULL
;
// safe conversion is not possible
return
NULL
;
// safe conversion is not possible
return
new
Item_func_conv_charset
(
this
,
tocs
);
return
new
Item_func_conv_charset
(
this
,
tocs
);
}
}
/*
Created mostly for mysql_prepare_table(). Important
when a string ENUM/SET column is described with a numeric default value:
CREATE TABLE t1(a SET('a') DEFAULT 1);
We cannot use generic Item::safe_charset_converter(), because
the latter returns a non-fixed Item, so val_str() crashes afterwards.
Override Item_num method, to return a fixed item.
*/
Item
*
Item_num
::
safe_charset_converter
(
CHARSET_INFO
*
tocs
)
{
Item_string
*
conv
;
char
buf
[
64
];
String
*
s
,
tmp
(
buf
,
sizeof
(
buf
),
&
my_charset_bin
);
s
=
val_str
(
&
tmp
);
if
((
conv
=
new
Item_string
(
s
->
ptr
(),
s
->
length
(),
s
->
charset
())))
{
conv
->
str_value
.
copy
();
conv
->
str_value
.
mark_as_const
();
}
return
conv
;
}
Item
*
Item_string
::
safe_charset_converter
(
CHARSET_INFO
*
tocs
)
Item
*
Item_string
::
safe_charset_converter
(
CHARSET_INFO
*
tocs
)
{
{
Item_string
*
conv
;
Item_string
*
conv
;
...
@@ -3754,6 +3782,20 @@ bool Item_hex_string::eq(const Item *arg, bool binary_cmp) const
...
@@ -3754,6 +3782,20 @@ bool Item_hex_string::eq(const Item *arg, bool binary_cmp) const
return
FALSE
;
return
FALSE
;
}
}
Item
*
Item_varbinary
::
safe_charset_converter
(
CHARSET_INFO
*
tocs
)
{
Item_string
*
conv
;
String
tmp
,
*
str
=
val_str
(
&
tmp
);
if
(
!
(
conv
=
new
Item_string
(
str
->
ptr
(),
str
->
length
(),
tocs
)))
return
NULL
;
conv
->
str_value
.
copy
();
conv
->
str_value
.
mark_as_const
();
return
conv
;
}
/*
/*
bin item.
bin item.
In string context this is a binary string.
In string context this is a binary string.
...
...
sql/item.h
View file @
7d405e3c
...
@@ -771,6 +771,7 @@ class Item_num: public Item
...
@@ -771,6 +771,7 @@ class Item_num: public Item
{
{
public:
public:
virtual
Item_num
*
neg
()
=
0
;
virtual
Item_num
*
neg
()
=
0
;
Item
*
safe_charset_converter
(
CHARSET_INFO
*
tocs
);
};
};
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
...
@@ -1369,6 +1370,7 @@ class Item_hex_string: public Item
...
@@ -1369,6 +1370,7 @@ class Item_hex_string: public Item
// to prevent drop fixed flag (no need parent cleanup call)
// to prevent drop fixed flag (no need parent cleanup call)
void
cleanup
()
{}
void
cleanup
()
{}
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
bool
eq
(
const
Item
*
item
,
bool
binary_cmp
)
const
;
virtual
Item
*
safe_charset_converter
(
CHARSET_INFO
*
tocs
);
};
};
...
...
sql/sql_table.cc
View file @
7d405e3c
...
@@ -752,10 +752,15 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
...
@@ -752,10 +752,15 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
Convert the default value from client character
Convert the default value from client character
set into the column character set if necessary.
set into the column character set if necessary.
*/
*/
if
(
sql_field
->
def
)
if
(
sql_field
->
def
&&
cs
!=
sql_field
->
def
->
collation
.
collation
)
{
{
sql_field
->
def
=
if
(
!
(
sql_field
->
def
=
sql_field
->
def
->
safe_charset_converter
(
cs
);
sql_field
->
def
->
safe_charset_converter
(
cs
)))
{
/* Could not convert */
my_error
(
ER_INVALID_DEFAULT
,
MYF
(
0
),
sql_field
->
field_name
);
DBUG_RETURN
(
-
1
);
}
}
}
if
(
sql_field
->
sql_type
==
FIELD_TYPE_SET
)
if
(
sql_field
->
sql_type
==
FIELD_TYPE_SET
)
...
...
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