Re: Fulltextindex - Mailing list pgsql-hackers

From Nigel J. Andrews
Subject Re: Fulltextindex
Date
Msg-id Pine.LNX.4.21.0208301209370.667-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Re: Fulltextindex  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
On Fri, 30 Aug 2002, Christopher Kings-Lynne wrote:
> 
> --------------------------------
> 
> struct varlena *data;
> char    *word           = "john";
> char    *cur_pos        = NULL;
> int     cur_pos_length  = 0;
> 
> data = (struct varlena *) palloc(VARHDRSZ + column_length + 1);
> word_length = strlen(word);
> cur_pos = &word[word_length - 2];
> 
> while(cur_pos > word)
> {
>     cur_pos_length = strlen(cur_pos);
>     /* Line below causes seg fault on SECOND iteration */
>     data->vl_len = cur_pos_length + sizeof(int32);
>     memcpy(VARDATA(data), cur_pos, cur_pos_length);
>     values[0] = PointerGetDatum(data);
>     values[1] = 0;
>     values[2] = oid;
> 
>     ret = SPI_execp(*(plan->splan), values, NULL, 0);
>     if(ret != SPI_OK_INSERT)
>         elog(ERROR, "Full Text Indexing: error executing plan in insert\n");
> 
>     cur_pos--;
> }
> 

That would imply the SPI_execp call is trashing the value of data. Have you
confirmed that? (Sometimes it helps to confirm exactly where a pointer is
getting hammered.)

column_length is something sensible like word_length I presume.

That sizeof(int32) should really be VARHDRSZ imo, but I can't see how that's
breaking it.

Disclaimer: I have no idea what I'm doing here.


-- 
Nigel J. Andrews



pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: DROP COLUMN & TOASTED DATA
Next
From: John Gray
Date:
Subject: Accessing original TupleDesc from SRF