From 39650379c974d64631960510be12d88595249641 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Sun, 2 Jun 2024 18:50:30 -0400 Subject: [PATCH v2 2/4] Improve COPY test coverage for handling of control characters --- src/test/regress/expected/copy2.out | 38 +++++++++++++++++++++++++++++ src/test/regress/sql/copy2.sql | 25 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out index 931542f268..be654daf4a 100644 --- a/src/test/regress/expected/copy2.out +++ b/src/test/regress/expected/copy2.out @@ -905,3 +905,41 @@ truncate copy_default; -- DEFAULT cannot be used in COPY TO copy (select 1 as test) TO stdout with (default '\D'); ERROR: COPY DEFAULT only available using COPY FROM +-- Test handling of control characters +create temp table copy_ctl (a text, b text); +copy copy_ctl from stdin; +copy copy_ctl to stdout; +abc def +\n def +abc \n +\t def +abc \t +ab\b \bdef +a\vbc def\v +\f\f\f g\fg +\f def +abc  + def +abc  +\\ \n\t\\ +9 9999 +S4 j +copy copy_ctl to stdout with (format csv); +abc,def +" +",def +abc," +" + ,def +abc, +ab,def +a bc,def + ,g g + ,def +abc, +,def +abc, +\," + \" +9,9999 +S4,j diff --git a/src/test/regress/sql/copy2.sql b/src/test/regress/sql/copy2.sql index 8b14962194..e8d495e024 100644 --- a/src/test/regress/sql/copy2.sql +++ b/src/test/regress/sql/copy2.sql @@ -676,3 +676,28 @@ truncate copy_default; -- DEFAULT cannot be used in COPY TO copy (select 1 as test) TO stdout with (default '\D'); + +-- Test handling of control characters +create temp table copy_ctl (a text, b text); + +copy copy_ctl from stdin; +abc def +\n def +abc \n +\t def +abc \t +ab\b \bdef +a\vbc def\v +\f\f\f g\fg +\x0c def +abc \x6 +\6 def +abc \017 +\\ \ +\ \\ +\9 \9999 +\1234 \j +\. + +copy copy_ctl to stdout; +copy copy_ctl to stdout with (format csv); -- 2.39.3 (Apple Git-146)