diff options
author | unknown <ram@gw.mysql.r18.ru> | 2004-10-10 14:40:24 +0500 |
---|---|---|
committer | unknown <ram@gw.mysql.r18.ru> | 2004-10-10 14:40:24 +0500 |
commit | 692c4ee4e421a64fb6a53c98a953a82cbb2d1672 (patch) | |
tree | 9ef5f0dc0dea0e0ce7b0f684ebcc23281136a01d | |
parent | d9f53f22d18d3fb45784deaae35601bc407555db (diff) | |
download | mariadb-git-692c4ee4e421a64fb6a53c98a953a82cbb2d1672.tar.gz |
A fix (bug #5382: Server crashes after writing INTO OUTFILE)
-rw-r--r-- | mysql-test/r/outfile.result | 10 | ||||
-rw-r--r-- | mysql-test/t/outfile.test | 16 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 54 |
3 files changed, 63 insertions, 17 deletions
diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result new file mode 100644 index 00000000000..4dc09f65b7c --- /dev/null +++ b/mysql-test/r/outfile.result @@ -0,0 +1,10 @@ +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; diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index a7b81d565e6..28d5ebfaf99 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -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; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 48792962eb9..c040357a5da 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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 */ |