stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: select ..into outfile, If there is a "ENCLOSED BY" string in the field, it should be escaped

Open davidshiz opened this issue 2 years ago • 0 comments

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • [X] I confirm there is no existing issue for this

Describe the problem

[root@stonedb-test std_data]# cat /stonedb57/install/mysql-test/test.csv
r1r     rrr
r2r     rrrr
r3r     rrrrr
r4r     rrrrrr
r5r     r.rr
r6r     r.rrr
r7r     r.rrrr
r8r     r.rrrrr
r9r     rr.r
r10r    rrr.r
r11r    rrrr.r
r12r    rrrrr.r
r13r    r.r.r
r14r    r.rr.r
r15r    r.rrr.r
r16r    r.rrrr.r

Expected behavior

[root@stonedb-test std_data]# cat /stonedb57/install/mysql-test/test.csv
r1r     rrrr
r2r     rrrrrr
r3r     rrrrrrrr
r4r     rrrrrrrrrr
r5r     r.rrr
r6r     r.rrrrr
r7r     r.rrrrrrr
r8r     r.rrrrrrrrr
r9r     rrr.r
r10r    rrrrr.r
r11r    rrrrrrr.r
r12r    rrrrrrrrr.r
r13r    r.rr.r
r14r    r.rrrr.r
r15r    r.rrrrrr.r
r16r    r.rrrrrrrr.r

How To Reproduce

CREATE TABLE t1 (
  id INT AUTO_INCREMENT PRIMARY KEY,
  c1 VARCHAR(255)
);

INSERT INTO t1 (c1) VALUES
  ('r'),   ('rr'),   ('rrr'),   ('rrrr'),
  ('.r'),  ('.rr'),  ('.rrr'),  ('.rrrr'),
  ('r.'),  ('rr.'),  ('rrr.'),  ('rrrr.'),
  ('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
SELECT * INTO OUTFILE '/stonedb57/install/mysql-test/test.csv' FIELDS ENCLOSED BY 'r' FROM t1;
cat /stonedb57/install/mysql-test/test.csv

Environment

[root@stonedb-test bin]# ./mysqld --version
./mysqld  Ver 5.7.36-StoneDB-v1.0.1 for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 12fa952
        Last commit time: Date:   Sat Jun 3 10:07:20 2023 +0800
        Build time: Date: Mon Jun  5 08:49:16 UTC 2023

Are you interested in submitting a PR to solve the problem?

  • [ ] Yes, I will!

davidshiz avatar Jun 07 '23 13:06 davidshiz