33 #include "utils/array.h"
51 char *combinations_sql,
57 size_t *result_count) {
62 size_t size_start_vidsArr = 0;
63 int64_t *start_vidsArr = NULL;
65 size_t size_end_vidsArr = 0;
66 int64_t *end_vidsArr = NULL;
68 size_t total_combinations = 0;
72 start_vidsArr = (int64_t*)
74 end_vidsArr = (int64_t*)
76 }
else if (combinations_sql) {
78 if (total_combinations == 0) {
86 (*result_tuples) = NULL;
91 size_t total_edges = 0;
94 PGR_DBG(
"Total %ld edges in query:", total_edges);
96 if (total_edges == 0) {
105 PGR_DBG(
"Starting processing");
106 clock_t start_t = clock();
107 char *log_msg = NULL;
108 char *notice_msg = NULL;
109 char *err_msg = NULL;
115 start_vidsArr, size_start_vidsArr,
116 end_vidsArr, size_end_vidsArr,
127 time_msg(
" processing pgr_edwardMoore", start_t, clock());
128 PGR_DBG(
"Returning %ld tuples", *result_count);
132 pfree(*result_tuples);
147 pfree(start_vidsArr);
154 FuncCallContext *funcctx;
155 TupleDesc tuple_desc;
159 size_t result_count = 0;
162 if (SRF_IS_FIRSTCALL()) {
163 MemoryContext oldcontext;
164 funcctx = SRF_FIRSTCALL_INIT();
165 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
168 if (PG_NARGS() == 4) {
173 text_to_cstring(PG_GETARG_TEXT_P(0)),
175 PG_GETARG_ARRAYTYPE_P(1),
176 PG_GETARG_ARRAYTYPE_P(2),
181 }
else if (PG_NARGS() == 3) {
186 text_to_cstring(PG_GETARG_TEXT_P(0)),
187 text_to_cstring(PG_GETARG_TEXT_P(1)),
198 #if PGSQL_VERSION > 95
199 funcctx->max_calls = result_count;
201 funcctx->max_calls = (uint32_t)result_count;
203 funcctx->user_fctx = result_tuples;
204 if (get_call_result_type(fcinfo, NULL, &tuple_desc) != TYPEFUNC_COMPOSITE) {
206 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
207 errmsg(
"function returning record called in context "
208 "that cannot accept type record")));
211 funcctx->tuple_desc = tuple_desc;
212 MemoryContextSwitchTo(oldcontext);
215 funcctx = SRF_PERCALL_SETUP();
216 tuple_desc = funcctx->tuple_desc;
219 if (funcctx->call_cntr < funcctx->max_calls) {
238 values = palloc(numb *
sizeof(Datum));
239 nulls = palloc(numb *
sizeof(
bool));
242 for (i = 0; i < numb; ++i) {
246 values[0] = Int32GetDatum(funcctx->call_cntr + 1);
247 values[1] = Int32GetDatum(result_tuples[funcctx->call_cntr].
seq);
248 values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].
start_id);
249 values[3] = Int64GetDatum(result_tuples[funcctx->call_cntr].
end_id);
250 values[4] = Int64GetDatum(result_tuples[funcctx->call_cntr].
node);
251 values[5] = Int64GetDatum(result_tuples[funcctx->call_cntr].
edge);
252 values[6] = Float8GetDatum(result_tuples[funcctx->call_cntr].
cost);
253 values[7] = Float8GetDatum(result_tuples[funcctx->call_cntr].
agg_cost);
257 tuple = heap_form_tuple(tuple_desc, values, nulls);
258 result = HeapTupleGetDatum(tuple);
259 SRF_RETURN_NEXT(funcctx, result);
267 SRF_RETURN_DONE(funcctx);