============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================
Your name : Misha Routchiev
Your email address : routchiev.mikhail@csfb.com
Category : runtime: back-end
Severity : critical
Summary: fatal error occurs while building index
System Configuration
--------------------
Operating System : SunOS 5.5.1 (Solaris)
PostgreSQL version : 6.4.2
Compiler used : gcc 2.7.2.2
Hardware:
---------
SUN
Versions of other tools:
------------------------
gmake, probably flex
--------------------------------------------------------------------------
Problem Description:
--------------------
Problem happens while building index on relatively
large database (1M+ records)
indexed field is declared as varchar(16)). In the btree
index there are a lot of duplicate values (100s and more).
Somewhere in the middle of building,
following fatal error occurs:
btree: failed to add item to the page in _bt_sort (2)
(from nbtsort.c)
and frontend/backend pair exits leaving behind a lot
of temporary files
--------------------------------------------------------------------------
Test Case:
----------
This problem happens both in 6.3.2 and 6.4.2.
I when I extracted offending column trying to reproduce it,
and populated it into separate table, it created same index
on this column just fine, so it must somehow be related to
the size of the tuple as well.
Problem reproduces itself on the whole dump (too big to be
attached), though.
--------------------------------------------------------------------------
Solution:
---------
I tried to look into it, but I could only guess that
somehow lower exceeds upper in PageAddItem
because the size of the remaining space in Page
page is wrongly calculated (there is some strange
warning in PageGetFreeSpace() saying:
/* XXX not always true */
or spoiled by previous additions
I remember previous versions had the same problem with
integers, but is was fixed for release 6.3.
For anything beyond that I have too little knowledge of the
design.
--------------------------------------------------------------------------