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 @@
# test of into outfile|dumpfile
#
--disable_warnings
drop table if exists t1;
--enable_warnings
# We need to check that we have 'file' privilege.
#drop table if exists t1;
......@@ -26,3 +30,15 @@
#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb");
#select * from t into outfile "check";
#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,15 +3870,11 @@ select_var_ident: '@' ident_or_text
into:
INTO OUTFILE TEXT_STRING_sys
{
LEX *lex=Lex;
if (!lex->describe)
{
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($3.str,0)))
YYABORT;
if (!(lex->result= new select_export(lex->exchange)))
YYABORT;
}
LEX *lex= Lex;
lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
if (!(lex->exchange= new sql_exchange($3.str, 0)) ||
!(lex->result= new select_export(lex->exchange)))
YYABORT;
}
opt_field_term opt_line_term
| INTO DUMPFILE TEXT_STRING_sys
......@@ -4721,15 +4717,28 @@ field_term_list:
| 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
{
LEX *lex=Lex;
LEX *lex= Lex;
DBUG_ASSERT(lex->exchange);
lex->exchange->enclosed= $4;
lex->exchange->opt_enclosed=1;
lex->exchange->opt_enclosed= 1;
}
| ENCLOSED BY text_string { Lex->exchange->enclosed= $3;}
| ESCAPED BY text_string { Lex->exchange->escaped= $3;};
| ENCLOSED BY text_string
{
DBUG_ASSERT(Lex->exchange);
Lex->exchange->enclosed= $3;
}
| ESCAPED BY text_string
{
DBUG_ASSERT(Lex->exchange);
Lex->exchange->escaped= $3;
};
opt_line_term:
/* empty */
......@@ -4740,13 +4749,24 @@ line_term_list:
| line_term;
line_term:
TERMINATED BY text_string { Lex->exchange->line_term= $3;}
| STARTING BY text_string { Lex->exchange->line_start= $3;};
TERMINATED BY text_string
{
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:
/* empty */
| IGNORE_SYM NUM LINES
{ Lex->exchange->skip_lines=atol($2.str); };
{
DBUG_ASSERT(Lex->exchange);
Lex->exchange->skip_lines= atol($2.str);
};
/* 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