55 size_t *valid_combinations) {
59 *valid_combinations = *valid_combinations + 1;
69 size_t *totalTuples) {
70 clock_t start_t = clock();
72 const int tuple_limit = 1000000;
75 size_t valid_combinations;
80 for (i = 0; i < 2; ++i) {
86 info[0].
name =
"source";
87 info[1].
name =
"target";
97 (*totalTuples) = total_tuples = valid_combinations = 0;
99 while (moredata ==
true) {
100 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
101 if (total_tuples == 0)
104 size_t ntuples = SPI_processed;
105 total_tuples += ntuples;
108 if ((*combinations) == NULL)
115 if ((*combinations) == NULL) {
116 elog(ERROR,
"Out of memory");
120 SPITupleTable *tuptable = SPI_tuptable;
121 TupleDesc tupdesc = SPI_tuptable->tupdesc;
122 for (t = 0; t < ntuples; t++) {
123 HeapTuple tuple = tuptable->vals[t];
125 &(*combinations)[total_tuples - ntuples + t],
126 &valid_combinations);
128 SPI_freetuptable(tuptable);
134 SPI_cursor_close(SPIportal);
136 if (total_tuples == 0 || valid_combinations == 0) {
137 PGR_DBG(
"No combinations found");
140 (*totalTuples) = total_tuples;
141 PGR_DBG(
"Reading %ld combinations", total_tuples);
142 time_msg(
"reading combinations", start_t, clock());
148 char *combinations_sql,
150 size_t *total_combinations) {