53 char *restrictions_sql,
64 size_t *result_count) {
72 size_t k = (size_t)p_k;
74 if (start_vid == end_vid) {
75 PGR_DBG(
"Source and target are the same");
83 size_t total_edges = 0;
89 size_t total_restrictions = 0;
94 if (total_edges == 0) {
100 clock_t start_t = clock();
101 char *log_msg = NULL;
102 char *notice_msg = NULL;
103 char *err_msg = NULL;
123 time_msg(
" processing pgr_turnRestrictedPath", start_t, clock());
126 if (*path) pfree(*path);
130 if (edges) {pfree(edges); edges = NULL;}
131 if (log_msg) {pfree(log_msg); log_msg = NULL;}
132 if (notice_msg) {pfree(notice_msg); notice_msg = NULL;}
133 if (err_msg) {pfree(err_msg); err_msg = NULL;}
134 if (restrictions) {pfree(restrictions); edges = NULL;}
141 FuncCallContext *funcctx;
142 TupleDesc tuple_desc;
145 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);
175 text_to_cstring(PG_GETARG_TEXT_P(0)),
176 text_to_cstring(PG_GETARG_TEXT_P(1)),
187 #if PGSQL_VERSION > 95
188 funcctx->max_calls = result_count;
190 funcctx->max_calls = (uint32_t)result_count;
192 funcctx->user_fctx = path;
193 if (get_call_result_type(fcinfo, NULL, &tuple_desc)
194 != TYPEFUNC_COMPOSITE) {
196 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
197 errmsg(
"function returning record called in context "
198 "that cannot accept type record")));
201 funcctx->tuple_desc = tuple_desc;
202 MemoryContextSwitchTo(oldcontext);
205 funcctx = SRF_PERCALL_SETUP();
206 tuple_desc = funcctx->tuple_desc;
209 if (funcctx->call_cntr < funcctx->max_calls) {
228 values = palloc(v_count *
sizeof(Datum));
229 nulls = palloc(v_count *
sizeof(
bool));
233 for (i = 0; i < v_count; ++i) {
237 values[0] = Int32GetDatum(funcctx->call_cntr + 1);
238 values[1] = Int32GetDatum(path[funcctx->call_cntr].
start_id + 1);
239 values[2] = Int32GetDatum(path[funcctx->call_cntr].
seq);
240 values[3] = Int64GetDatum(path[funcctx->call_cntr].
node);
241 values[4] = Int64GetDatum(path[funcctx->call_cntr].
edge);
242 values[5] = Float8GetDatum(path[funcctx->call_cntr].
cost);
243 values[6] = Float8GetDatum(path[funcctx->call_cntr].
agg_cost);
246 tuple = heap_form_tuple(tuple_desc, values, nulls);
247 result = HeapTupleGetDatum(tuple);
248 SRF_RETURN_NEXT(funcctx, result);
250 SRF_RETURN_DONE(funcctx);