From: | "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk> |
---|---|
To: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fulltextindex |
Date: | 2002-08-30 11:22:01 |
Message-ID: | Pine.LNX.4.21.0208301209370.667-100000@ponder.fairway2k.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | John Gray | 2002-08-30 11:45:54 | Accessing original TupleDesc from SRF |
Previous Message | Christopher Kings-Lynne | 2002-08-30 07:52:15 | DROP COLUMN & TOASTED DATA |