79 time_window->
id =
get_Idx(tuple, tupdesc, info[0], 0);
82 char kind =
get_Kind(tuple, tupdesc, info[1],
' ');
83 if (kind !=
'p' && kind !=
'd') {
84 ereport(ERROR, (errmsg(
"Invalid kind %c", kind),
85 errhint(
"Kind must be either 'p' or 'd'")));
87 time_window->
kind = kind;
111 (errmsg(
"Invalid time window (%d, %d)",
113 errhint(
"Time window start time %d must be "
114 "less than or equal to time window end time %d",
122 char *time_windows_sql,
124 size_t *total_time_windows,
127 const int column_count,
131 clock_t start_t = clock();
132 PGR_DBG(
"%s", time_windows_sql);
135 const int tuple_limit = 1000000;
144 bool moredata =
true;
145 (*total_time_windows) = total_tuples = 0;
149 while (moredata ==
true) {
150 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
151 if (total_tuples == 0) {
154 size_t ntuples = SPI_processed;
155 total_tuples += ntuples;
157 if ((*time_windows) == NULL)
165 if ((*time_windows) == NULL) {
166 elog(ERROR,
"Out of memory");
170 SPITupleTable *tuptable = SPI_tuptable;
171 TupleDesc tupdesc = SPI_tuptable->tupdesc;
172 for (t = 0; t < ntuples; t++) {
173 HeapTuple tuple = tuptable->vals[t];
175 &(*time_windows)[total_tuples - ntuples + t],
176 is_shipment, is_plain);
178 SPI_freetuptable(tuptable);
184 SPI_cursor_close(SPIportal);
186 if (total_tuples == 0) {
187 (*total_time_windows) = 0;
191 (*total_time_windows) = total_tuples;
193 time_msg(
"reading time windows", start_t, clock());
209 int kColumnCount = 3;
212 for (
int i = 0; i < kColumnCount; ++i) {
220 info[1].
name =
"tw_open";
221 info[2].
name =
"tw_close";
244 int kColumnCount = 4;
247 for (
int i = 0; i < kColumnCount; ++i) {
255 info[1].
name =
"kind";
256 info[2].
name =
"tw_open";
257 info[3].
name =
"tw_close";