@@ -532,13 +532,11 @@ typedef struct RestoreWordEntry
532532 * reconstruct partial tsvector from set of index entries
533533 */
534534static TSVector
535- rum_reconstruct_tsvector (bool * check ,TSQuery query ,int32 nkeys ,
536- int * map_item_operand ,
535+ rum_reconstruct_tsvector (bool * check ,TSQuery query ,int * map_item_operand ,
537536Datum * addInfo ,bool * addInfoIsNull )
538537{
539538TSVector tsv ;
540- int cntwords = 0 ,
541- totalwords = query -> size * 4 ;/* 4 positions per word, estimation */
539+ int cntwords = 0 ;
542540int i = 0 ;
543541QueryItem * item = GETQUERY (query );
544542char * operandData = GETOPERAND (query );
@@ -550,8 +548,8 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int32 nkeys,
550548int stroff ;
551549
552550
553- rwe = palloc (sizeof (* rwe )* totalwords );
554- visited = palloc0 (sizeof (* visited )* nkeys );
551+ rwe = palloc (sizeof (* rwe )* query -> size );
552+ visited = palloc0 (sizeof (* visited )* query -> size );
555553
556554/*
557555 * go through query to collect lexemes and add to them
@@ -562,7 +560,7 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int32 nkeys,
562560{
563561if (item -> type == QI_VAL )
564562{
565- int keyN = map_item_operand [i ];
563+ int keyN = map_item_operand [i ];
566564
567565if (check [keyN ]== true&& visited [keyN ]== false)
568566{
@@ -572,12 +570,6 @@ rum_reconstruct_tsvector(bool *check, TSQuery query, int32 nkeys,
572570 */
573571visited [keyN ]= true;
574572
575- while (cntwords + 1 >=totalwords )
576- {
577- totalwords *=2 ;
578- rwe = repalloc (rwe ,sizeof (* rwe )* totalwords );
579- }
580-
581573rwe [cntwords ].word = operandData + item -> qoperand .distance ;
582574rwe [cntwords ].wordlen = item -> qoperand .length ;
583575
@@ -662,15 +654,15 @@ rum_tsquery_distance(PG_FUNCTION_ARGS)
662654
663655/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
664656TSQuery query = PG_GETARG_TSQUERY (2 );
665- int32 nkeys = PG_GETARG_INT32 (3 );
657+ /* int32nkeys = PG_GETARG_INT32(3); */
666658Pointer * extra_data = (Pointer * )PG_GETARG_POINTER (4 );
667659Datum * addInfo = (Datum * )PG_GETARG_POINTER (8 );
668660bool * addInfoIsNull = (bool * )PG_GETARG_POINTER (9 );
669661float8 res ;
670662int * map_item_operand = (int * ) (extra_data [0 ]);
671663TSVector tsv ;
672664
673- tsv = rum_reconstruct_tsvector (check ,query ,nkeys , map_item_operand ,
665+ tsv = rum_reconstruct_tsvector (check ,query ,map_item_operand ,
674666addInfo ,addInfoIsNull );
675667
676668res = DatumGetFloat4 (DirectFunctionCall2Coll (ts_rank_tt ,