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
6f6868bf
Commit
6f6868bf
authored
Nov 20, 2006
by
bar@mysql.com/bar.intranet.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/usr/home/bar/mysql-4.1.b22646
into mysql.com:/usr/home/bar/mysql-5.0.b22646
parents
9543b7df
413d1865
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
49 deletions
+79
-49
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+23
-1
mysql-test/t/ctype_utf8.test
mysql-test/t/ctype_utf8.test
+20
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+36
-48
No files found.
mysql-test/r/ctype_utf8.result
View file @
6f6868bf
...
...
@@ -124,12 +124,34 @@ create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")`
varbinary(10)
default NULL
`date_format("2004-01-19 10:10:10", "%Y-%m-%d")`
char(10) character set utf8
default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
date_format("2004-01-19 10:10:10", "%Y-%m-%d")
2004-01-19
drop table t1;
set names utf8;
set LC_TIME_NAMES='fr_FR';
create table t1 (s1 char(20) character set latin1);
insert into t1 values (date_format('2004-02-02','%M'));
select hex(s1) from t1;
hex(s1)
66E97672696572
drop table t1;
create table t1 (s1 char(20) character set koi8r);
set LC_TIME_NAMES='ru_RU';
insert into t1 values (date_format('2004-02-02','%M'));
insert into t1 values (date_format('2004-02-02','%b'));
insert into t1 values (date_format('2004-02-02','%W'));
insert into t1 values (date_format('2004-02-02','%a'));
select hex(s1), s1 from t1;
hex(s1) s1
E6C5D7D2C1CCD1 Февраля
E6C5D7 Фев
F0CFCEC5C4C5CCD8CEC9CB Понедельник
F0CEC4 Пнд
drop table t1;
set LC_TIME_NAMES='en_US';
set names koi8r;
create table t1 (s1 char(1) character set utf8);
insert into t1 values (_koi8r'');
...
...
mysql-test/t/ctype_utf8.test
View file @
6f6868bf
...
...
@@ -93,6 +93,26 @@ show create table t1;
select
*
from
t1
;
drop
table
t1
;
#
# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
#
set
names
utf8
;
set
LC_TIME_NAMES
=
'fr_FR'
;
create
table
t1
(
s1
char
(
20
)
character
set
latin1
);
insert
into
t1
values
(
date_format
(
'2004-02-02'
,
'%M'
));
select
hex
(
s1
)
from
t1
;
drop
table
t1
;
create
table
t1
(
s1
char
(
20
)
character
set
koi8r
);
set
LC_TIME_NAMES
=
'ru_RU'
;
insert
into
t1
values
(
date_format
(
'2004-02-02'
,
'%M'
));
insert
into
t1
values
(
date_format
(
'2004-02-02'
,
'%b'
));
insert
into
t1
values
(
date_format
(
'2004-02-02'
,
'%W'
));
insert
into
t1
values
(
date_format
(
'2004-02-02'
,
'%a'
));
select
hex
(
s1
),
s1
from
t1
;
drop
table
t1
;
set
LC_TIME_NAMES
=
'en_US'
;
#
# Bug #2366 Wrong utf8 behaviour when data is truncated
#
...
...
sql/item_timefunc.cc
View file @
6f6868bf
...
...
@@ -609,16 +609,10 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
uint
weekday
;
ulong
length
;
const
char
*
ptr
,
*
end
;
MY_LOCALE
*
locale
;
THD
*
thd
=
current_thd
;
char
buf
[
STRING_BUFFER_USUAL_SIZE
];
String
tmp
(
buf
,
sizeof
(
buf
),
thd
->
variables
.
character_set_results
);
uint
errors
=
0
;
MY_LOCALE
*
locale
=
thd
->
variables
.
lc_time_names
;
tmp
.
length
(
0
);
str
->
length
(
0
);
str
->
set_charset
(
&
my_charset_bin
);
locale
=
thd
->
variables
.
lc_time_names
;
if
(
l_time
->
neg
)
str
->
append
(
'-'
);
...
...
@@ -632,41 +626,37 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time,
{
switch
(
*++
ptr
)
{
case
'M'
:
if
(
!
l_time
->
month
)
return
1
;
tmp
.
copy
(
locale
->
month_names
->
type_names
[
l_time
->
month
-
1
],
strlen
(
locale
->
month_names
->
type_names
[
l_time
->
month
-
1
]),
system_charset_info
,
tmp
.
charset
(),
&
errors
);
str
->
append
(
tmp
.
ptr
(),
tmp
.
length
());
break
;
if
(
!
l_time
->
month
)
return
1
;
str
->
append
(
locale
->
month_names
->
type_names
[
l_time
->
month
-
1
],
strlen
(
locale
->
month_names
->
type_names
[
l_time
->
month
-
1
]),
system_charset_info
);
break
;
case
'b'
:
if
(
!
l_time
->
month
)
return
1
;
tmp
.
copy
(
locale
->
ab_month_names
->
type_names
[
l_time
->
month
-
1
],
strlen
(
locale
->
ab_month_names
->
type_names
[
l_time
->
month
-
1
]),
system_charset_info
,
tmp
.
charset
(),
&
errors
);
str
->
append
(
tmp
.
ptr
(),
tmp
.
length
());
break
;
if
(
!
l_time
->
month
)
return
1
;
str
->
append
(
locale
->
ab_month_names
->
type_names
[
l_time
->
month
-
1
],
strlen
(
locale
->
ab_month_names
->
type_names
[
l_time
->
month
-
1
]),
system_charset_info
);
break
;
case
'W'
:
if
(
type
==
MYSQL_TIMESTAMP_TIME
)
return
1
;
weekday
=
calc_weekday
(
calc_daynr
(
l_time
->
year
,
l_time
->
month
,
l_time
->
day
),
0
);
tmp
.
copy
(
locale
->
day_names
->
type_names
[
weekday
],
strlen
(
locale
->
day_names
->
type_names
[
weekday
]),
system_charset_info
,
tmp
.
charset
(),
&
errors
);
str
->
append
(
tmp
.
ptr
(),
tmp
.
length
());
break
;
if
(
type
==
MYSQL_TIMESTAMP_TIME
)
return
1
;
weekday
=
calc_weekday
(
calc_daynr
(
l_time
->
year
,
l_time
->
month
,
l_time
->
day
),
0
);
str
->
append
(
locale
->
day_names
->
type_names
[
weekday
],
strlen
(
locale
->
day_names
->
type_names
[
weekday
]),
system_charset_info
);
break
;
case
'a'
:
if
(
type
==
MYSQL_TIMESTAMP_TIME
)
return
1
;
weekday
=
calc_weekday
(
calc_daynr
(
l_time
->
year
,
l_time
->
month
,
l_time
->
day
),
0
);
tmp
.
copy
(
locale
->
ab_day_names
->
type_names
[
weekday
],
strlen
(
locale
->
ab_day_names
->
type_names
[
weekday
]),
system_charset_info
,
tmp
.
charset
(),
&
errors
);
str
->
append
(
tmp
.
ptr
(),
tmp
.
length
());
break
;
if
(
type
==
MYSQL_TIMESTAMP_TIME
)
return
1
;
weekday
=
calc_weekday
(
calc_daynr
(
l_time
->
year
,
l_time
->
month
,
l_time
->
day
),
0
);
str
->
append
(
locale
->
ab_day_names
->
type_names
[
weekday
],
strlen
(
locale
->
ab_day_names
->
type_names
[
weekday
]),
system_charset_info
);
break
;
case
'D'
:
if
(
type
==
MYSQL_TIMESTAMP_TIME
)
return
1
;
...
...
@@ -1721,6 +1711,7 @@ longlong Item_func_sec_to_time::val_int()
void
Item_func_date_format
::
fix_length_and_dec
()
{
THD
*
thd
=
current_thd
;
/*
Must use this_item() in case it's a local SP variable
(for ->max_length and ->str_value)
...
...
@@ -1728,22 +1719,18 @@ void Item_func_date_format::fix_length_and_dec()
Item
*
arg1
=
args
[
1
]
->
this_item
();
decimals
=
0
;
collation
.
set
(
&
my_charset_bi
n
);
collation
.
set
(
thd
->
variables
.
collation_connectio
n
);
if
(
arg1
->
type
()
==
STRING_ITEM
)
{
// Optimize the normal case
fixed_length
=
1
;
/*
The result is a binary string (no reason to use collation->mbmaxlen
This is becasue make_date_time() only returns binary strings
*/
max_length
=
format_length
(
&
arg1
->
str_value
);
max_length
=
format_length
(
&
arg1
->
str_value
)
*
collation
.
collation
->
mbmaxlen
;
}
else
{
fixed_length
=
0
;
/* The result is a binary string (no reason to use collation->mbmaxlen */
max_length
=
min
(
arg1
->
max_length
,
MAX_BLOB_WIDTH
)
*
10
;
max_length
=
min
(
arg1
->
max_length
,
MAX_BLOB_WIDTH
)
*
10
*
collation
.
collation
->
mbmaxlen
;
set_if_smaller
(
max_length
,
MAX_BLOB_WIDTH
);
}
maybe_null
=
1
;
// If wrong date
...
...
@@ -1888,6 +1875,7 @@ String *Item_func_date_format::val_str(String *str)
date_time_format
.
format
.
length
=
format
->
length
();
/* Create the result string */
str
->
set_charset
(
collation
.
collation
);
if
(
!
make_date_time
(
&
date_time_format
,
&
l_time
,
is_time_format
?
MYSQL_TIMESTAMP_TIME
:
MYSQL_TIMESTAMP_DATE
,
...
...
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