Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To quote from the <a href="http://www.postgresql.org/docs/8.3/interactive/sql-copy.html" rel="nofollow">documentation</a>:</p> <blockquote> <p>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 by a backslash and carriage return, and to represent a data newline by a backslash and newline.</p> </blockquote> <p>So I would say the following will work:</p> <pre><code>npgsqlCopySerializer.AddString("another\\\r\\\naddress"); </code></pre> <p><strong>EDIT</strong>: I tried it for myself and there seems to be a bug in <code>NpgsqlCopySerializer.AddString()</code>:</p> <pre><code>if (escapeAt &gt; bufferedUpto) { int encodedLength = ENCODING_UTF8.GetByteCount(fieldValue.ToCharArray(bufferedUpto, escapeAt)); MakeRoomForBytes(encodedLength); _sendBufferAt += ENCODING_UTF8.GetBytes(fieldValue, bufferedUpto, escapeAt, _sendBuffer, _sendBufferAt); bufferedUpto = escapeAt; } </code></pre> <p>The second line throws the <code>ArgumentOutOfRangeException</code> after the two escape sequences (<code>\r</code> and <code>\n</code>) are processed and added to the output buffer, since at that moment <code>bufferedUpto == 9</code> and <code>escapeAt == "another\r\naddress".Length == 16</code></p> <p>Now I even found <a href="http://pgfoundry.org/tracker/index.php?func=detail&amp;aid=1011215&amp;group_id=1000140&amp;atid=590" rel="nofollow">this bug</a> reported at the Npgsql tracker.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload