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:[EMAIL PROTECTED]] > Sent: Friday, 30 August 2002 2:53 PM > To: Christopher Kings-Lynne > Cc: Hackers > Subject: Re: Fulltextindex > > > "Christopher Kings-Lynne" <[EMAIL PROTECTED]> 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 > ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster