Hi!
On Jun 13, Tatiana A. Nurnberg wrote:
> #At file:///misc/mysql/forest/37114/51-37114/
>
> 2661 Tatiana A. Nurnberg 2008-06-13
> Bug#37114: sql_mode NO_BACKSLASH_ESCAPES does not work properly with LOAD DATA
> INFILE
>
> NO_BACKSLASH_ESCAPES was not heeded in LOAD DATA INFILE
> and SELECT INTO OUTFILE. It is now.
> === modified file 'mysql-test/r/loaddata.result'
> --- a/mysql-test/r/loaddata.result 2008-03-28 21:05:20 +0000
> +++ b/mysql-test/r/loaddata.result 2008-06-13 17:12:45 +0000
> @@ -364,3 +364,91 @@ SET character_set_filesystem=default;
> select @@character_set_filesystem;
> @@character_set_filesystem
> binary
> +Bug#37114
> +SET SESSION character_set_client=latin1;
> +SET SESSION character_set_server=latin1;
> +SET SESSION character_set_connection=latin1;
> +SET @OLD_SQL_MODE=@@SESSION.SQL_MODE;
> +SET sql_mode = '';
> +CREATE TABLE t1 (id INT PRIMARY KEY, val1 CHAR(4));
> +1.1 NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY
> +INSERT INTO t1 (id, val1) VALUES (4, '\\r');
> +SET sql_mode = 'NO_BACKSLASH_ESCAPES';
> +INSERT INTO t1 (id, val1) VALUES (3, '\tx');
> +SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' FIELDS TERMINATED BY ' '
> FROM t1 ORDER BY id;
> +UPDATE t1 SET id=id-2;
> +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' INTO TABLE t1 FIELDS TERMINATED
> BY ' ';
> +SELECT id,val1,HEX(val1) FROM t1 ORDER BY id;
> +id val1 HEX(val1)
> +1 \tx 5C7478
> +2 \r 5C72
> +3 \tx 5C7478
> +4 \r 5C72
> +TRUNCATE t1;
> +SELECT
> LOAD_FILE("/misc/mysql/forest/37114/51-37114/mysql-test/var/tmp/bug37114.txt");
> +LOAD_FILE("/misc/mysql/forest/37114/51-37114/mysql-test/var/tmp/bug37114.txt")
here and below, path in the LOAD_FILE().
A suggestion: Don't load data for each of your four tests, so that I
wouldn't need to vdiff them, so that one could see that you use the same
data in all tests.
You can do it as
CREATE TABLE t1 (...);
INSERT t1 ...
CREATE TABLE t2 LIKE t1;
-- tests
SELECT * FROM t1 INTO OUTFILE ...
LOAD DATA INFILE ... TABLE t2 ...
SELECT 'before', id, val1, hex(val1) FROM t1 UNION
SELECT 'after', id, val1, hex(val1) FROM t2;
TRUNCATE t2;
-- another test...
That is, t1 is never changed during the tests, and data are loaded into
it only once - it's obvious that the same data is used in all four
tests.
> +3 \tx
> +4 \r
> +
> +1.2 NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY
> +SET sql_mode = '';
...
> === modified file 'sql/sql_yacc.yy'
> --- a/sql/sql_yacc.yy 2008-05-20 07:38:17 +0000
> +++ b/sql/sql_yacc.yy 2008-06-13 17:12:45 +0000
> @@ -8463,8 +8463,9 @@ into_destination:
> OUTFILE TEXT_STRING_filesystem
> {
> LEX *lex= Lex;
> + THD *thd= YYTHD;
> lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
> - if (!(lex->exchange= new sql_exchange($2.str, 0)) ||
> + if (!(lex->exchange= new sql_exchange($2.str, 0,
> (thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES))) ||
I'm not sure it's correct. You need to take the value of
MODE_NO_BACKSLASH_ESCAPES when the statement is executed, not when it's
parsed.
> !(lex->result= new select_export(lex->exchange,
> lex->nest_level)))
> MYSQL_YYABORT;
> }
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect
/_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028
<___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring