45 distance->
id = *default_id;
60 size_t *total_coordinates) {
61 clock_t start_t = clock();
63 const int tuple_limit = 1000000;
66 size_t total_tuples = 0;
71 for (i = 0; i < 3; ++i) {
77 info[0].
name = strdup(
"id");
78 info[1].
name = strdup(
"x");
79 info[2].
name = strdup(
"y");
93 (*total_coordinates) = total_tuples;
95 int64_t default_id = 1;
97 while (moredata == TRUE) {
98 SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
99 if (total_tuples == 0)
102 ntuples = SPI_processed;
103 total_tuples += ntuples;
106 if ((*coordinates) == NULL)
111 repalloc((*coordinates),
114 if ((*coordinates) == NULL) {
115 elog(ERROR,
"Out of memory");
118 SPITupleTable *tuptable = SPI_tuptable;
119 TupleDesc tupdesc = SPI_tuptable->tupdesc;
120 PGR_DBG(
"Processing %ld coordinates tupĺes", ntuples);
123 for (t = 0; t < ntuples; t++) {
124 HeapTuple tuple = tuptable->vals[t];
127 &(*coordinates)[total_tuples - ntuples + t]);
129 SPI_freetuptable(tuptable);
135 SPI_cursor_close(SPIportal);
138 if (total_tuples == 0) {
139 (*total_coordinates) = 0;
144 (*total_coordinates) = total_tuples;
145 time_msg(
" reading coordinates:", start_t, clock());
int64_t pgr_SPI_getBigInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
void time_msg(char *msg, clock_t start_t, clock_t end_t)
void pgr_fetch_column_info(Column_info_t info[], int info_size)
bool column_found(int colNumber)
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
double pgr_SPI_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
SPIPlanPtr pgr_SPI_prepare(char *sql)