Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC. - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC.
Date
Msg-id 4FB38C29.8070009@enterprisedb.com
Whole thread Raw
In response to Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC.  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC.  (Tomonari Katsumata <katsumata.tomonari@po.ntts.co.jp>)
List pgsql-bugs
On 16.05.2012 13:47, Heikki Linnakangas wrote:
> This sounds like a bug in the new page-at-a-time behavior in COPY. Can
> you send me a self-contained test, including the test data?

Never mind. After staring at the code for a while, I spotted the bug,
and was able to reproduce with a simpler case. It's quite easy to
reproduce when you set fillfactor even lower, like 10.

The problem is with this line in heap_multi_insert function:

    if (PageGetHeapFreeSpace(page) - saveFreeSpace < MAXALIGN(heaptup->t_len))

That doesn't work as intended, because the return value of
PageGetHeapFreeSpace and saveFreeSpace are unsigned. When saveFreeSpace
is larger than the amount of free space on the page, the left hand side
of that comparison is supposed to go negative, but it wraps around to a
highly positive number because it's unsigned.

Fixed, thanks for the report!

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

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC.
Next
From: Tomonari Katsumata
Date:
Subject: Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC.