1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-18 12:22:09 +03:00

Fix bug in COPY CSV mode: handle consecutive embedded newlines in COPY

input. Also add a regression test for this bug. From Andrew Dunstan.
This commit is contained in:
Neil Conway
2005-05-13 06:35:25 +00:00
parent 928d269abf
commit 9ac4af6847
3 changed files with 16 additions and 1 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -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();