33 #include "utils/array.h"
55 char* combinations_sql,
61 size_t *result_count) {
64 int64_t* start_vidsArr = NULL;
65 size_t size_start_vidsArr = 0;
67 int64_t* end_vidsArr = NULL;
68 size_t size_end_vidsArr = 0;
71 size_t total_edges = 0;
74 size_t total_combinations = 0;
77 start_vidsArr = (int64_t*)
79 end_vidsArr = (int64_t*)
81 }
else if (combinations_sql) {
86 PGR_DBG(
"Total %ld edges in query:", total_edges);
88 if (total_edges == 0) {
95 clock_t start_t = clock();
97 char *notice_msg = NULL;
101 combinations, total_combinations,
102 start_vidsArr, size_start_vidsArr,
103 end_vidsArr, size_end_vidsArr,
114 time_msg(
" processing pgr_bdDijkstra", start_t, clock());
117 if (err_msg && (*result_tuples)) {
118 pfree(*result_tuples);
119 (*result_tuples) = NULL;
125 if (log_msg) pfree(log_msg);
126 if (notice_msg) pfree(notice_msg);
127 if (err_msg) pfree(err_msg);
128 if (edges) pfree(edges);
136 FuncCallContext *funcctx;
137 TupleDesc tuple_desc;
143 size_t result_count = 0;
147 if (SRF_IS_FIRSTCALL()) {
148 MemoryContext oldcontext;
149 funcctx = SRF_FIRSTCALL_INIT();
150 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
153 if (PG_NARGS() == 5) {
158 text_to_cstring(PG_GETARG_TEXT_P(0)),
160 PG_GETARG_ARRAYTYPE_P(1),
161 PG_GETARG_ARRAYTYPE_P(2),
167 }
else if (PG_NARGS() == 4) {
172 text_to_cstring(PG_GETARG_TEXT_P(0)),
173 text_to_cstring(PG_GETARG_TEXT_P(1)),
185 #if PGSQL_VERSION > 95
186 funcctx->max_calls = result_count;
188 funcctx->max_calls = (uint32_t)result_count;
190 funcctx->user_fctx = result_tuples;
191 if (get_call_result_type(fcinfo, NULL, &tuple_desc)
192 != TYPEFUNC_COMPOSITE) {
194 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
195 errmsg(
"function returning record called in context "
196 "that cannot accept type record")));
199 funcctx->tuple_desc = tuple_desc;
200 MemoryContextSwitchTo(oldcontext);
203 funcctx = SRF_PERCALL_SETUP();
204 tuple_desc = funcctx->tuple_desc;
208 if (funcctx->call_cntr < funcctx->max_calls) {
213 size_t call_cntr = funcctx->call_cntr;
228 values = palloc(numb *
sizeof(Datum));
229 nulls = palloc(numb *
sizeof(
bool));
233 for (i = 0; i < numb; ++i) {
237 values[0] = Int32GetDatum(call_cntr + 1);
238 values[1] = Int32GetDatum(result_tuples[call_cntr].seq);
239 values[2] = Int64GetDatum(result_tuples[call_cntr].start_id);
240 values[3] = Int64GetDatum(result_tuples[call_cntr].end_id);
241 values[4] = Int64GetDatum(result_tuples[call_cntr].node);
242 values[5] = Int64GetDatum(result_tuples[call_cntr].
edge);
243 values[6] = Float8GetDatum(result_tuples[call_cntr].cost);
244 values[7] = Float8GetDatum(result_tuples[call_cntr].agg_cost);
248 tuple = heap_form_tuple(tuple_desc, values, nulls);
249 result = HeapTupleGetDatum(tuple);
250 SRF_RETURN_NEXT(funcctx, result);
252 SRF_RETURN_DONE(funcctx);