Add pipe parameter to COPY function to allow proper line termination.
authorBruce Momjian
Sat, 19 Apr 2003 19:55:37 +0000 (19:55 +0000)
committerBruce Momjian
Sat, 19 Apr 2003 19:55:37 +0000 (19:55 +0000)
doc/src/sgml/ref/copy.sgml
src/backend/commands/copy.c

index 56e7223bd9f6f19bbfeb46372ea99f82dac6cc16..209ae01bd7a8f700aa88a9fa18fc272b16d88670 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -289,7 +289,7 @@ COPY table [ ( 
     otherwise be taken as row or column delimiters. In particular, the
     following characters must be preceded by a backslash if
     they appear as part of a column value: backslash itself,
-    newline, and the current delimiter character.
+    newline, carriage return, and the current delimiter character.
    
 
    
@@ -355,16 +355,16 @@ COPY table [ ( 
     It is strongly recommended that applications generating COPY data convert
     data newlines and carriage returns to the \n and
     \r sequences respectively.  At present it is
-    possible to represent a data carriage return without any special quoting,
-    and to represent a data newline by a backslash and newline.  However,
-    these representations will not be accepted by default in future releases.
+    possible to represent a data carriage return by a backslash and carriage
+    return, and to represent a data newline by a backslash and newline.  
+    However, these representations might not be accepted in future releases.
    
 
    
-    Note that the end of each row is marked by a Unix-style newline
-    (\n).  Presently, COPY FROM will not behave as
-    desired if given a file containing DOS- or Mac-style newlines.
-    This is expected to change in future releases.
+    COPY TO will terminate each row with a Unix-style 
+    newline (\n),  or carriage return/newline 
+    ("\r\n") on  MS Windows.  COPY FROM can handle lines 
+    ending with newlines, carriage returns, or carriage return/newlines.
    
   
 
@@ -393,7 +393,7 @@ COPY table [ ( 
 12-byte sequence PGBCOPY\n\377\r\n\0 --- note that the zero byte
 is a required part of the signature.  (The signature is designed to allow
 easy identification of files that have been munged by a non-8-bit-clean
-transfer.  This signature will be changed by newline-translation
+transfer.  This signature will be changed by end-of-line-translation
 filters, dropped zero bytes, dropped high bits, or parity changes.)
        
       
index fd85f48b592877ce2318e50e02c9b9c32a478adf..64e3c09e29fcebb1536e67548816e0484aa386b3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.192 2003/04/19 00:02:29 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.193 2003/04/19 19:55:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -114,7 +114,7 @@ static int  server_encoding;
  */
 static void SendCopyBegin(bool binary);
 static void ReceiveCopyBegin(bool binary);
-static void SendCopyEnd(bool binary);
+static void SendCopyEnd(bool binary, bool pipe);
 static void CopySendData(void *databuf, int datasize);
 static void CopySendString(const char *str);
 static void CopySendChar(char c);
@@ -178,7 +178,7 @@ ReceiveCopyBegin(bool binary)
 }
 
 static void
-SendCopyEnd(bool binary)
+SendCopyEnd(bool binary, bool pipe)
 {
    if (!binary)
        CopySendData("\\.\n", 3);
@@ -680,7 +680,7 @@ DoCopy(const CopyStmt *stmt)
    if (!pipe)
        FreeFile(copy_file);
    else if (IsUnderPostmaster && !is_from)
-       SendCopyEnd(binary);
+       SendCopyEnd(binary, pipe);
    pfree(attribute_buf.data);
 
    /*