Bug in tsvector stats collection, fixed.

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Bug in tsvector stats collection, fixed.
Дата
Msg-id 492F0EAF.7000307@enterprisedb.com
обсуждение исходный текст
Список pgsql-hackers
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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Zdenek Kotala
Дата:
Сообщение: Re: Thread safety
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: [PATCHES] GIN improvements