Re: [HACKERS] small bug in hlCover

2008-10-17 Thread Teodor Sigaev

Thank you, patch applied.

Sushant Sinha wrote:

Has any one noticed this?

-Sushant.

On Wed, 2008-07-16 at 23:01 -0400, Sushant Sinha wrote:

I think there is a slight bug in hlCover function in wparser_def.c

If there is only one query item and that is the first word in the text,
then hlCover does not returns any cover. This is evident in this example
when ts_headline only generates the min_words:

testdb=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery,
'MinWords=5');
   ts_headline
--

 1 2 3 4 5
(1 row)

The problem is that *q is initialized to 0 which is a legitimate value
for a cover. So I have attached a patch that fixes it and after applying
the patch here is the result.

testdb=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery,
'MinWords=5');
 ts_headline 
-

 1 2 3 4 5 6 7 8 9 10
(1 row)

-Sushant.





--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] small bug in hlCover

2008-08-03 Thread Sushant Sinha
On Mon, 2008-08-04 at 00:36 -0300, Euler Taveira de Oliveira wrote:
> Sushant Sinha escreveu:
> > I think there is a slight bug in hlCover function in wparser_def.c
> > 
> The bug is not in the hlCover. In prsd_headline, if we didn't find a 
> suitable bestlen (i.e. >= 0), than it includes up to document length or 
> *maxWords* (here is the bug). I'm attaching a small patch that fixes it 
> and some comment typos. Please apply it to 8_3_STABLE too.

Well hlCover purpose is to find a cover and for the document  '1 2 3 4 5
6 7 8 9 10' and the query '1'::tsquery, a cover exists. So it should
point it out.

On my source I see that prsd_headline marks only min_words which seems
like the right thing to do.

-Sushant.

> 
> euler=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery, 
> 'MinWords=5');
>   ts_headline
> -
>   1 2 3 4 5 6 7 8 9 10
> (1 registro)
> 
> euler=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery);
>   ts_headline
> -
>   1 2 3 4 5 6 7 8 9 10
> (1 registro)
> 
> 


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] small bug in hlCover

2008-08-03 Thread Sushant Sinha
Has any one noticed this?

-Sushant.

On Wed, 2008-07-16 at 23:01 -0400, Sushant Sinha wrote:
> I think there is a slight bug in hlCover function in wparser_def.c
> 
> If there is only one query item and that is the first word in the text,
> then hlCover does not returns any cover. This is evident in this example
> when ts_headline only generates the min_words:
> 
> testdb=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery,
> 'MinWords=5');
>ts_headline
> --
>  1 2 3 4 5
> (1 row)
> 
> The problem is that *q is initialized to 0 which is a legitimate value
> for a cover. So I have attached a patch that fixes it and after applying
> the patch here is the result.
> 
> testdb=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery,
> 'MinWords=5');
>  ts_headline 
> -
>  1 2 3 4 5 6 7 8 9 10
> (1 row)
> 
> -Sushant.


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] small bug in hlCover

2008-07-16 Thread Sushant Sinha
I think there is a slight bug in hlCover function in wparser_def.c

If there is only one query item and that is the first word in the text,
then hlCover does not returns any cover. This is evident in this example
when ts_headline only generates the min_words:

testdb=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery,
'MinWords=5');
   ts_headline
--
 1 2 3 4 5
(1 row)

The problem is that *q is initialized to 0 which is a legitimate value
for a cover. So I have attached a patch that fixes it and after applying
the patch here is the result.

testdb=# select ts_headline('1 2 3 4 5 6 7 8 9 10','1'::tsquery,
'MinWords=5');
 ts_headline 
-
 1 2 3 4 5 6 7 8 9 10
(1 row)

-Sushant.
Index: src/backend/tsearch/wparser_def.c
===
RCS file: /home/postgres/devel/pgsql-cvs/pgsql/src/backend/tsearch/wparser_def.c,v
retrieving revision 1.15
diff -c -r1.15 wparser_def.c
*** src/backend/tsearch/wparser_def.c	17 Jun 2008 16:09:06 -	1.15
--- src/backend/tsearch/wparser_def.c	17 Jul 2008 02:45:34 -
***
*** 1621,1627 
  	QueryItem  *item = GETQUERY(query);
  	int			pos = *p;
  
! 	*q = 0;
  	*p = 0x7fff;
  
  	for (j = 0; j < query->size; j++)
--- 1621,1627 
  	QueryItem  *item = GETQUERY(query);
  	int			pos = *p;
  
! 	*q = -1;
  	*p = 0x7fff;
  
  	for (j = 0; j < query->size; j++)
***
*** 1643,1649 
  		item++;
  	}
  
! 	if (*q == 0)
  		return false;
  
  	item = GETQUERY(query);
--- 1643,1649 
  		item++;
  	}
  
! 	if (*q < 0)
  		return false;
  
  	item = GETQUERY(query);

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers