52 int64_t **result_tuples,
53 size_t *result_count) {
56 (*result_tuples) = NULL;
60 size_t total_edges = 0;
64 if (total_edges == 0) {
69 clock_t start_t = clock();
71 char *notice_msg = NULL;
83 time_msg(
" processing pgr_bridges", start_t, clock());
86 if (*result_tuples) pfree(*result_tuples);
90 if (edges) pfree(edges);
91 if (log_msg) pfree(log_msg);
92 if (notice_msg) pfree(notice_msg);
93 if (err_msg) pfree(err_msg);
99 FuncCallContext *funcctx;
100 TupleDesc tuple_desc;
102 int64_t *result_tuples = NULL;
103 size_t result_count = 0;
105 if (SRF_IS_FIRSTCALL()) {
106 MemoryContext oldcontext;
107 funcctx = SRF_FIRSTCALL_INIT();
108 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
111 text_to_cstring(PG_GETARG_TEXT_P(0)),
116 #if PGSQL_VERSION > 94
117 funcctx->max_calls = (uint32_t)result_count;
119 funcctx->max_calls = (uint32_t)result_count;
121 funcctx->user_fctx = result_tuples;
122 if (get_call_result_type(fcinfo, NULL, &tuple_desc)
123 != TYPEFUNC_COMPOSITE) {
125 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
126 errmsg(
"function returning record called in context "
127 "that cannot accept type record")));
130 funcctx->tuple_desc = tuple_desc;
131 MemoryContextSwitchTo(oldcontext);
134 funcctx = SRF_PERCALL_SETUP();
135 tuple_desc = funcctx->tuple_desc;
136 result_tuples = (int64_t*) funcctx->user_fctx;
138 if (funcctx->call_cntr < funcctx->max_calls) {
145 values = palloc(2 *
sizeof(Datum));
146 nulls = palloc(2 *
sizeof(
bool));
150 for (i = 0; i < 2; ++i) {
154 values[0] = Int32GetDatum(funcctx->call_cntr + 1);
155 values[1] = Int64GetDatum(result_tuples[funcctx->call_cntr]);
157 tuple = heap_form_tuple(tuple_desc, values, nulls);
158 result = HeapTupleGetDatum(tuple);
159 SRF_RETURN_NEXT(funcctx, result);
161 SRF_RETURN_DONE(funcctx);