Re: COPY with hints, rebirth

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY with hints, rebirth
Date: 2012-03-01 20:49:23
Message-ID: 4F4FE0D3.1070509@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01.03.2012 18:40, Simon Riggs wrote:
> On Sun, Feb 26, 2012 at 7:16 PM, Heikki Linnakangas
> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>> On 24.02.2012 22:55, Simon Riggs wrote:
>>>
>>> What exactly does it do? Previously, we optimised COPY when it was
>>> loading data into a newly created table or a freshly truncated table.
>>> This patch extends that and actually sets the tuple header flag as
>>> HEAP_XMIN_COMMITTED during the load. Doing so is simple 2 lines of
>>> code. The patch also adds some tests for corner cases that would make
>>> that action break MVCC - though those cases are minor and typical data
>>> loads will benefit fully from this.
>>
>> This doesn't work with subtransactions:
> ...
>> The query should return the row copied in the same subtransaction.
>
> Thanks for pointing that out.
>
> New patch with corrected logic and test case attached.

It's still broken:

-- create test table and file
create table a as select 1 as id;
copy a to '/tmp/a';

-- start test
postgres=# begin;
BEGIN
postgres=# truncate a;
TRUNCATE TABLE
postgres=# savepoint sp1;
SAVEPOINT
postgres=# copy a from '/tmp/a';
COPY 1
postgres=# select * from a;
id
----
1
(1 row)

postgres=# rollback to savepoint sp1;
ROLLBACK
postgres=# select * from a;
id
----
1
(1 row)

That last select should not have seen the tuple.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-03-01 21:08:26 Re: 16-bit page checksums for 9.2
Previous Message Peter Eisentraut 2012-03-01 20:17:04 Re: pg_upgrade --logfile option documentation