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;
87 time_msg(
" processing pgr_makeConnected", start_t, clock());
88 PGR_DBG(
"Returning %ld tuples", *result_count);
92 pfree(*result_tuples);
110 FuncCallContext *funcctx;
111 TupleDesc tuple_desc;
115 size_t result_count = 0;
118 if (SRF_IS_FIRSTCALL()) {
119 MemoryContext oldcontext;
120 funcctx = SRF_FIRSTCALL_INIT();
121 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
132 text_to_cstring(PG_GETARG_TEXT_P(0)),
138 #if PGSQL_VERSION > 95
139 funcctx->max_calls = result_count;
141 funcctx->max_calls = (uint32_t)result_count;
143 funcctx->user_fctx = result_tuples;
144 if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) {
146 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
147 errmsg(
"function returning record called in context "
148 "that cannot accept type record")));
151 funcctx->tuple_desc = tuple_desc;
152 MemoryContextSwitchTo(oldcontext);
155 funcctx = SRF_PERCALL_SETUP();
156 tuple_desc = funcctx->tuple_desc;
159 if (funcctx->call_cntr < funcctx->max_calls) {
172 values = palloc(numb *
sizeof(Datum));
173 nulls = palloc(numb *
sizeof(
bool));
176 for (i = 0; i < numb; ++i) {
180 values[0] = Int32GetDatum(funcctx->call_cntr + 1);
181 values[1] = Int64GetDatum(result_tuples[funcctx->call_cntr].
start_vid);
182 values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].
end_vid);
186 tuple = heap_form_tuple(tuple_desc, values, nulls);
187 result = HeapTupleGetDatum(tuple);
188 SRF_RETURN_NEXT(funcctx, result);
196 SRF_RETURN_DONE(funcctx);