COPY's test for read-only transaction was backward; it prohibited COPY TO
authorTom Lane <[email protected]>
Mon, 3 Oct 2005 23:43:29 +0000 (23:43 +0000)
committerTom Lane <[email protected]>
Mon, 3 Oct 2005 23:43:29 +0000 (23:43 +0000)
where it should prohibit COPY FROM.  Found by Alon Goldshuv.

doc/src/sgml/release.sgml
src/backend/commands/copy.c

index d1576a78a3a0762075de16f6f6a33927e091ed1e..da2e1fba0f28b1658de9c47656ce480c47d122a0 100644 (file)
@@ -46,6 +46,11 @@ DATABASE</></para>
 <para>This should fix recent reports of <quote>index is not a btree</>
 failures when a crash occurs shortly after <command>CREATE
 DATABASE</>.</para></listitem>
+<listitem><para>Fix the sense of the test for read-only transaction
+in <command>COPY</></para>
+<para>The code formerly prohibited <command>COPY TO</>, where it should
+prohibit <command>COPY FROM</>.
+</para></listitem>
 <listitem><para>Handle consecutive embedded newlines in <command>COPY</>
 CSV-mode input</para></listitem>
 <listitem><para>Fix <function>date_trunc(week)</> for dates near year
@@ -2817,6 +2822,11 @@ length when using a multiple-byte character set (Yoshiyuki Asaba)</para>
 <para>In prior releases, the padding of <type>CHAR()</> was incorrect
 because it only padded to the specified number of bytes without
 considering how many characters were stored.</para></listitem>
+<listitem><para>Fix the sense of the test for read-only transaction
+in <command>COPY</></para>
+<para>The code formerly prohibited <command>COPY TO</>, where it should
+prohibit <command>COPY FROM</>.
+</para></listitem>
 <listitem><para>Fix planning problem with outer-join ON clauses that reference
 only the inner-side relation</para></listitem>
 <listitem><para>Further fixes for <literal>x FULL JOIN y ON true</> corner
index 4dc2654fc2337e05afe270280c4493992615085b..90ef3d41dd75f59a2844b2c6c679df5db6457cbc 100644 (file)
@@ -900,7 +900,8 @@ DoCopy(const CopyStmt *stmt)
        rel = heap_openrv(relation, (is_from ? RowExclusiveLock : AccessShareLock));
 
        /* check read-only transaction */
-       if (XactReadOnly && !is_from && !isTempNamespace(RelationGetNamespace(rel)))
+       if (XactReadOnly && is_from &&
+               !isTempNamespace(RelationGetNamespace(rel)))
                ereport(ERROR,
                                (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
                                 errmsg("transaction is read-only")));
@@ -2395,6 +2396,7 @@ CopyReadAttributeCSV(const char *delim, const char *null_print, char *quote,
                        if (done && line_buf.len == 0)
                                break;
                        start_cursor = line_buf.cursor;
+                       continue;
                }
 
                end_cursor = line_buf.cursor;