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
68bc3dd1
Commit
68bc3dd1
authored
Dec 06, 2005
by
jimw@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/jimw/my/mysql-5.0-14299
into mysql.com:/home/jimw/my/mysql-5.0-clean
parents
adc8051c
8ecedd19
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
23 deletions
+81
-23
mysql-test/r/type_binary.result
mysql-test/r/type_binary.result
+23
-0
mysql-test/t/type_binary.test
mysql-test/t/type_binary.test
+24
-0
sql/field.cc
sql/field.cc
+34
-23
No files found.
mysql-test/r/type_binary.result
View file @
68bc3dd1
...
@@ -114,3 +114,26 @@ drop table t1;
...
@@ -114,3 +114,26 @@ drop table t1;
select hex(cast(0x10 as binary(2)));
select hex(cast(0x10 as binary(2)));
hex(cast(0x10 as binary(2)))
hex(cast(0x10 as binary(2)))
1000
1000
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'vb' at row 1
drop table t1;
create table t1 (c char(2), vc varchar(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
Warnings:
Note 1265 Data truncated for column 'vc' at row 1
drop table t1;
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, NULL);
ERROR 22001: Data too long for column 'b' at row 1
insert into t1 values(NULL, 0x412020);
ERROR 22001: Data too long for column 'vb' at row 1
drop table t1;
set @@sql_mode= @old_sql_mode;
End of 5.0 tests
mysql-test/t/type_binary.test
View file @
68bc3dd1
...
@@ -68,3 +68,27 @@ drop table t1;
...
@@ -68,3 +68,27 @@ drop table t1;
# check that cast appends trailing zeros
# check that cast appends trailing zeros
select
hex
(
cast
(
0x10
as
binary
(
2
)));
select
hex
(
cast
(
0x10
as
binary
(
2
)));
#
# Bug #14299: BINARY space truncation should cause warning or error
#
create
table
t1
(
b
binary
(
2
),
vb
varbinary
(
2
));
insert
into
t1
values
(
0x4120
,
0x4120
);
insert
into
t1
values
(
0x412020
,
0x412020
);
drop
table
t1
;
create
table
t1
(
c
char
(
2
),
vc
varchar
(
2
));
insert
into
t1
values
(
0x4120
,
0x4120
);
insert
into
t1
values
(
0x412020
,
0x412020
);
drop
table
t1
;
set
@
old_sql_mode
=
@@
sql_mode
,
sql_mode
=
'traditional'
;
create
table
t1
(
b
binary
(
2
),
vb
varbinary
(
2
));
insert
into
t1
values
(
0x4120
,
0x4120
);
--
error
ER_DATA_TOO_LONG
insert
into
t1
values
(
0x412020
,
NULL
);
--
error
ER_DATA_TOO_LONG
insert
into
t1
values
(
NULL
,
0x412020
);
drop
table
t1
;
set
@@
sql_mode
=
@
old_sql_mode
;
--
echo
End
of
5.0
tests
sql/field.cc
View file @
68bc3dd1
...
@@ -5870,23 +5870,30 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
...
@@ -5870,23 +5870,30 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
error
=
2
;
error
=
2
;
}
}
/*
/* Make sure we don't break a multibyte sequence or copy malformed data. */
Make sure we don't break a multibyte sequence
as well as don't copy a malformed data.
*/
copy_length
=
field_charset
->
cset
->
well_formed_len
(
field_charset
,
copy_length
=
field_charset
->
cset
->
well_formed_len
(
field_charset
,
from
,
from
+
length
,
from
,
from
+
length
,
field_length
/
field_length
/
field_charset
->
mbmaxlen
,
field_charset
->
mbmaxlen
,
&
well_formed_error
);
&
well_formed_error
);
memcpy
(
ptr
,
from
,
copy_length
);
memcpy
(
ptr
,
from
,
copy_length
);
if
(
copy_length
<
field_length
)
// Append spaces if shorter
/* Append spaces if the string was shorter than the field. */
if
(
copy_length
<
field_length
)
field_charset
->
cset
->
fill
(
field_charset
,
ptr
+
copy_length
,
field_charset
->
cset
->
fill
(
field_charset
,
ptr
+
copy_length
,
field_length
-
copy_length
,
field_length
-
copy_length
,
field_charset
->
pad_char
);
field_charset
->
pad_char
);
/*
Check if we lost any important data (anything in a binary string,
or any non-space in others).
*/
if
((
copy_length
<
length
)
&&
table
->
in_use
->
count_cuted_fields
)
if
((
copy_length
<
length
)
&&
table
->
in_use
->
count_cuted_fields
)
{
// Check if we loosed some info
{
if
(
binary
())
error
=
2
;
else
{
const
char
*
end
=
from
+
length
;
const
char
*
end
=
from
+
length
;
from
+=
copy_length
;
from
+=
copy_length
;
from
+=
field_charset
->
cset
->
scan
(
field_charset
,
from
,
end
,
from
+=
field_charset
->
cset
->
scan
(
field_charset
,
from
,
end
,
...
@@ -5894,6 +5901,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
...
@@ -5894,6 +5901,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
if
(
from
!=
end
)
if
(
from
!=
end
)
error
=
2
;
error
=
2
;
}
}
}
if
(
error
)
if
(
error
)
{
{
if
(
table
->
in_use
->
abort_on_warning
)
if
(
table
->
in_use
->
abort_on_warning
)
...
@@ -6270,6 +6278,8 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
...
@@ -6270,6 +6278,8 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
// Check if we lost something other than just trailing spaces
// Check if we lost something other than just trailing spaces
if
((
copy_length
<
length
)
&&
table
->
in_use
->
count_cuted_fields
&&
if
((
copy_length
<
length
)
&&
table
->
in_use
->
count_cuted_fields
&&
!
error_code
)
!
error_code
)
{
if
(
!
binary
())
{
{
const
char
*
end
=
from
+
length
;
const
char
*
end
=
from
+
length
;
from
+=
copy_length
;
from
+=
copy_length
;
...
@@ -6277,6 +6287,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
...
@@ -6277,6 +6287,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
/* If we lost only spaces then produce a NOTE, not a WARNING */
/* If we lost only spaces then produce a NOTE, not a WARNING */
if
(
from
==
end
)
if
(
from
==
end
)
level
=
MYSQL_ERROR
::
WARN_LEVEL_NOTE
;
level
=
MYSQL_ERROR
::
WARN_LEVEL_NOTE
;
}
error_code
=
WARN_DATA_TRUNCATED
;
error_code
=
WARN_DATA_TRUNCATED
;
}
}
if
(
error_code
)
if
(
error_code
)
...
...
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