Skip to content

Commit fb7d212

Browse files
committed
Add CVS \r\n regression tests.
Andrew Dunstan
1 parent 888271e commit fb7d212

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/test/regress/input/copy.source

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,36 @@ COPY bt_txt_heap FROM '@abs_srcdir@/data/desc.data';
5454

5555
COPY bt_f8_heap FROM '@abs_srcdir@/data/hash.data';
5656

57+
--- test copying in CSV mode with various styles
58+
--- of embedded line ending characters
59+
60+
create temp table copytest (
61+
style text,
62+
test text,
63+
filler int);
64+
65+
insert into copytest values('DOS','abc\r\ndef',1);
66+
insert into copytest values('Unix','abc\ndef',2);
67+
insert into copytest values('Mac','abc\rdef',3);
68+
insert into copytest values('esc\\ape','a\\r\\\r\\\n\\nb',4);
69+
70+
copy copytest to '@abs_builddir@/results/copytest.csv' csv;
71+
72+
create temp table copytest2 (like copytest);
73+
74+
copy copytest2 from '@abs_builddir@/results/copytest.csv' csv;
75+
76+
select * from copytest except select * from copytest2;
77+
78+
truncate copytest2;
79+
80+
--- same test but with an escape char different from quote char
81+
82+
copy copytest to '@abs_builddir@/results/copytest.csv' csv quote '\'' escape '\\';
83+
84+
copy copytest2 from '@abs_builddir@/results/copytest.csv' csv quote '\'' escape '\\';
85+
86+
select * from copytest except select * from copytest2;
87+
88+
89+

src/test/regress/output/copy.source

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,30 @@ COPY bt_i4_heap FROM '@abs_srcdir@/data/desc.data';
3131
COPY bt_name_heap FROM '@abs_srcdir@/data/hash.data';
3232
COPY bt_txt_heap FROM '@abs_srcdir@/data/desc.data';
3333
COPY bt_f8_heap FROM '@abs_srcdir@/data/hash.data';
34+
--- test copying in CSV mode with various styles
35+
--- of embedded line ending characters
36+
create temp table copytest (
37+
style text,
38+
test text,
39+
filler int);
40+
insert into copytest values('DOS','abc\r\ndef',1);
41+
insert into copytest values('Unix','abc\ndef',2);
42+
insert into copytest values('Mac','abc\rdef',3);
43+
insert into copytest values('esc\\ape','a\\r\\\r\\\n\\nb',4);
44+
copy copytest to '@abs_builddir@/results/copytest.csv' csv;
45+
create temp table copytest2 (like copytest);
46+
copy copytest2 from '@abs_builddir@/results/copytest.csv' csv;
47+
select * from copytest except select * from copytest2;
48+
style | test | filler
49+
-------+------+--------
50+
(0 rows)
51+
52+
truncate copytest2;
53+
--- same test but with an escape char different from quote char
54+
copy copytest to '@abs_builddir@/results/copytest.csv' csv quote '\'' escape '\\';
55+
copy copytest2 from '@abs_builddir@/results/copytest.csv' csv quote '\'' escape '\\';
56+
select * from copytest except select * from copytest2;
57+
style | test | filler
58+
-------+------+--------
59+
(0 rows)
60+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy