60 PGDLLEXPORT Datum
bridges(PG_FUNCTION_ARGS);
71 size_t *result_count) {
77 (*result_tuples) = NULL;
82 size_t total_edges = 0;
85 PGR_DBG(
"Total %ld edges in query:", total_edges);
87 if (total_edges == 0) {
94 clock_t start_t = clock();
96 char *notice_msg = NULL;
106 start_vidsArr, size_start_vidsArr,
107 end_vidsArr, size_end_vidsArr,
116 time_msg(
" processing pgr_bridges", start_t, clock());
117 PGR_DBG(
"Returning %ld tuples", *result_count);
120 if (*result_tuples) pfree(*result_tuples);
124 if (edges) pfree(edges);
125 if (log_msg) pfree(log_msg);
126 if (notice_msg) pfree(notice_msg);
127 if (err_msg) pfree(err_msg);
133 if (end_vidsArr) pfree(end_vidsArr);
134 if (start_vidsArr) pfree(start_vidsArr);
143 FuncCallContext *funcctx;
144 TupleDesc tuple_desc;
150 size_t result_count = 0;
154 if (SRF_IS_FIRSTCALL()) {
155 MemoryContext oldcontext;
156 funcctx = SRF_FIRSTCALL_INIT();
157 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
171 text_to_cstring(PG_GETARG_TEXT_P(0)),
177 PG_GETARG_ARRAYTYPE_P(1),
178 PG_GETARG_ARRAYTYPE_P(2),
186 #if PGSQL_VERSION > 94
187 funcctx->max_calls = (uint32_t)result_count;
189 funcctx->max_calls = (uint32_t)result_count;
191 funcctx->user_fctx = result_tuples;
192 if (get_call_result_type(fcinfo, NULL, &tuple_desc)
193 != TYPEFUNC_COMPOSITE) {
195 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
196 errmsg(
"function returning record called in context "
197 "that cannot accept type record")));
200 funcctx->tuple_desc = tuple_desc;
201 MemoryContextSwitchTo(oldcontext);
204 funcctx = SRF_PERCALL_SETUP();
205 tuple_desc = funcctx->tuple_desc;
208 if (funcctx->call_cntr < funcctx->max_calls) {
223 values = palloc(2 *
sizeof(Datum));
224 nulls = palloc(2 *
sizeof(
bool));
228 for (i = 0; i < 2; ++i) {
233 values[0] = Int32GetDatum(funcctx->call_cntr + 1);
234 values[1] = Int64GetDatum(result_tuples[funcctx->call_cntr].
identifier);
237 tuple = heap_form_tuple(tuple_desc, values, nulls);
238 result = HeapTupleGetDatum(tuple);
239 SRF_RETURN_NEXT(funcctx, result);
248 SRF_RETURN_DONE(funcctx);
static edge_t edges[22573]
void time_msg(char *msg, clock_t start_t, clock_t end_t)
PG_FUNCTION_INFO_V1(bridges)
void pgr_global_report(char *log, char *notice, char *err)
notice & error
void pgr_SPI_finish(void)
static void process(char *edges_sql, pgr_components_rt **result_tuples, size_t *result_count)
void pgr_SPI_connect(void)
PGDLLEXPORT Datum bridges(PG_FUNCTION_ARGS)
postgres_connection.h
void do_pgr_bridges(pgr_edge_t *data_edges, size_t total_edges, pgr_components_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)