Skip to content

Commit 659660c

Browse files
committed
Add regression tests for CSV COPY format.
1 parent 337f802 commit 659660c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/test/regress/expected/copy2.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ I'm null before trigger fired
172172
3 after trigger fired
173173
4 after trigger fired
174174
5 after trigger fired
175+
CREATE TABLE y (
176+
col1 text,
177+
col2 text
178+
);
179+
INSERT INTO y VALUES ('Jackson, Sam', '\\h');
180+
INSERT INTO y VALUES ('It is "perfect".','\t');
181+
INSERT INTO y VALUES ('', NULL);
182+
COPY y TO stdout WITH CSV;
183+
"Jackson, Sam",\h
184+
"It is ""perfect"".",
185+
"",
186+
COPY y TO stdout WITH CSV QUOTE '''' DELIMITER '|';
187+
Jackson, Sam|\h
188+
It is "perfect".|
189+
''|
190+
COPY y TO stdout WITH CSV FORCE QUOTE col2 ESCAPE '\\';
191+
"Jackson, Sam","\\h"
192+
"It is \"perfect\"."," "
193+
"",
175194
DROP TABLE x;
176195
DROP FUNCTION fn_x_before();
177196
DROP FUNCTION fn_x_after();

src/test/regress/sql/copy2.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ COPY x TO stdout;
116116
COPY x (c, e) TO stdout;
117117
COPY x (b, e) TO stdout WITH NULL 'I''m null';
118118

119+
CREATE TABLE y (
120+
col1 text,
121+
col2 text
122+
);
123+
124+
INSERT INTO y VALUES ('Jackson, Sam', '\\h');
125+
INSERT INTO y VALUES ('It is "perfect".','\t');
126+
INSERT INTO y VALUES ('', NULL);
127+
128+
COPY y TO stdout WITH CSV;
129+
COPY y TO stdout WITH CSV QUOTE '''' DELIMITER '|';
130+
COPY y TO stdout WITH CSV FORCE QUOTE col2 ESCAPE '\\';
131+
119132
DROP TABLE x;
120133
DROP FUNCTION fn_x_before();
121134
DROP FUNCTION fn_x_after();

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