Re: COPY FROM WITH HEADER skips a tuple every 4 billion tuples

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: COPY FROM WITH HEADER skips a tuple every 4 billion tuples
Date: 2018-05-22 21:39:14
Message-ID: CAKJS1f-4nND6JqmqxrW_NoVtLEGs7pwv381=hK+5knic4ER+CA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23 May 2018 at 09:31, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> On 23 May 2018 at 03:55, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> > Hm, so why is the correct rowcount returned --- are we running
>> > a separate counter for that purpose, and if so why?
>>
>> I thought the output I pasted was clearly showing it not to be the
>> same. 4299999999 vs 4300000000.
>>
>> Did I misunderstand you?
>
> Well, the row-returned counter is obviously wide enough, otherwise
> 4299999999 couldn't be returned. Tom's point, as I understood it, is
> that we obviously have one wide enough counter - why can't we reuse that
> for the one you made wider. And it doesn't seem entirely trivial to do
> so, so your patch is easier.

*moment of realisation*

Oh, this makes sense now.

They can't be the same. One tracks the line number in the COPY FROM
input, the other tracks the number of rows inserted. You'd only have
to add a BEFORE INSERT ROW trigger which blocks some rows to
understand why they need to be separate.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-05-22 22:02:27 Re: plperl fails with perl 5.28
Previous Message Andres Freund 2018-05-22 21:31:11 Re: COPY FROM WITH HEADER skips a tuple every 4 billion tuples