diff options
author | Neil Conway <neilc@samurai.com> | 2005-05-13 06:35:25 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2005-05-13 06:35:25 +0000 |
commit | 9ac4af684737f9c20ba60eda67ac41c41d41ea3e (patch) | |
tree | d0e7971b3b08a67be9f38d30d0d292c494d8b4ea | |
parent | 928d269abf2dd3e6f7832f6592ebfdd4f1fe70a4 (diff) | |
download | postgresql-9ac4af684737f9c20ba60eda67ac41c41d41ea3e.tar.gz postgresql-9ac4af684737f9c20ba60eda67ac41c41d41ea3e.zip |
Fix bug in COPY CSV mode: handle consecutive embedded newlines in COPY
input. Also add a regression test for this bug. From Andrew Dunstan.
-rw-r--r-- | src/backend/commands/copy.c | 3 | ||||
-rw-r--r-- | src/test/regress/expected/copy2.out | 3 | ||||
-rw-r--r-- | src/test/regress/sql/copy2.sql | 11 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 9f99bdd9e48..79ffac04df0 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.236 2004/12/31 21:59:41 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.236.4.1 2005/05/13 06:35:25 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -2395,6 +2395,7 @@ CopyReadAttributeCSV(const char *delim, const char *null_print, char *quote, if (done && line_buf.len == 0) break; start_cursor = line_buf.cursor; + continue; } end_cursor = line_buf.cursor; diff --git a/src/test/regress/expected/copy2.out b/src/test/regress/expected/copy2.out index 6a4769adac1..40dd7f24af2 100644 --- a/src/test/regress/expected/copy2.out +++ b/src/test/regress/expected/copy2.out @@ -191,6 +191,9 @@ COPY y TO stdout WITH CSV FORCE QUOTE col2 ESCAPE '\\'; "Jackson, Sam","\\h" "It is \"perfect\"."," " "", +--test that we read consecutive LFs properly +CREATE TEMP TABLE testnl (a int, b text, c int); +COPY testnl FROM stdin CSV; DROP TABLE x, y; DROP FUNCTION fn_x_before(); DROP FUNCTION fn_x_after(); diff --git a/src/test/regress/sql/copy2.sql b/src/test/regress/sql/copy2.sql index 78bbf4182e5..eb1a69c0955 100644 --- a/src/test/regress/sql/copy2.sql +++ b/src/test/regress/sql/copy2.sql @@ -129,6 +129,17 @@ COPY y TO stdout WITH CSV; COPY y TO stdout WITH CSV QUOTE '''' DELIMITER '|'; COPY y TO stdout WITH CSV FORCE QUOTE col2 ESCAPE '\\'; +--test that we read consecutive LFs properly + +CREATE TEMP TABLE testnl (a int, b text, c int); + +COPY testnl FROM stdin CSV; +1,"a field with two LFs + +inside",2 +\. + + DROP TABLE x, y; DROP FUNCTION fn_x_before(); DROP FUNCTION fn_x_after(); |