50 size_t *result_count) {
55 size_t total_tuples = 0;
58 if (total_tuples == 0) {
61 (*result_tuples) = NULL;
65 PGR_DBG(
"Total %ld tuples in query:", total_tuples);
67 clock_t start_t = clock();
70 char *notice_msg = NULL;
80 time_msg(
" processing FloydWarshall", start_t, clock());
82 if (err_msg && (*result_tuples)) {
84 (*result_tuples) = NULL;
91 if (log_msg) pfree(log_msg);
92 if (notice_msg) pfree(notice_msg);
93 if (err_msg) pfree(err_msg);
102 FuncCallContext *funcctx;
103 TupleDesc tuple_desc;
108 size_t result_count = 0;
112 if (SRF_IS_FIRSTCALL()) {
113 MemoryContext oldcontext;
114 funcctx = SRF_FIRSTCALL_INIT();
115 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
132 text_to_cstring(PG_GETARG_TEXT_P(0)),
140 #if PGSQL_VERSION > 95
141 funcctx->max_calls = result_count;
143 funcctx->max_calls = (uint32_t)result_count;
145 funcctx->user_fctx = result_tuples;
146 if (get_call_result_type(fcinfo, NULL, &tuple_desc)
147 != TYPEFUNC_COMPOSITE)
149 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
150 errmsg(
"function returning record called in context "
151 "that cannot accept type record")));
153 funcctx->tuple_desc = tuple_desc;
154 MemoryContextSwitchTo(oldcontext);
157 funcctx = SRF_PERCALL_SETUP();
158 tuple_desc = funcctx->tuple_desc;
161 if (funcctx->call_cntr < funcctx->max_calls) {
168 values = palloc(3 *
sizeof(Datum));
169 nulls = palloc(3 *
sizeof(
bool));
172 values[0] = Int64GetDatum(result_tuples[funcctx->call_cntr].
from_vid);
174 values[1] = Int64GetDatum(result_tuples[funcctx->call_cntr].
to_vid);
176 values[2] = Float8GetDatum(result_tuples[funcctx->call_cntr].
cost);
180 tuple = heap_form_tuple(tuple_desc, values, nulls);
181 result = HeapTupleGetDatum(tuple);
182 SRF_RETURN_NEXT(funcctx, result);
184 SRF_RETURN_DONE(funcctx);