33 #include "utils/array.h"
51 size_t *result_count) {
57 (*result_tuples) = NULL;
62 size_t total_edges = 0;
65 PGR_DBG(
"Total %ld edges in query:", total_edges);
67 if (total_edges == 0) {
73 clock_t start_t = clock();
75 char *notice_msg = NULL;
88 time_msg(
" processing pgr_boyerMyrvold", start_t, clock());
89 PGR_DBG(
"Returning %ld tuples", *result_count);
93 pfree(*result_tuples);
111 FuncCallContext *funcctx;
112 TupleDesc tuple_desc;
116 size_t result_count = 0;
119 if (SRF_IS_FIRSTCALL()) {
120 MemoryContext oldcontext;
121 funcctx = SRF_FIRSTCALL_INIT();
122 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
133 text_to_cstring(PG_GETARG_TEXT_P(0)),
139 #if PGSQL_VERSION > 95
140 funcctx->max_calls = result_count;
142 funcctx->max_calls = (uint32_t)result_count;
144 funcctx->user_fctx = result_tuples;
145 if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) {
147 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
148 errmsg(
"function returning record called in context "
149 "that cannot accept type record")));
152 funcctx->tuple_desc = tuple_desc;
153 MemoryContextSwitchTo(oldcontext);
156 funcctx = SRF_PERCALL_SETUP();
157 tuple_desc = funcctx->tuple_desc;
160 if (funcctx->call_cntr < funcctx->max_calls) {
174 values = palloc(numb *
sizeof(Datum));
175 nulls = palloc(numb *
sizeof(
bool));
178 for (i = 0; i < numb; ++i) {
182 values[0] = Int32GetDatum(funcctx->call_cntr + 1);
183 values[1] = Int64GetDatum(result_tuples[funcctx->call_cntr].
source);
184 values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].
target);
185 values[3] = Float8GetDatum(result_tuples[funcctx->call_cntr].
cost);
189 tuple = heap_form_tuple(tuple_desc, values, nulls);
190 result = HeapTupleGetDatum(tuple);
191 SRF_RETURN_NEXT(funcctx, result);
199 SRF_RETURN_DONE(funcctx);