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
174d28e4
Commit
174d28e4
authored
Nov 21, 2005
by
bar@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/usr/home/bar/mysql-5.0.b14255
parents
d741ce90
c7db1871
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
15 deletions
+35
-15
mysql-test/r/type_binary.result
mysql-test/r/type_binary.result
+3
-0
mysql-test/t/type_binary.test
mysql-test/t/type_binary.test
+3
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+29
-15
No files found.
mysql-test/r/type_binary.result
View file @
174d28e4
...
...
@@ -111,3 +111,6 @@ select count(distinct s1) from t1;
count(distinct s1)
3
drop table t1;
select hex(cast(0x10 as binary(2)));
hex(cast(0x10 as binary(2)))
1000
mysql-test/t/type_binary.test
View file @
174d28e4
...
...
@@ -65,3 +65,6 @@ select hex(s1) from t1 where s1=0x0120;
select
hex
(
s1
)
from
t1
where
s1
=
0x0100
;
select
count
(
distinct
s1
)
from
t1
;
drop
table
t1
;
# check that cast appends trailing zeros
select
hex
(
cast
(
0x10
as
binary
(
2
)));
sql/item_timefunc.cc
View file @
174d28e4
...
...
@@ -2352,22 +2352,36 @@ String *Item_char_typecast::val_str(String *str)
and the result is longer than cast length, e.g.
CAST('string' AS CHAR(1))
*/
if
(
cast_length
>=
0
&&
(
res
->
length
()
>
(
length
=
(
uint32
)
res
->
charpos
(
cast_length
))))
{
// Safe even if const arg
char
char_type
[
40
];
my_snprintf
(
char_type
,
sizeof
(
char_type
),
"CHAR(%lu)"
,
length
);
if
(
!
res
->
alloced_length
())
{
// Don't change const str
str_value
=
*
res
;
// Not malloced string
res
=
&
str_value
;
if
(
cast_length
>=
0
)
{
if
(
res
->
length
()
>
(
length
=
(
uint32
)
res
->
charpos
(
cast_length
)))
{
// Safe even if const arg
char
char_type
[
40
];
my_snprintf
(
char_type
,
sizeof
(
char_type
),
"CHAR(%lu)"
,
length
);
if
(
!
res
->
alloced_length
())
{
// Don't change const str
str_value
=
*
res
;
// Not malloced string
res
=
&
str_value
;
}
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_TRUNCATED_WRONG_VALUE
,
ER
(
ER_TRUNCATED_WRONG_VALUE
),
char_type
,
res
->
c_ptr_safe
());
res
->
length
((
uint
)
length
);
}
else
if
(
cast_cs
==
&
my_charset_bin
&&
res
->
length
()
<
(
uint
)
cast_length
)
{
if
(
res
->
alloced_length
()
<
(
uint
)
cast_length
)
{
str
->
alloc
(
cast_length
);
str
->
copy
(
*
res
);
res
=
str
;
}
bzero
((
char
*
)
res
->
ptr
()
+
res
->
length
(),
(
uint
)
cast_length
-
res
->
length
());
res
->
length
(
cast_length
);
}
push_warning_printf
(
current_thd
,
MYSQL_ERROR
::
WARN_LEVEL_WARN
,
ER_TRUNCATED_WRONG_VALUE
,
ER
(
ER_TRUNCATED_WRONG_VALUE
),
char_type
,
res
->
c_ptr_safe
());
res
->
length
((
uint
)
length
);
}
null_value
=
0
;
return
res
;
...
...
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