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
f4025aa8
Commit
f4025aa8
authored
Jul 14, 2010
by
Georgi Kodinov
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
bdfcb8bc
4c519b48
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
24 deletions
+98
-24
mysql-test/r/loaddata.result
mysql-test/r/loaddata.result
+29
-0
mysql-test/t/loaddata.test
mysql-test/t/loaddata.test
+32
-0
sql/item_func.cc
sql/item_func.cc
+4
-1
sql/sql_load.cc
sql/sql_load.cc
+33
-23
No files found.
mysql-test/r/loaddata.result
View file @
f4025aa8
...
...
@@ -503,4 +503,33 @@ DROP TABLE t1;
CREATE TABLE t1 (id INT NOT NULL);
LOAD DATA LOCAL INFILE 'tb.txt' INTO TABLE t1;
DROP TABLE t1;
#
# Bug #51876 : crash/memory underrun when loading data with ucs2
# and reverse() function
#
# Problem # 1 (original report): wrong parsing of ucs2 data
SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt';
CREATE TABLE t1(a INT);
LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2
(@b) SET a=REVERSE(@b);
Warnings:
Warning 1366 Incorrect integer value: '?' for column 'a' at row 1
Warning 1366 Incorrect integer value: '?' for column 'a' at row 2
# should return 2 zeroes (as the value is truncated)
SELECT * FROM t1;
a
0
0
DROP TABLE t1;
# Problem # 2 : if you write and read ucs2 data to a file they're lost
SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2;
CREATE TABLE t1(a INT);
LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2
(@b) SET a=REVERSE(@b);
# should return 0 and 1 (10 reversed)
SELECT * FROM t1;
a
0
1
DROP TABLE t1;
End of 5.1 tests
mysql-test/t/loaddata.test
View file @
f4025aa8
...
...
@@ -570,4 +570,36 @@ DROP TABLE t1;
connection
default
;
disconnect
con1
;
--
echo
#
--
echo
# Bug #51876 : crash/memory underrun when loading data with ucs2
--
echo
# and reverse() function
--
echo
#
--
echo
# Problem # 1 (original report): wrong parsing of ucs2 data
SELECT
'00'
UNION
SELECT
'10'
INTO
OUTFILE
'tmpp.txt'
;
CREATE
TABLE
t1
(
a
INT
);
LOAD
DATA
INFILE
'tmpp.txt'
INTO
TABLE
t1
CHARACTER
SET
ucs2
(
@
b
)
SET
a
=
REVERSE
(
@
b
);
--
echo
# should return 2 zeroes (as the value is truncated)
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
remove_file
$MYSQLD_DATADIR
/
test
/
tmpp
.
txt
;
--
echo
# Problem # 2 : if you write and read ucs2 data to a file they're lost
SELECT
'00'
UNION
SELECT
'10'
INTO
OUTFILE
'tmpp2.txt'
CHARACTER
SET
ucs2
;
CREATE
TABLE
t1
(
a
INT
);
LOAD
DATA
INFILE
'tmpp2.txt'
INTO
TABLE
t1
CHARACTER
SET
ucs2
(
@
b
)
SET
a
=
REVERSE
(
@
b
);
--
echo
# should return 0 and 1 (10 reversed)
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
remove_file
$MYSQLD_DATADIR
/
test
/
tmpp2
.
txt
;
--
echo
End
of
5.1
tests
sql/item_func.cc
View file @
f4025aa8
...
...
@@ -5066,6 +5066,7 @@ bool Item_func_get_user_var::set_value(THD *thd,
bool
Item_user_var_as_out_param
::
fix_fields
(
THD
*
thd
,
Item
**
ref
)
{
DBUG_ASSERT
(
fixed
==
0
);
DBUG_ASSERT
(
thd
->
lex
->
exchange
);
if
(
Item
::
fix_fields
(
thd
,
ref
)
||
!
(
entry
=
get_variable
(
&
thd
->
user_vars
,
name
,
1
)))
return
TRUE
;
...
...
@@ -5075,7 +5076,9 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
of fields in LOAD DATA INFILE.
(Since Item_user_var_as_out_param is used only there).
*/
entry
->
collation
.
set
(
thd
->
variables
.
collation_database
);
entry
->
collation
.
set
(
thd
->
lex
->
exchange
->
cs
?
thd
->
lex
->
exchange
->
cs
:
thd
->
variables
.
collation_database
);
entry
->
update_query_id
=
thd
->
query_id
;
return
FALSE
;
}
...
...
sql/sql_load.cc
View file @
f4025aa8
...
...
@@ -1441,29 +1441,6 @@ int READ_INFO::read_field()
while
(
to
<
end_of_buff
)
{
chr
=
GET
;
#ifdef USE_MB
if
((
my_mbcharlen
(
read_charset
,
chr
)
>
1
)
&&
to
+
my_mbcharlen
(
read_charset
,
chr
)
<=
end_of_buff
)
{
uchar
*
p
=
(
uchar
*
)
to
;
*
to
++
=
chr
;
int
ml
=
my_mbcharlen
(
read_charset
,
chr
);
int
i
;
for
(
i
=
1
;
i
<
ml
;
i
++
)
{
chr
=
GET
;
if
(
chr
==
my_b_EOF
)
goto
found_eof
;
*
to
++
=
chr
;
}
if
(
my_ismbchar
(
read_charset
,
(
const
char
*
)
p
,
(
const
char
*
)
to
))
continue
;
for
(
i
=
0
;
i
<
ml
;
i
++
)
PUSH
((
uchar
)
*--
to
);
chr
=
GET
;
}
#endif
if
(
chr
==
my_b_EOF
)
goto
found_eof
;
if
(
chr
==
escape_char
)
...
...
@@ -1547,6 +1524,39 @@ int READ_INFO::read_field()
return
0
;
}
}
#ifdef USE_MB
if
(
my_mbcharlen
(
read_charset
,
chr
)
>
1
&&
to
+
my_mbcharlen
(
read_charset
,
chr
)
<=
end_of_buff
)
{
uchar
*
p
=
(
uchar
*
)
to
;
int
ml
,
i
;
*
to
++
=
chr
;
ml
=
my_mbcharlen
(
read_charset
,
chr
);
for
(
i
=
1
;
i
<
ml
;
i
++
)
{
chr
=
GET
;
if
(
chr
==
my_b_EOF
)
{
/*
Need to back up the bytes already ready from illformed
multi-byte char
*/
to
-=
i
;
goto
found_eof
;
}
*
to
++
=
chr
;
}
if
(
my_ismbchar
(
read_charset
,
(
const
char
*
)
p
,
(
const
char
*
)
to
))
continue
;
for
(
i
=
0
;
i
<
ml
;
i
++
)
PUSH
((
uchar
)
*--
to
);
chr
=
GET
;
}
#endif
*
to
++
=
(
uchar
)
chr
;
}
/*
...
...
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