File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -54,3 +54,36 @@ COPY bt_txt_heap FROM '@abs_srcdir@/data/desc.data';
54
54
55
55
COPY bt_f8_heap FROM '@abs_srcdir@/data/hash.data';
56
56
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
+
Original file line number Diff line number Diff line change @@ -31,3 +31,30 @@ COPY bt_i4_heap FROM '@abs_srcdir@/data/desc.data';
31
31
COPY bt_name_heap FROM '@abs_srcdir@/data/hash.data';
32
32
COPY bt_txt_heap FROM '@abs_srcdir@/data/desc.data';
33
33
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
+
You can’t perform that action at this time.
0 commit comments