51 restriction->
cost = -1;
54 restriction->
via = NULL;
58 tuple, tupdesc, info[2], &restriction->
via_size);
64 char *restrictions_sql,
66 size_t *total_restrictions) {
67 const int tuple_limit = 1000000;
68 clock_t start_t = clock();
70 PGR_DBG(
"pgr_get_restrictions");
71 PGR_DBG(
"%s", restrictions_sql);
76 for (i = 0; i < 3; ++i) {
84 info[1].
name =
"cost";
86 info[2].
name =
"path";
101 bool moredata =
true;
102 (*total_restrictions) = total_tuples = 0;
107 while (moredata ==
true) {
108 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
109 if (total_tuples == 0) {
112 size_t ntuples = SPI_processed;
113 total_tuples += ntuples;
114 PGR_DBG(
"Restrictions to be processed %ld", ntuples);
117 if ((*restrictions) == NULL) {
126 if ((*restrictions) == NULL) {
127 elog(ERROR,
"Out of memory");
131 SPITupleTable *tuptable = SPI_tuptable;
132 TupleDesc tupdesc = SPI_tuptable->tupdesc;
133 PGR_DBG(
"processing %ld", ntuples);
134 for (t = 0; t < ntuples; t++) {
135 HeapTuple tuple = tuptable->vals[t];
137 &(*restrictions)[total_tuples - ntuples + t]);
139 SPI_freetuptable(tuptable);
145 SPI_cursor_close(SPIportal);
147 if (total_tuples == 0) {
148 (*total_restrictions) = 0;
153 (*total_restrictions) = total_tuples;
154 PGR_DBG(
"Finish reading %ld restrictions, %ld",
156 (*total_restrictions));
157 clock_t end_t = clock();
158 time_msg(
" reading Restrictions", start_t, end_t);