Skip to content

Commit 060d13f

Browse files
committed
COPY's test for read-only transaction was backward; it prohibited COPY TO
where it should prohibit COPY FROM. Found by Alon Goldshuv.
1 parent 53e47cd commit 060d13f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

doc/src/sgml/release.sgml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.387 2005/10/03 16:04:13 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.388 2005/10/03 23:43:06 tgl Exp $
33

44
Typical markup:
55

@@ -2097,6 +2097,11 @@ DATABASE</></para>
20972097
<para>This should fix recent reports of <quote>index is not a btree</>
20982098
failures when a crash occurs shortly after <command>CREATE
20992099
DATABASE</>.</para></listitem>
2100+
<listitem><para>Fix the sense of the test for read-only transaction
2101+
in <command>COPY</></para>
2102+
<para>The code formerly prohibited <command>COPY TO</>, where it should
2103+
prohibit <command>COPY FROM</>.
2104+
</para></listitem>
21002105
<listitem><para>Handle consecutive embedded newlines in <command>COPY</>
21012106
CSV-mode input</para></listitem>
21022107
<listitem><para>Fix <function>date_trunc(week)</> for dates near year
@@ -4868,6 +4873,11 @@ length when using a multiple-byte character set (Yoshiyuki Asaba)</para>
48684873
<para>In prior releases, the padding of <type>CHAR()</> was incorrect
48694874
because it only padded to the specified number of bytes without
48704875
considering how many characters were stored.</para></listitem>
4876+
<listitem><para>Fix the sense of the test for read-only transaction
4877+
in <command>COPY</></para>
4878+
<para>The code formerly prohibited <command>COPY TO</>, where it should
4879+
prohibit <command>COPY FROM</>.
4880+
</para></listitem>
48714881
<listitem><para>Fix planning problem with outer-join ON clauses that reference
48724882
only the inner-side relation</para></listitem>
48734883
<listitem><para>Further fixes for <literal>x FULL JOIN y ON true</> corner

src/backend/commands/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.251 2005/09/24 22:54:36 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.252 2005/10/03 23:43:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -857,7 +857,7 @@ DoCopy(const CopyStmt *stmt)
857857
(is_from ? RowExclusiveLock : AccessShareLock));
858858

859859
/* check read-only transaction */
860-
if (XactReadOnly && !is_from &&
860+
if (XactReadOnly && is_from &&
861861
!isTempNamespace(RelationGetNamespace(cstate->rel)))
862862
ereport(ERROR,
863863
(errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),

0 commit comments

Comments
 (0)