There was a small bug in the new compute_tsvector_stats function in CVS
HEAD, causing a crash with this surprisingly simple test case:
postgres=# CREATE TABLE tstest (ts tsvector);
CREATE TABLE
postgres=# INSERT INTO tstest values ('foobar');
INSERT 0 1
postgres=# ANALYZE tstest;
server closed the connection unexpectedlyThis probably means the server terminated abnormallybefore or while processing
therequest.
The crash happens here:
/* Grab the minimal and maximal frequencies that will get stored */ minfreq = sort_table[num_mcelem -
1]->frequency; maxfreq = sort_table[0]->frequency;
Because the loop above this point suppresses items that occur only once,
num_mcelem is 0.
The fix is trivial, but I thought I'd post this test case anyway to get
it archived. The patch I committed moves the code above within the
"if(num_mcelem > 0)" block below that. The possibility that num_mcelem
can be zero was clearly thought of, but the check was too late.
-- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com