diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-09-22 16:39:05 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-09-28 12:04:26 +0400 |
commit | 54db387410b2a4f2bd6a1eacd5979a974b4f5389 (patch) | |
tree | 971efe7d3c0f732ef527ae01a5aeb90832206bf1 /mysql-test/suite/csv | |
parent | bca5894d519fc1aa1d2619257ee772060eeaf36a (diff) | |
download | mariadb-git-54db387410b2a4f2bd6a1eacd5979a974b4f5389.tar.gz |
MDEV-8682 - CSV engine does not properly process "", in quotes
Added per-table boolean IETF_QUOTES variable to CSV storage engine. It allows to
enable IETF-compatible parsing of embedded quote and comma characters. Disabled
by default.
This patch is based on Percona revision:
https://github.com/percona/percona-server/commit/b32fbf02766f8db00f9ff4e6dc05a1df97c10ff7
Note that original patch adds server variable, while this patch adds per-table
variable.
Diffstat (limited to 'mysql-test/suite/csv')
-rw-r--r-- | mysql-test/suite/csv/csv.result | 54 | ||||
-rw-r--r-- | mysql-test/suite/csv/csv.test | 43 |
2 files changed, 97 insertions, 0 deletions
diff --git a/mysql-test/suite/csv/csv.result b/mysql-test/suite/csv/csv.result index 8d497f52b31..5f1b380f96b 100644 --- a/mysql-test/suite/csv/csv.result +++ b/mysql-test/suite/csv/csv.result @@ -5493,3 +5493,57 @@ RENAME TABLE t1 TO t2; SELECT * FROM t2; a DROP TABLE t2; +# +# MDEV-8664 - plugins.show_all_plugins --embedded fails in buildbot +# +CREATE TABLE t1(c1 TEXT NOT NULL, c2 TEXT NOT NULL) ENGINE=CSV IETF_QUOTES=yes; +INSERT INTO t1 VALUES("a\"b,c","d"); +INSERT INTO t1 VALUES("d","a\"b,c"); +INSERT INTO t1 VALUES(",\"a","e"); +INSERT INTO t1 VALUES("e",",\"a"); +INSERT INTO t1 VALUES("\"","f"); +INSERT INTO t1 VALUES("f","\""); +INSERT INTO t1 VALUES(",","g"); +INSERT INTO t1 VALUES("g",","); +SELECT * FROM t1; +c1 c2 +a"b,c d +d a"b,c +,"a e +e ,"a +" f +f " +, g +g , +CSV file contents: +"a""b,c","d" +"d","a""b,c" +",""a","e" +"e",",""a" +"""","f" +"f","""" +",","g" +"g","," +DROP TABLE t1; +CREATE TABLE t1(c1 TEXT NOT NULL, c2 TEXT NOT NULL) ENGINE=CSV IETF_QUOTES=yes; +Replacing t1.CSV +SELECT * FROM t1; +c1 c2 +a b +a b +a"b,c d +d ,"a +a", e +e " +, f +ALTER TABLE t1 IETF_QUOTES=no; +SELECT * FROM t1; +c1 c2 +a b +a b +a"b,c d +d ,"a +a", e +e " +, f +DROP TABLE t1; diff --git a/mysql-test/suite/csv/csv.test b/mysql-test/suite/csv/csv.test index 90617d06599..f274eea3236 100644 --- a/mysql-test/suite/csv/csv.test +++ b/mysql-test/suite/csv/csv.test @@ -1926,3 +1926,46 @@ move_file $MYSQLD_DATADIR/test/t1.CSV $MYSQLD_DATADIR/test/t2.CSV; RENAME TABLE t1 TO t2; SELECT * FROM t2; DROP TABLE t2; + +--echo # +--echo # MDEV-8664 - plugins.show_all_plugins --embedded fails in buildbot +--echo # +CREATE TABLE t1(c1 TEXT NOT NULL, c2 TEXT NOT NULL) ENGINE=CSV IETF_QUOTES=yes; + +INSERT INTO t1 VALUES("a\"b,c","d"); +INSERT INTO t1 VALUES("d","a\"b,c"); +INSERT INTO t1 VALUES(",\"a","e"); +INSERT INTO t1 VALUES("e",",\"a"); +INSERT INTO t1 VALUES("\"","f"); +INSERT INTO t1 VALUES("f","\""); +INSERT INTO t1 VALUES(",","g"); +INSERT INTO t1 VALUES("g",","); + +SELECT * FROM t1; + +--echo CSV file contents: +--cat_file $MYSQLD_DATADIR/test/t1.CSV + +DROP TABLE t1; + +CREATE TABLE t1(c1 TEXT NOT NULL, c2 TEXT NOT NULL) ENGINE=CSV IETF_QUOTES=yes; + +--echo Replacing t1.CSV +--remove_file $MYSQLD_DATADIR/test/t1.CSV +--write_file $MYSQLD_DATADIR/test/t1.CSV +a,b +"a","b" +"a""b,c","d" +"d",",""a" +"a"",",e +e,"""" +",",f +EOF + +SELECT * FROM t1; + +ALTER TABLE t1 IETF_QUOTES=no; + +SELECT * FROM t1; + +DROP TABLE t1; |