|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.234 2004/11/06 17:46:27 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.235 2004/12/03 17:13:28 momjian Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -98,6 +98,7 @@ static bool fe_eof; /* true if detected end of copy data */
|
98 | 98 | static EolType eol_type; /* EOL type of input */
|
99 | 99 | static int client_encoding; /* remote side's character encoding */
|
100 | 100 | static int server_encoding; /* local encoding */
|
| 101 | +static bool embedded_line_warning; |
101 | 102 |
|
102 | 103 | /* these are just for error messages, see copy_in_error_callback */
|
103 | 104 | static bool copy_binary; /* is it a binary copy? */
|
@@ -1190,6 +1191,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
|
1190 | 1191 | attr = tupDesc->attrs;
|
1191 | 1192 | num_phys_attrs = tupDesc->natts;
|
1192 | 1193 | attr_count = list_length(attnumlist);
|
| 1194 | + embedded_line_warning = false; |
1193 | 1195 |
|
1194 | 1196 | /*
|
1195 | 1197 | * Get info about the columns we need to process.
|
@@ -2627,6 +2629,25 @@ CopyAttributeOutCSV(char *server_string, char *delim, char *quote,
|
2627 | 2629 | !use_quote && (c = *test_string) != '\0';
|
2628 | 2630 | test_string += mblen)
|
2629 | 2631 | {
|
| 2632 | + /* |
| 2633 | + * We don't know here what the surrounding line end characters |
| 2634 | + * might be. It might not even be under postgres' control. So |
| 2635 | + * we simple warn on ANY embedded line ending character. |
| 2636 | + * |
| 2637 | + * This warning will disappear when we make line parsing field-aware, |
| 2638 | + * so that we can reliably read in embedded line ending characters |
| 2639 | + * regardless of the file's line-end context. |
| 2640 | + * |
| 2641 | + */ |
| 2642 | + |
| 2643 | + if (!embedded_line_warning && (c == '\n' || c == '\r') ) |
| 2644 | + { |
| 2645 | + embedded_line_warning = true; |
| 2646 | + elog(WARNING, |
| 2647 | + "CSV fields with embedded linefeed or carriage return " |
| 2648 | + "characters might not be able to be reimported"); |
| 2649 | + } |
| 2650 | + |
2630 | 2651 | if (c == delimc || c == quotec || c == '\n' || c == '\r')
|
2631 | 2652 | use_quote = true;
|
2632 | 2653 | if (!same_encoding)
|
|
0 commit comments