198 |
pfree(values[3]); |
pfree(values[3]); |
199 |
pfree(values); |
pfree(values); |
200 |
|
|
201 |
elog(INFO, "row: %s|%s|%s|%s",values[0],values[1],values[2],values[3]); |
elog(DEBUG1, "row: %s|%s|%s|%s",values[0],values[1],values[2],values[3]); |
202 |
|
|
203 |
SRF_RETURN_NEXT(funcctx, result); |
SRF_RETURN_NEXT(funcctx, result); |
204 |
} else { |
} else { |
217 |
PG_FUNCTION_INFO_V1(pgswish2); |
PG_FUNCTION_INFO_V1(pgswish2); |
218 |
Datum pgswish2(PG_FUNCTION_ARGS) |
Datum pgswish2(PG_FUNCTION_ARGS) |
219 |
{ |
{ |
|
int ncols = 2; |
|
220 |
int nrows = 3; |
int nrows = 3; |
221 |
int16 typlen; |
int16 typlen; |
222 |
bool typbyval; |
bool typbyval; |
230 |
MemoryContext oldcontext; |
MemoryContext oldcontext; |
231 |
Datum dvalue; |
Datum dvalue; |
232 |
char **values; |
char **values; |
233 |
int rsinfo_ncols; |
int ncols; |
234 |
int i, j; |
int i, j; |
235 |
|
|
236 |
/* check to see if caller supports us returning a tuplestore */ |
/* check to see if caller supports us returning a tuplestore */ |
242 |
|
|
243 |
/* get the requested return tuple description */ |
/* get the requested return tuple description */ |
244 |
tupdesc = rsinfo->expectedDesc; |
tupdesc = rsinfo->expectedDesc; |
245 |
rsinfo_ncols = tupdesc->natts; |
ncols = tupdesc->natts; |
246 |
|
|
247 |
/* |
/* |
248 |
* The requested tuple description better match up with the array |
* The requested tuple description better match up with the array |
249 |
* we were given. |
* we were given. |
250 |
*/ |
*/ |
|
elog(INFO, "rsinfo_ncols = %d, ncols = %d", rsinfo_ncols, ncols); |
|
|
|
|
251 |
/* OK, use it */ |
/* OK, use it */ |
252 |
attinmeta = TupleDescGetAttInMetadata(tupdesc); |
attinmeta = TupleDescGetAttInMetadata(tupdesc); |
253 |
|
|
298 |
char *prop; |
char *prop; |
299 |
int len; |
int len; |
300 |
|
|
301 |
elog(DEBUG1, "prop2text(%s)", propname); |
elog(DEBUG2, "prop2text(%s)", propname); |
302 |
|
|
303 |
prop = SwishResultPropertyStr( sw_res, propname ); |
prop = SwishResultPropertyStr( sw_res, propname ); |
304 |
error_or_abort( swish_handle ); |
error_or_abort( swish_handle ); |
305 |
|
|
306 |
len = strlen(prop); |
len = strlen(prop); |
307 |
elog(INFO, "prop2text(%s) = '%s' %d bytes", propname, prop, len); |
elog(DEBUG1, "prop2text(%s) = '%s' %d bytes", propname, prop, len); |
308 |
|
|
309 |
len++; |
len++; |
310 |
len *= sizeof(char); |
len *= sizeof(char); |
311 |
|
|
312 |
elog(DEBUG1, "palloc(%d)", len); |
elog(DEBUG2, "palloc(%d)", len); |
313 |
|
|
314 |
val = palloc(len); |
val = palloc(len); |
315 |
|
|
316 |
memset(val, 0, len); |
memset(val, 0, len); |
317 |
strncpy(val, prop, len); |
strncpy(val, prop, len); |
318 |
|
|
319 |
elog(DEBUG1, "val=%s", val); |
elog(DEBUG2, "val=%s", val); |
320 |
|
|
321 |
return val; |
return val; |
322 |
} |
} |
327 |
unsigned long prop; |
unsigned long prop; |
328 |
int len; |
int len; |
329 |
|
|
330 |
elog(DEBUG1, "prop2int(%s)", propname); |
elog(DEBUG2, "prop2int(%s)", propname); |
331 |
|
|
332 |
prop = SwishResultPropertyULong( sw_res, propname ); |
prop = SwishResultPropertyULong( sw_res, propname ); |
333 |
error_or_abort( swish_handle ); |
error_or_abort( swish_handle ); |
334 |
|
|
335 |
elog(INFO, "prop2int(%s) = %lu", propname, prop); |
elog(DEBUG1, "prop2int(%s) = %lu", propname, prop); |
336 |
|
|
337 |
len = 128 * sizeof(char); |
len = 128 * sizeof(char); |
338 |
elog(DEBUG1, "palloc(%d)", len); |
elog(DEBUG2, "palloc(%d)", len); |
339 |
|
|
340 |
val = palloc(len); |
val = palloc(len); |
341 |
memset(val, 0, len); |
memset(val, 0, len); |
342 |
|
|
343 |
snprintf(val, len, "%lu", prop); |
snprintf(val, len, "%lu", prop); |
344 |
|
|
345 |
elog(DEBUG1, "val=%s", val); |
elog(DEBUG2, "val=%s", val); |
346 |
|
|
347 |
return val; |
return val; |
348 |
} |
} |