Skip to content

Commit 9c48cae

Browse files
committed
Add pipe parameter to COPY function to allow proper line termination.
1 parent 3df163a commit 9c48cae

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 return without any special quoting,
359-
and to represent a data newline by a backslash and newline. However,
360-
these representations will not be accepted by default in future releases.
358+
possible to represent a data carriage return by a backslash and carriage
359+
return, and to represent a data newline by a backslash and newline.
360+
However, these representations might not be accepted in future releases.
361361
</para>
362362

363363
<para>
364-
Note that the end of each row is marked by a Unix-style newline
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 terminate each row with a 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 by newline-translation
396+
transfer. This signature will be changed by end-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/19 00:02:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.193 2003/04/19 19:55:37 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -114,7 +114,7 @@ static int server_encoding;
114114
*/
115115
static void SendCopyBegin(bool binary);
116116
static void ReceiveCopyBegin(bool binary);
117-
static void SendCopyEnd(bool binary);
117+
static void SendCopyEnd(bool binary, bool pipe);
118118
static void CopySendData(void *databuf, int datasize);
119119
static void CopySendString(const char *str);
120120
static void CopySendChar(char c);
@@ -178,7 +178,7 @@ ReceiveCopyBegin(bool binary)
178178
}
179179

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

686686
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy