56 size_t *result_count) {
59 size_t total_edges = 0;
62 if (total_edges == 0) {
68 clock_t start_t = clock();
70 char* notice_msg = NULL;
74 result_tuples, result_count,
79 time_msg(
"processing pgr_bipartite()", start_t, clock());
82 if (err_msg && (*result_tuples)) {
83 pfree(*result_tuples);
84 (*result_tuples) = NULL;
90 if (log_msg) pfree(log_msg);
91 if (notice_msg) pfree(notice_msg);
92 if (err_msg) pfree(err_msg);
93 if (edges) pfree(edges);
99 FuncCallContext *funcctx;
100 TupleDesc tuple_desc;
102 size_t result_count = 0;
103 if (SRF_IS_FIRSTCALL()) {
104 MemoryContext oldcontext;
105 funcctx = SRF_FIRSTCALL_INIT();
106 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
108 text_to_cstring(PG_GETARG_TEXT_P(0)),
113 #if PGSQL_VERSION > 95
114 funcctx->max_calls = result_count;
116 funcctx->max_calls = (uint32_t)result_count;
118 funcctx->user_fctx = result_tuples;
119 if (get_call_result_type(fcinfo, NULL, &tuple_desc)
120 != TYPEFUNC_COMPOSITE)
122 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
123 errmsg(
"function returning record called in context "
124 "that cannot accept type record")));
125 funcctx->tuple_desc = tuple_desc;
126 MemoryContextSwitchTo(oldcontext);
129 funcctx = SRF_PERCALL_SETUP();
130 tuple_desc = funcctx->tuple_desc;
133 if (funcctx->call_cntr < funcctx->max_calls) {
138 size_t call_cntr = funcctx->call_cntr;
141 values =(Datum *)palloc(numb *
sizeof(Datum));
142 nulls = palloc(numb *
sizeof(
bool));
144 for (i = 0; i < numb; ++i) {
147 values[0] = Int64GetDatum(result_tuples[call_cntr].vid);
148 values[1] = Int64GetDatum(result_tuples[call_cntr].color);
149 tuple = heap_form_tuple(tuple_desc, values, nulls);
150 result = HeapTupleGetDatum(tuple);
151 SRF_RETURN_NEXT(funcctx, result);
153 SRF_RETURN_DONE(funcctx);