--- trunk/pgswish.c 2005/02/19 15:09:05 12 +++ trunk/pgswish.c 2005/02/19 16:01:46 13 @@ -114,6 +114,8 @@ funcctx->attinmeta = attinmeta; MemoryContextSwitchTo(oldcontext); + + elog(INFO, "SRF_IS_FIRSTCALL done"); } /* stuff done on every call of the function */ @@ -130,7 +132,7 @@ Datum result; SW_RESULT *sw_res; /* one row from swish-e results */ - elog(INFO, "pgswish: in loop %d", call_cntr); + elog(INFO, "pgswish: loop count %d", call_cntr); if (! swish_results) { elog(ERROR, "pgswish: no swish-e results"); @@ -145,7 +147,6 @@ * This should be an array of C strings which will * be processed later by the type input functions. */ - values = (char **) palloc(4 * sizeof(char *)); sw_res = SwishNextResult( swish_results ); if (! sw_res) { @@ -164,11 +165,23 @@ SwishResultPropertyULong ( sw_res, "swishfilenum" ) ); - elog(INFO, "swishdocpath: %s", prop2text( sw_res, "swishdocpath" ) ); + values = (char **) palloc(4 * sizeof(char *)); + values[0] = prop2int( sw_res, "swishrank" ); values[1] = prop2text( sw_res, "swishdocpath" ); values[2] = prop2text( sw_res, "swishtitle" ); values[3] = prop2int( sw_res, "swishdocsize" ); + +/* + values[0] = (char *) palloc(16 * sizeof(char)); + snprintf(values[0], 16, "%d", 1); + values[1] = (char *) palloc(16 * sizeof(char)); + snprintf(values[1], 16, "%d", 2); + values[2] = (char *) palloc(16 * sizeof(char)); + snprintf(values[2], 16, "%d", 3); + values[3] = (char *) palloc(16 * sizeof(char)); + snprintf(values[3], 16, "%d", 4); +*/ /* build a tuple */ tuple = BuildTupleFromCStrings(attinmeta, values); @@ -177,11 +190,18 @@ result = TupleGetDatum(slot, tuple); /* clean up ? */ - + pfree(values[0]); + pfree(values[1]); + pfree(values[2]); + pfree(values[3]); + pfree(values); + elog(INFO, "row: %s|%s|%s|%s",values[0],values[1],values[2],values[3]); SRF_RETURN_NEXT(funcctx, result); } else { + elog(INFO, "loop over"); + /* free swish object and close */ Free_Search_Object( search ); SwishClose( swish_handle );