From: | "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fulltextindex |
Date: | 2002-08-30 07:08:54 |
Message-ID: | GNELIHDDFBOCMGBFGEFOMEPJCDAA.chriskl@familyhealth.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 executing plan in insert\n");
cur_pos--;
}
> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Friday, 30 August 2002 2:53 PM
> To: Christopher Kings-Lynne
> Cc: Hackers
> Subject: Re: Fulltextindex
>
>
> "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Kings-Lynne | 2002-08-30 07:52:15 | DROP COLUMN & TOASTED DATA |
Previous Message | Christopher Kings-Lynne | 2002-08-30 07:02:59 | Re: RULE regression test failure |