114 |
funcctx->attinmeta = attinmeta; |
funcctx->attinmeta = attinmeta; |
115 |
|
|
116 |
MemoryContextSwitchTo(oldcontext); |
MemoryContextSwitchTo(oldcontext); |
117 |
|
|
118 |
|
elog(INFO, "SRF_IS_FIRSTCALL done"); |
119 |
} |
} |
120 |
|
|
121 |
/* stuff done on every call of the function */ |
/* stuff done on every call of the function */ |
132 |
Datum result; |
Datum result; |
133 |
SW_RESULT *sw_res; /* one row from swish-e results */ |
SW_RESULT *sw_res; /* one row from swish-e results */ |
134 |
|
|
135 |
elog(INFO, "pgswish: in loop %d", call_cntr); |
elog(INFO, "pgswish: loop count %d", call_cntr); |
136 |
|
|
137 |
if (! swish_results) { |
if (! swish_results) { |
138 |
elog(ERROR, "pgswish: no swish-e results"); |
elog(ERROR, "pgswish: no swish-e results"); |
147 |
* This should be an array of C strings which will |
* This should be an array of C strings which will |
148 |
* be processed later by the type input functions. |
* be processed later by the type input functions. |
149 |
*/ |
*/ |
|
values = (char **) palloc(4 * sizeof(char *)); |
|
150 |
|
|
151 |
sw_res = SwishNextResult( swish_results ); |
sw_res = SwishNextResult( swish_results ); |
152 |
if (! sw_res) { |
if (! sw_res) { |
165 |
SwishResultPropertyULong ( sw_res, "swishfilenum" ) |
SwishResultPropertyULong ( sw_res, "swishfilenum" ) |
166 |
); |
); |
167 |
|
|
168 |
elog(INFO, "swishdocpath: %s", prop2text( sw_res, "swishdocpath" ) ); |
values = (char **) palloc(4 * sizeof(char *)); |
169 |
|
|
170 |
values[0] = prop2int( sw_res, "swishrank" ); |
values[0] = prop2int( sw_res, "swishrank" ); |
171 |
values[1] = prop2text( sw_res, "swishdocpath" ); |
values[1] = prop2text( sw_res, "swishdocpath" ); |
172 |
values[2] = prop2text( sw_res, "swishtitle" ); |
values[2] = prop2text( sw_res, "swishtitle" ); |
173 |
values[3] = prop2int( sw_res, "swishdocsize" ); |
values[3] = prop2int( sw_res, "swishdocsize" ); |
174 |
|
|
175 |
|
/* |
176 |
|
values[0] = (char *) palloc(16 * sizeof(char)); |
177 |
|
snprintf(values[0], 16, "%d", 1); |
178 |
|
values[1] = (char *) palloc(16 * sizeof(char)); |
179 |
|
snprintf(values[1], 16, "%d", 2); |
180 |
|
values[2] = (char *) palloc(16 * sizeof(char)); |
181 |
|
snprintf(values[2], 16, "%d", 3); |
182 |
|
values[3] = (char *) palloc(16 * sizeof(char)); |
183 |
|
snprintf(values[3], 16, "%d", 4); |
184 |
|
*/ |
185 |
|
|
186 |
/* build a tuple */ |
/* build a tuple */ |
187 |
tuple = BuildTupleFromCStrings(attinmeta, values); |
tuple = BuildTupleFromCStrings(attinmeta, values); |
190 |
result = TupleGetDatum(slot, tuple); |
result = TupleGetDatum(slot, tuple); |
191 |
|
|
192 |
/* clean up ? */ |
/* clean up ? */ |
193 |
|
pfree(values[0]); |
194 |
|
pfree(values[1]); |
195 |
|
pfree(values[2]); |
196 |
|
pfree(values[3]); |
197 |
|
pfree(values); |
198 |
|
|
199 |
elog(INFO, "row: %s|%s|%s|%s",values[0],values[1],values[2],values[3]); |
elog(INFO, "row: %s|%s|%s|%s",values[0],values[1],values[2],values[3]); |
200 |
|
|
201 |
SRF_RETURN_NEXT(funcctx, result); |
SRF_RETURN_NEXT(funcctx, result); |
202 |
} else { |
} else { |
203 |
|
elog(INFO, "loop over"); |
204 |
|
|
205 |
/* free swish object and close */ |
/* free swish object and close */ |
206 |
Free_Search_Object( search ); |
Free_Search_Object( search ); |
207 |
SwishClose( swish_handle ); |
SwishClose( swish_handle ); |