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
42699946
Commit
42699946
authored
Jul 04, 2007
by
gshchepa/uchum@gleb.loc
Browse files
Options
Browse Files
Download
Plain Diff
Merge gleb.loc:/home/uchum/work/bk/4.1-opt
into gleb.loc:/home/uchum/work/bk/5.0-opt
parents
24865012
0e8292c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
1 deletion
+103
-1
mysql-test/r/loaddata.result
mysql-test/r/loaddata.result
+54
-0
mysql-test/t/loaddata.test
mysql-test/t/loaddata.test
+35
-0
sql/sql_class.cc
sql/sql_class.cc
+4
-1
sql/sql_class.h
sql/sql_class.h
+9
-0
sql/sql_load.cc
sql/sql_load.cc
+1
-0
No files found.
mysql-test/r/loaddata.result
View file @
42699946
...
...
@@ -86,6 +86,60 @@ field1 field2
a"b cd"ef
a"b c"d"e
drop table t1;
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 VARCHAR(255)
);
CREATE TABLE t2 (
id INT,
c2 VARCHAR(255)
);
INSERT INTO t1 (c1) VALUES
('r'), ('rr'), ('rrr'), ('rrrr'),
('.r'), ('.rr'), ('.rrr'), ('.rrrr'),
('r.'), ('rr.'), ('rrr.'), ('rrrr.'),
('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
SELECT * FROM t1;
id c1
1 r
2 rr
3 rrr
4 rrrr
5 .r
6 .rr
7 .rrr
8 .rrrr
9 r.
10 rr.
11 rrr.
12 rrrr.
13 .r.
14 .rr.
15 .rrr.
16 .rrrr.
SELECT * INTO OUTFILE 'MYSQL_TEST_DIR/var/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
r1r rrrr
r2r rrrrrr
r3r rrrrrrrr
r4r rrrrrrrrrr
r5r r.rrr
r6r r.rrrrr
r7r r.rrrrrrr
r8r r.rrrrrrrrr
r9r rrr.r
r10r rrrrr.r
r11r rrrrrrr.r
r12r rrrrrrrrr.r
r13r r.rr.r
r14r r.rrrr.r
r15r r.rrrrrr.r
r16r r.rrrrrrrr.r
LOAD DATA INFILE 'MYSQL_TEST_DIR/var/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
SELECT t1.id, c1, c2 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
id c1 c2
SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
id c1 c2
DROP TABLE t1,t2;
create table t1 (a int default 100, b int, c varchar(60));
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
select * from t1;
...
...
mysql-test/t/loaddata.test
View file @
42699946
...
...
@@ -67,6 +67,41 @@ load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminate
select
*
from
t1
;
drop
table
t1
;
#
# Bug #29294 SELECT INTO OUTFILE/LOAD DATA INFILE with special
# characters in the FIELDS ENCLOSED BY clause
#
CREATE
TABLE
t1
(
id
INT
AUTO_INCREMENT
PRIMARY
KEY
,
c1
VARCHAR
(
255
)
);
CREATE
TABLE
t2
(
id
INT
,
c2
VARCHAR
(
255
)
);
INSERT
INTO
t1
(
c1
)
VALUES
(
'r'
),
(
'rr'
),
(
'rrr'
),
(
'rrrr'
),
(
'.r'
),
(
'.rr'
),
(
'.rrr'
),
(
'.rrrr'
),
(
'r.'
),
(
'rr.'
),
(
'rrr.'
),
(
'rrrr.'
),
(
'.r.'
),
(
'.rr.'
),
(
'.rrr.'
),
(
'.rrrr.'
);
SELECT
*
FROM
t1
;
--
exec
rm
-
f
$MYSQL_TEST_DIR
/
var
/
tmp
/
t1
--
replace_result
$MYSQL_TEST_DIR
MYSQL_TEST_DIR
eval
SELECT
*
INTO
OUTFILE
'$MYSQL_TEST_DIR/var/tmp/t1'
FIELDS
ENCLOSED
BY
'r'
FROM
t1
;
--
exec
cat
$MYSQL_TEST_DIR
/
var
/
tmp
/
t1
--
replace_result
$MYSQL_TEST_DIR
MYSQL_TEST_DIR
eval
LOAD
DATA
INFILE
'$MYSQL_TEST_DIR/var/tmp/t1'
INTO
TABLE
t2
FIELDS
ENCLOSED
BY
'r'
;
SELECT
t1
.
id
,
c1
,
c2
FROM
t1
LEFT
JOIN
t2
ON
t1
.
id
=
t2
.
id
WHERE
c1
!=
c2
;
SELECT
t1
.
id
,
c1
,
c2
FROM
t1
RIGHT
JOIN
t2
ON
t1
.
id
=
t2
.
id
WHERE
c1
!=
c2
;
--
exec
rm
$MYSQL_TEST_DIR
/
var
/
tmp
/
t1
DROP
TABLE
t1
,
t2
;
# End of 4.1 tests
#
...
...
sql/sql_class.cc
View file @
42699946
...
...
@@ -1209,6 +1209,7 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
field_sep_char
=
(
exchange
->
enclosed
->
length
()
?
(
*
exchange
->
enclosed
)[
0
]
:
field_term_length
?
(
*
exchange
->
field_term
)[
0
]
:
INT_MAX
);
escape_char
=
(
exchange
->
escaped
->
length
()
?
(
*
exchange
->
escaped
)[
0
]
:
-
1
);
is_ambiguous_field_sep
=
test
(
strchr
(
ESCAPE_CHARS
,
field_sep_char
));
line_sep_char
=
(
exchange
->
line_term
->
length
()
?
(
*
exchange
->
line_term
)[
0
]
:
INT_MAX
);
if
(
!
field_term_length
)
...
...
@@ -1349,7 +1350,9 @@ bool select_export::send_data(List<Item> &items)
NEED_ESCAPING
(
pos
[
1
])))
{
char
tmp_buff
[
2
];
tmp_buff
[
0
]
=
escape_char
;
tmp_buff
[
0
]
=
((
int
)
*
pos
==
field_sep_char
&&
is_ambiguous_field_sep
)
?
field_sep_char
:
escape_char
;
tmp_buff
[
1
]
=
*
pos
?
*
pos
:
'0'
;
if
(
my_b_write
(
&
cache
,(
byte
*
)
start
,(
uint
)
(
pos
-
start
))
||
my_b_write
(
&
cache
,(
byte
*
)
tmp_buff
,
2
))
...
...
sql/sql_class.h
View file @
42699946
...
...
@@ -1919,9 +1919,18 @@ public:
};
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
class
select_export
:
public
select_to_file
{
uint
field_term_length
;
int
field_sep_char
,
escape_char
,
line_sep_char
;
/*
The is_ambiguous_field_sep field is true if a value of the field_sep_char
field is one of the 'n', 't', 'r' etc characters
(see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
*/
bool
is_ambiguous_field_sep
;
bool
fixed_row_size
;
public:
select_export
(
sql_exchange
*
ex
)
:
select_to_file
(
ex
)
{}
...
...
sql/sql_load.cc
View file @
42699946
...
...
@@ -847,6 +847,7 @@ continue_loop:;
char
READ_INFO
::
unescape
(
char
chr
)
{
/* keep this switch synchornous with the ESCAPE_CHARS macro */
switch
(
chr
)
{
case
'n'
:
return
'\n'
;
case
't'
:
return
'\t'
;
...
...
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