Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb99679

Browse files
committed
> If it bothers you that much. I'd make a flag, cleared at the start of
> each COPY, and then where we test for CR or LF in CopyAttributeOutCSV,> if the flag is not set then set it and issue the warning.Andrew Dunstan
1 parentc1233c8 commitcb99679

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

‎src/backend/commands/copy.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -98,6 +98,7 @@ static bool fe_eof;/* true if detected end of copy data */
9898
staticEolTypeeol_type;/* EOL type of input */
9999
staticintclient_encoding;/* remote side's character encoding */
100100
staticintserver_encoding;/* local encoding */
101+
staticboolembedded_line_warning;
101102

102103
/* these are just for error messages, see copy_in_error_callback */
103104
staticboolcopy_binary;/* is it a binary copy? */
@@ -1190,6 +1191,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
11901191
attr=tupDesc->attrs;
11911192
num_phys_attrs=tupDesc->natts;
11921193
attr_count=list_length(attnumlist);
1194+
embedded_line_warning= false;
11931195

11941196
/*
11951197
* Get info about the columns we need to process.
@@ -2627,6 +2629,25 @@ CopyAttributeOutCSV(char *server_string, char *delim, char *quote,
26272629
!use_quote&& (c=*test_string)!='\0';
26282630
test_string+=mblen)
26292631
{
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+
26302651
if (c==delimc||c==quotec||c=='\n'||c=='\r')
26312652
use_quote= true;
26322653
if (!same_encoding)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp