Commit 48305dcd authored by ram@gw.mysql.r18.ru's avatar ram@gw.mysql.r18.ru

A fix (bug #5382: Server crashes after writing INTO OUTFILE)

parent 5e352def
drop table if exists t1;
CREATE TABLE t1 (a INT);
EXPLAIN
SELECT *
INTO OUTFILE '/tmp/t1.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
DROP TABLE t1;
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
# test of into outfile|dumpfile # test of into outfile|dumpfile
# #
--disable_warnings
drop table if exists t1;
--enable_warnings
# We need to check that we have 'file' privilege. # We need to check that we have 'file' privilege.
#drop table if exists t1; #drop table if exists t1;
...@@ -26,3 +30,15 @@ ...@@ -26,3 +30,15 @@
#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb"); #INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb");
#select * from t into outfile "check"; #select * from t into outfile "check";
#drop table if exists t; #drop table if exists t;
#
# Bug #5382: 'explain select into outfile' crashes the server
#
CREATE TABLE t1 (a INT);
EXPLAIN
SELECT *
INTO OUTFILE '/tmp/t1.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
FROM t1;
DROP TABLE t1;
...@@ -3870,16 +3870,12 @@ select_var_ident: '@' ident_or_text ...@@ -3870,16 +3870,12 @@ select_var_ident: '@' ident_or_text
into: into:
INTO OUTFILE TEXT_STRING_sys INTO OUTFILE TEXT_STRING_sys
{ {
LEX *lex=Lex; LEX *lex= Lex;
if (!lex->describe)
{
lex->uncacheable(UNCACHEABLE_SIDEEFFECT); lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($3.str,0))) if (!(lex->exchange= new sql_exchange($3.str, 0)) ||
YYABORT; !(lex->result= new select_export(lex->exchange)))
if (!(lex->result= new select_export(lex->exchange)))
YYABORT; YYABORT;
} }
}
opt_field_term opt_line_term opt_field_term opt_line_term
| INTO DUMPFILE TEXT_STRING_sys | INTO DUMPFILE TEXT_STRING_sys
{ {
...@@ -4721,15 +4717,28 @@ field_term_list: ...@@ -4721,15 +4717,28 @@ field_term_list:
| field_term; | field_term;
field_term: field_term:
TERMINATED BY text_string { Lex->exchange->field_term= $3;} TERMINATED BY text_string
{
DBUG_ASSERT(Lex->exchange);
Lex->exchange->field_term= $3;
}
| OPTIONALLY ENCLOSED BY text_string | OPTIONALLY ENCLOSED BY text_string
{ {
LEX *lex=Lex; LEX *lex= Lex;
DBUG_ASSERT(lex->exchange);
lex->exchange->enclosed= $4; lex->exchange->enclosed= $4;
lex->exchange->opt_enclosed=1; lex->exchange->opt_enclosed= 1;
} }
| ENCLOSED BY text_string { Lex->exchange->enclosed= $3;} | ENCLOSED BY text_string
| ESCAPED BY text_string { Lex->exchange->escaped= $3;}; {
DBUG_ASSERT(Lex->exchange);
Lex->exchange->enclosed= $3;
}
| ESCAPED BY text_string
{
DBUG_ASSERT(Lex->exchange);
Lex->exchange->escaped= $3;
};
opt_line_term: opt_line_term:
/* empty */ /* empty */
...@@ -4740,13 +4749,24 @@ line_term_list: ...@@ -4740,13 +4749,24 @@ line_term_list:
| line_term; | line_term;
line_term: line_term:
TERMINATED BY text_string { Lex->exchange->line_term= $3;} TERMINATED BY text_string
| STARTING BY text_string { Lex->exchange->line_start= $3;}; {
DBUG_ASSERT(Lex->exchange);
Lex->exchange->line_term= $3;
}
| STARTING BY text_string
{
DBUG_ASSERT(Lex->exchange);
Lex->exchange->line_start= $3;
};
opt_ignore_lines: opt_ignore_lines:
/* empty */ /* empty */
| IGNORE_SYM NUM LINES | IGNORE_SYM NUM LINES
{ Lex->exchange->skip_lines=atol($2.str); }; {
DBUG_ASSERT(Lex->exchange);
Lex->exchange->skip_lines= atol($2.str);
};
/* Common definitions */ /* Common definitions */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment