Commit 336acaf7 authored by Matthias Leich's avatar Matthias Leich

Merge actual bugteam tree -> local tree

parents 5c58d353 3f966ec7
...@@ -41,6 +41,7 @@ drop table t1; ...@@ -41,6 +41,7 @@ drop table t1;
# Test for testable InnoDB status variables. This test # Test for testable InnoDB status variables. This test
# uses previous ones(pages_created, rows_deleted, ...). # uses previous ones(pages_created, rows_deleted, ...).
-- replace_regex /51[12]/51_/
show status like "Innodb_buffer_pool_pages_total"; show status like "Innodb_buffer_pool_pages_total";
show status like "Innodb_page_size"; show status like "Innodb_page_size";
show status like "Innodb_rows_deleted"; show status like "Innodb_rows_deleted";
......
...@@ -337,6 +337,126 @@ DROP VIEW v2; ...@@ -337,6 +337,126 @@ DROP VIEW v2;
DROP VIEW v3; DROP VIEW v3;
# -- End of Bug#35469. # -- End of Bug#35469.
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;
test LOAD DATA INFILE
SET sql_mode = '';
SELECT '1 \\aa\n' INTO DUMPFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt';
CREATE TABLE t1 (id INT, val1 CHAR(3)) ENGINE=MyISAM;
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' REPLACE INTO TABLE t1 FIELDS TERMINATED BY ' ';
SELECT * FROM t1;
id val1
1 \aa
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114_out.txt' FIELDS ESCAPED BY '' TERMINATED BY ' ' FROM t1;
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114_out.txt' FIELDS TERMINATED BY ' ' FROM t1;
INSERT INTO t1 (id, val1) VALUES (1, '\aa');
SELECT * FROM t1;
id val1
1 \aa
1 \aa
SET sql_mode='';
INSERT INTO t1 (id, val1) VALUES (1, '\aa');
SELECT * FROM t1;
id val1
1 \aa
1 \aa
1 aa
DROP TABLE t1;
test SELECT INTO OUTFILE
CREATE TABLE t1 (id INT PRIMARY KEY, val1 CHAR(4));
CREATE TABLE t2 LIKE t1;
SET sql_mode = '';
INSERT INTO t1 (id, val1) VALUES (5, '\ttab');
INSERT INTO t1 (id, val1) VALUES (4, '\\r');
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
INSERT INTO t1 (id, val1) VALUES (3, '\tx');
1.1 NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' FIELDS TERMINATED BY ' ' FROM t1 ORDER BY id;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' INTO TABLE t2 FIELDS TERMINATED BY ' ';
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
t id val1 hex(val1)
before 3 \tx 5C7478
after 3 \tx 5C7478
before 4 \r 5C72
after 4 \r 5C72
before 5 tab 09746162
after 5 tab 09746162
TRUNCATE t2;
SELECT LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt");
LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt")
3 \tx
4 \r
5 tab
1.2 NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' FIELDS ESCAPED BY '\' TERMINATED BY ' ' FROM t1 ORDER BY id;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' INTO TABLE t2 FIELDS ESCAPED BY '\' TERMINATED BY ' ';
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
t id val1 hex(val1)
before 3 \tx 5C7478
after 3 \tx 5C7478
before 4 \r 5C72
after 4 \r 5C72
before 5 tab 09746162
after 5 tab 09746162
TRUNCATE t2;
SELECT LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt");
LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt")
3 \\tx
4 \\r
5 tab
SET sql_mode = '';
2.1 !NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' FIELDS TERMINATED BY ' ' FROM t1 ORDER BY id;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' INTO TABLE t2 FIELDS TERMINATED BY ' ';
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
t id val1 hex(val1)
before 3 \tx 5C7478
after 3 \tx 5C7478
before 4 \r 5C72
after 4 \r 5C72
before 5 tab 09746162
after 5 tab 09746162
TRUNCATE t2;
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
SELECT LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt");
LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt")
3 \\tx
4 \\r
5 tab
SET sql_mode = '';
2.2 !NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' FIELDS ESCAPED BY '' TERMINATED BY ' ' FROM t1 ORDER BY id;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug37114.txt' INTO TABLE t2 FIELDS ESCAPED BY '' TERMINATED BY ' ';
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
t id val1 hex(val1)
before 3 \tx 5C7478
after 3 \tx 5C7478
before 4 \r 5C72
after 4 \r 5C72
before 5 tab 09746162
after 5 tab 09746162
TRUNCATE t2;
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
SELECT LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt");
LOAD_FILE("MYSQLTEST_VARDIR/tmp/bug37114.txt")
3 \tx
4 \r
5 tab
set session sql_mode=@OLD_SQL_MODE;
DROP TABLE t1,t2;
End of 5.0 tests
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
SET NAMES latin1; SET NAMES latin1;
...@@ -364,3 +484,4 @@ SET character_set_filesystem=default; ...@@ -364,3 +484,4 @@ SET character_set_filesystem=default;
select @@character_set_filesystem; select @@character_set_filesystem;
@@character_set_filesystem @@character_set_filesystem
binary binary
End of 5.1 tests
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 0
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 0
drop table if exists t1;
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 1
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
begin;
delete from t1;
commit;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 2
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
drop table t1;
show status like "Innodb_buffer_pool_pages_total";
Variable_name Value
Innodb_buffer_pool_pages_total 51_
show status like "Innodb_page_size";
Variable_name Value
Innodb_page_size 16384
show status like "Innodb_rows_deleted";
Variable_name Value
Innodb_rows_deleted 2000
show status like "Innodb_rows_inserted";
Variable_name Value
Innodb_rows_inserted 2000
show status like "Innodb_rows_updated";
Variable_name Value
Innodb_rows_updated 0
...@@ -24,7 +24,7 @@ Binlog_cache_disk_use 1 ...@@ -24,7 +24,7 @@ Binlog_cache_disk_use 1
drop table t1; drop table t1;
show status like "Innodb_buffer_pool_pages_total"; show status like "Innodb_buffer_pool_pages_total";
Variable_name Value Variable_name Value
Innodb_buffer_pool_pages_total 512 Innodb_buffer_pool_pages_total 51_
show status like "Innodb_page_size"; show status like "Innodb_page_size";
Variable_name Value Variable_name Value
Innodb_page_size 16384 Innodb_page_size 16384
......
...@@ -24,7 +24,7 @@ Binlog_cache_disk_use 1 ...@@ -24,7 +24,7 @@ Binlog_cache_disk_use 1
drop table t1; drop table t1;
show status like "Innodb_buffer_pool_pages_total"; show status like "Innodb_buffer_pool_pages_total";
Variable_name Value Variable_name Value
Innodb_buffer_pool_pages_total 512 Innodb_buffer_pool_pages_total 51_
show status like "Innodb_page_size"; show status like "Innodb_page_size";
Variable_name Value Variable_name Value
Innodb_page_size 16384 Innodb_page_size 16384
......
# This is a wrapper for binlog.test so that the same test case can be used
# For both statement and row based bin logs 9/19/2005 [jbm]
-- source include/have_binlog_format_mixed.inc
-- source extra/binlog_tests/innodb_stat.test
# This is a wrapper for binlog.test so that the same test case can be used # This is a wrapper for binlog.test so that the same test case can be used
# For both statement and row based bin logs 9/19/2005 [jbm] # For both statement and row based bin logs 9/19/2005 [jbm]
-- source include/have_binlog_format_mixed_or_statement.inc -- source include/have_binlog_format_statement.inc
-- source extra/binlog_tests/innodb_stat.test -- source extra/binlog_tests/innodb_stat.test
...@@ -320,9 +320,191 @@ DROP VIEW v3; ...@@ -320,9 +320,191 @@ DROP VIEW v3;
--echo --echo
--echo # -- End of Bug#35469. --echo # -- End of Bug#35469.
########################################################################### ###########################################################################
# End of 5.0 tests #
# Bug#37114: sql_mode NO_BACKSLASH_ESCAPES does not work properly with
# LOAD DATA INFILE
#
# - For each plain "SELECT id,...", the 1st pair ("before" SELECT...OUTFILE,
# LOAD...INFILE) and the 2nd pair of lines ("after") in the result should
# look the same, otherwise we broke the dumpe/restore cycle!
#
# - the \r is always { '\\', 'r' } in memory, but on-disk format changes
#
# - the \t is { '\t' } or { '\\', 't' } in memory depending on whether \
# is magic (that is, NO_BACKSLASH_ESCAPES is not set) at INSERT-time.
# on-disk format varies.
#
# - while INFILE/OUTFILE behaviour changes according to NO_BACKSLASH_ESCAPES,
# we can override these defaults using ESCAPED BY '...'
# 1: NO_BACKSLASH_ESCAPES default, \ on-disk: \,t,x,\r
# 2: NO_BACKSLASH_ESCAPES override, \\ on-disk: \,\,t,x,\,\,r
# 3: !NO_BACKSLASH_ESCAPES default, \\ on-disk: tab,\,\,r
# 3: !NO_BACKSLASH_ESCAPES override, \ on-disk: tab,\,r
--echo 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;
# 0. test LOAD DATA INFILE first; if that works, all issues in
# SELECT INTO OUTFILE / LOAD DATA INFILE cycles below are
# arguably in the saving.
--echo test LOAD DATA INFILE
--let $file=$MYSQLTEST_VARDIR/tmp/bug37114.txt
--let $file2=$MYSQLTEST_VARDIR/tmp/bug37114_out.txt
SET sql_mode = '';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT '1 \\\\aa\n' INTO DUMPFILE '$file'
CREATE TABLE t1 (id INT, val1 CHAR(3)) ENGINE=MyISAM;
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA INFILE '$file' REPLACE INTO TABLE t1 FIELDS TERMINATED BY ' '
SELECT * FROM t1;
# show we can write this with OUTFILE, forcing the parameters for now
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file2' FIELDS ESCAPED BY '' TERMINATED BY ' ' FROM t1
--diff_files $file $file2
--remove_file $file2
# now show the OUTFILE defaults are correct with NO_BACKSLASH_ESCAPES
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file2' FIELDS TERMINATED BY ' ' FROM t1
--diff_files $file $file2
--remove_file $file2
INSERT INTO t1 (id, val1) VALUES (1, '\aa');
SELECT * FROM t1;
SET sql_mode='';
INSERT INTO t1 (id, val1) VALUES (1, '\aa');
SELECT * FROM t1;
DROP TABLE t1;
--remove_file $file
--echo test SELECT INTO OUTFILE
CREATE TABLE t1 (id INT PRIMARY KEY, val1 CHAR(4));
CREATE TABLE t2 LIKE t1;
# 1. with NO_BACKSLASH_ESCAPES on
SET sql_mode = '';
INSERT INTO t1 (id, val1) VALUES (5, '\ttab');
INSERT INTO t1 (id, val1) VALUES (4, '\\r');
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
INSERT INTO t1 (id, val1) VALUES (3, '\tx');
--echo 1.1 NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file' FIELDS TERMINATED BY ' ' FROM t1 ORDER BY id
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS TERMINATED BY ' '
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
TRUNCATE t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT LOAD_FILE("$file");
--remove_file $file
--echo 1.2 NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file' FIELDS ESCAPED BY '\' TERMINATED BY ' ' FROM t1 ORDER BY id
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS ESCAPED BY '\' TERMINATED BY ' '
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
TRUNCATE t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT LOAD_FILE("$file");
--remove_file $file
# 2. with NO_BACKSLASH_ESCAPES off
SET sql_mode = '';
--echo 2.1 !NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file' FIELDS TERMINATED BY ' ' FROM t1 ORDER BY id
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS TERMINATED BY ' '
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
TRUNCATE t2;
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT LOAD_FILE("$file");
--remove_file $file
SET sql_mode = '';
--echo 2.2 !NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT * INTO OUTFILE '$file' FIELDS ESCAPED BY '' TERMINATED BY ' ' FROM t1 ORDER BY id
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS ESCAPED BY '' TERMINATED BY ' '
SELECT 'before' AS t, id, val1, hex(val1) FROM t1 UNION
SELECT 'after' AS t, id, val1, hex(val1) FROM t2 ORDER BY id,t DESC;
TRUNCATE t2;
SET sql_mode = 'NO_BACKSLASH_ESCAPES';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT LOAD_FILE("$file");
--remove_file $file
# clean up
set session sql_mode=@OLD_SQL_MODE;
DROP TABLE t1,t2;
--echo End of 5.0 tests
# #
...@@ -347,3 +529,7 @@ DROP TABLE t1; ...@@ -347,3 +529,7 @@ DROP TABLE t1;
remove_file $MYSQLTEST_VARDIR/master-data/test/t@002d1; remove_file $MYSQLTEST_VARDIR/master-data/test/t@002d1;
SET character_set_filesystem=default; SET character_set_filesystem=default;
select @@character_set_filesystem; select @@character_set_filesystem;
--echo End of 5.1 tests
...@@ -1481,6 +1481,12 @@ sql_exchange::sql_exchange(char *name,bool flag) ...@@ -1481,6 +1481,12 @@ sql_exchange::sql_exchange(char *name,bool flag)
cs= NULL; cs= NULL;
} }
bool sql_exchange::escaped_given(void)
{
return escaped != &default_escaped;
}
bool select_send::send_fields(List<Item> &list, uint flags) bool select_send::send_fields(List<Item> &list, uint flags)
{ {
bool res; bool res;
...@@ -1766,8 +1772,11 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u) ...@@ -1766,8 +1772,11 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
exchange->line_term=exchange->field_term; // Use this if it exists exchange->line_term=exchange->field_term; // Use this if it exists
field_sep_char= (exchange->enclosed->length() ? field_sep_char= (exchange->enclosed->length() ?
(int) (uchar) (*exchange->enclosed)[0] : field_term_char); (int) (uchar) (*exchange->enclosed)[0] : field_term_char);
escape_char= (exchange->escaped->length() ? if (exchange->escaped->length() && (exchange->escaped_given() ||
(int) (uchar) (*exchange->escaped)[0] : -1); !(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)))
escape_char= (int) (uchar) (*exchange->escaped)[0];
else
escape_char= -1;
is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char)); is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char)); is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char));
line_sep_char= (exchange->line_term->length() ? line_sep_char= (exchange->line_term->length() ?
......
...@@ -2250,6 +2250,7 @@ public: ...@@ -2250,6 +2250,7 @@ public:
ulong skip_lines; ulong skip_lines;
CHARSET_INFO *cs; CHARSET_INFO *cs;
sql_exchange(char *name,bool dumpfile_flag); sql_exchange(char *name,bool dumpfile_flag);
bool escaped_given(void);
}; };
#include "log_event.h" #include "log_event.h"
......
...@@ -327,7 +327,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -327,7 +327,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
bzero((char*) &info,sizeof(info)); bzero((char*) &info,sizeof(info));
info.ignore= ignore; info.ignore= ignore;
info.handle_duplicates=handle_duplicates; info.handle_duplicates=handle_duplicates;
info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX; info.escape_char= (escaped->length() && (ex->escaped_given() ||
!(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES)))
? (*escaped)[0] : INT_MAX;
READ_INFO read_info(file,tot_length, READ_INFO read_info(file,tot_length,
ex->cs ? ex->cs : thd->variables.collation_database, ex->cs ? ex->cs : thd->variables.collation_database,
......
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