pgsql: Make COPY TO keep locks until the transaction end.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make COPY TO keep locks until the transaction end.
Date: 2020-05-15 02:48:11
Message-ID: E1jZQOR-0001TR-B2@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Make COPY TO keep locks until the transaction end.

COPY TO released the ACCESS SHARE lock immediately when it was done rather
than holding on to it until the end of the transaction.

This breaks the case where a REPEATABLE READ transaction could see an
empty table if it repeats a COPY statement and somebody truncated the
table in the meantime.

Before 4dded12faad the lock was also released after COPY FROM, but the
commit failed to notice the irregularity in COPY TO.

This is old behavior but doesn't seem important enough to backpatch.

Author: Laurenz Albe, based on suggestion by Robert Haas and Tom Lane
Reviewed-by: Amit Kapila
Discussion: https://postgr.es/m/7bcfc39d4176faf85ab317d0c26786953646a411.camel@cybertec.at

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a9cf48a4cf0c878684a2f52a3a88e29399b2065e

Modified Files
--------------
src/backend/commands/copy.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2020-05-15 12:30:07 pgsql: doc: PG 13 relnotes: fix xref link and remove extra word
Previous Message Bruce Momjian 2020-05-15 02:36:31 pgsql: docs: PG 13 relnotes: add links and SGML formatting