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

Commit9c48cae

Browse files
committed
Add pipe parameter to COPY function to allow proper line termination.
1 parent3df163a commit9c48cae

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

‎doc/src/sgml/ref/copy.sgml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v 1.42 2003/04/15 13:25:08 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v 1.43 2003/04/19 19:55:37 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -289,7 +289,7 @@ COPY <replaceable class="parameter">table</replaceable> [ ( <replaceable class="
289289
otherwise be taken as row or column delimiters. In particular, the
290290
following characters <emphasis>must</> be preceded by a backslash if
291291
they appear as part of a column value: backslash itself,
292-
newline, and the current delimiter character.
292+
newline,carriage return,and the current delimiter character.
293293
</para>
294294

295295
<para>
@@ -355,16 +355,16 @@ COPY <replaceable class="parameter">table</replaceable> [ ( <replaceable class="
355355
It is strongly recommended that applications generating COPY data convert
356356
data newlines and carriage returns to the <literal>\n</> and
357357
<literal>\r</> sequences respectively. At present it is
358-
possible to represent a data carriage returnwithout any special quoting,
359-
and to represent a data newline by a backslash and newline.However,
360-
these representationswill not be accepted by default in future releases.
358+
possible to represent a data carriage returnby a backslash and carriage
359+
return,and to represent a data newline by a backslash and newline.
360+
However,these representationsmight not be accepted in future releases.
361361
</para>
362362

363363
<para>
364-
Note that the end ofeach rowis marked bya Unix-stylenewline
365-
(<quote><literal>\n</></>). Presently, <command>COPY FROM</command> will not behave as
366-
desired if given a file containing DOS- or Mac-style newlines.
367-
This is expected to change in future releases.
364+
<command>COPY TO</command> will terminateeach rowwitha Unix-style
365+
newline(<quote><literal>\n</></>), or carriage return/newline
366+
("\r\n") on MS Windows. <command>COPY FROM</command> can handle lines
367+
ending with newlines, carriage returns, or carriage return/newlines.
368368
</para>
369369
</refsect2>
370370

@@ -393,7 +393,7 @@ COPY <replaceable class="parameter">table</replaceable> [ ( <replaceable class="
393393
12-byte sequence <literal>PGBCOPY\n\377\r\n\0</> --- note that the zero byte
394394
is a required part of the signature. (The signature is designed to allow
395395
easy identification of files that have been munged by a non-8-bit-clean
396-
transfer. This signature will be changed bynewline-translation
396+
transfer. This signature will be changed byend-of-line-translation
397397
filters, dropped zero bytes, dropped high bits, or parity changes.)
398398
</para>
399399
</listitem>

‎src/backend/commands/copy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.192 2003/04/1900:02:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.193 2003/04/1919:55:37 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -114,7 +114,7 @@ static intserver_encoding;
114114
*/
115115
staticvoidSendCopyBegin(boolbinary);
116116
staticvoidReceiveCopyBegin(boolbinary);
117-
staticvoidSendCopyEnd(boolbinary);
117+
staticvoidSendCopyEnd(boolbinary,boolpipe);
118118
staticvoidCopySendData(void*databuf,intdatasize);
119119
staticvoidCopySendString(constchar*str);
120120
staticvoidCopySendChar(charc);
@@ -178,7 +178,7 @@ ReceiveCopyBegin(bool binary)
178178
}
179179

180180
staticvoid
181-
SendCopyEnd(boolbinary)
181+
SendCopyEnd(boolbinary,boolpipe)
182182
{
183183
if (!binary)
184184
CopySendData("\\.\n",3);
@@ -680,7 +680,7 @@ DoCopy(const CopyStmt *stmt)
680680
if (!pipe)
681681
FreeFile(copy_file);
682682
elseif (IsUnderPostmaster&& !is_from)
683-
SendCopyEnd(binary);
683+
SendCopyEnd(binary,pipe);
684684
pfree(attribute_buf.data);
685685

686686
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp