aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-03-13 14:19:21 +0900
committerMichael Paquier <michael@paquier.xyz>2024-03-13 14:19:21 +0900
commita189ed49d6292979be1478292246be61c4563043 (patch)
tree82fcdfe4441a571f6ebe0329b01e2f6989b49b26
parent0b84f5c419a300dc1b1a70cf63b9907208e52643 (diff)
downloadpostgresql-a189ed49d6292979be1478292246be61c4563043.tar.gz
postgresql-a189ed49d6292979be1478292246be61c4563043.zip
Add tests for more row patterns with COPY FROM .. (ON_ERROR ignore)
While digging into the code of this feature, I got confused by the fact that a line is skipped when a value cannot be converted to its expected attribute even if the line has fewer attributes than the target relation. The tests had a check for the case of an empty line, this commit a couple more patterns where a line is incomplete, but skipped because of a conversion error. Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/Ze_7kZqexdt0BiyC@paquier.xyz
-rw-r--r--src/test/regress/expected/copy2.out5
-rw-r--r--src/test/regress/sql/copy2.sql3
2 files changed, 6 insertions, 2 deletions
diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out
index 25c401ce344..f98c2d1c4eb 100644
--- a/src/test/regress/expected/copy2.out
+++ b/src/test/regress/expected/copy2.out
@@ -730,13 +730,14 @@ COPY check_ign_err FROM STDIN WITH (on_error stop);
ERROR: invalid input syntax for type integer: "a"
CONTEXT: COPY check_ign_err, line 2, column n: "a"
COPY check_ign_err FROM STDIN WITH (on_error ignore);
-NOTICE: 4 rows were skipped due to data type incompatibility
+NOTICE: 6 rows were skipped due to data type incompatibility
SELECT * FROM check_ign_err;
n | m | k
---+-----+---
1 | {1} | 1
5 | {5} | 5
-(2 rows)
+ 8 | {8} | 8
+(3 rows)
-- test datatype error that can't be handled as soft: should fail
CREATE TABLE hard_err(foo widget);
diff --git a/src/test/regress/sql/copy2.sql b/src/test/regress/sql/copy2.sql
index b5e549e8563..afaaa37e52e 100644
--- a/src/test/regress/sql/copy2.sql
+++ b/src/test/regress/sql/copy2.sql
@@ -515,6 +515,9 @@ a {2} 2
4 {a, 4} 4
5 {5} 5
+6 a
+7 {7} a
+8 {8} 8
\.
SELECT * FROM check_ign_err;