46 distance->
id = *default_id;
61 size_t *total_coordinates) {
62 clock_t start_t = clock();
64 const int tuple_limit = 1000000;
67 size_t total_tuples = 0;
72 for (i = 0; i < 3; ++i) {
78 info[0].
name = strdup(
"id");
79 info[1].
name = strdup(
"x");
80 info[2].
name = strdup(
"y");
94 (*total_coordinates) = total_tuples;
96 int64_t default_id = 1;
98 while (moredata == TRUE) {
99 SPI_cursor_fetch(SPIportal, TRUE, tuple_limit);
100 if (total_tuples == 0)
103 ntuples = SPI_processed;
104 total_tuples += ntuples;
107 if ((*coordinates) == NULL)
112 repalloc((*coordinates),
115 if ((*coordinates) == NULL) {
116 elog(ERROR,
"Out of memory");
119 SPITupleTable *tuptable = SPI_tuptable;
120 TupleDesc tupdesc = SPI_tuptable->tupdesc;
121 PGR_DBG(
"Processing %ld coordinates tupĺes", ntuples);
124 for (t = 0; t < ntuples; t++) {
125 HeapTuple tuple = tuptable->vals[t];
128 &(*coordinates)[total_tuples - ntuples + t]);
130 SPI_freetuptable(tuptable);
137 if (total_tuples == 0) {
138 (*total_coordinates) = 0;
143 (*total_coordinates) = total_tuples;
144 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)