Re: Fulltextindex - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: Fulltextindex
Date
Msg-id GNELIHDDFBOCMGBFGEFOMEPJCDAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: Fulltextindex  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Fulltextindex  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Re: Fulltextindex  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
OK, I was probably a little aggressive in my pruning...BTW, this code was
not written by me...

--------------------------------

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
executingplan in insert\n");
 
cur_pos--;
}

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Friday, 30 August 2002 2:53 PM
> To: Christopher Kings-Lynne
> Cc: Hackers
> Subject: Re: Fulltextindex
>
>
> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > struct varlena *data;
> > char    *word           = NULL;
> > char    *cur_pos        = NULL;
> > int     cur_pos_length  = 0;
>
> > data = (struct varlena *) palloc(column_length);
>
> > while(cur_pos > word)
> > {
> >     cur_pos_length = strlen(cur_pos);
> >     /* Line below causes seg fault on SECOND iteration */
>
> You are not telling the whole truth here, as the above code excerpt
> will obviously never iterate the WHILE even once.  "NULL > NULL" is
> false in every C I ever heard of.
>
> Also, how much is column_length and how does it relate to the amount
> of data being copied into *data ?
>
>             regards, tom lane
>



pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: RULE regression test failure
Next
From: "Christopher Kings-Lynne"
Date:
Subject: DROP COLUMN & TOASTED DATA