vrpRouting  0.3
get_check_data.c
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: get_check_data.c
3 
4 Copyright (c) 2015 pgRouting developers
6 
7 Developer:
8 Copyright (c) 2015 Celia Virginia Vergara Castillo
9 
10 ------
11 
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 
26  ********************************************************************PGR-GNU*/
27 
28 #include <stdbool.h>
29 #include <time.h>
31 #include <utils/date.h> // NOLINT [build/include_order]
32 #include <utils/datetime.h> // NOLINT [build/include_order]
33 
35 #include "c_common/arrays_input.h"
36 
37 #include "catalog/pg_type.h"
38 
39 #include "c_common/debug_macro.h"
40 #include "c_types/typedefs.h"
41 
42 static
43 void
45  if (!(info.type == 1186)) {
46  elog(ERROR,
47  "Unexpected Column '%s' type. Expected INTERVAL",
48  info.name);
49  }
50 }
51 
52 /*
53  * [BPCHAROID](https://doxygen.postgresql.org/include_2catalog_2pg__type_8h.html#afa7749dbe36d31874205189d9d6b21d7)
54  * [INT2ARRAYOID](https://doxygen.postgresql.org/include_2catalog_2pg__type_8h.html#ac265fe7b0bb75fead13b16bf072722e9)
55  */
56 static
57 void
59  if (!(info.type == BPCHAROID)) {
60  elog(ERROR, "Unexpected Column '%s' type. Expected CHAR", info.name);
61  }
62 }
63 
64 static
65 void
67  if (!(info.type == TEXTOID)) {
68  elog(ERROR, "Unexpected Column '%s' type. Expected TEXT", info.name);
69  }
70 }
71 
72 static
73 void
75  if (!(info.type == JSONBOID)) {
76  elog(ERROR, "Unexpected Column '%s' type. Expected JSONB %ld", info.name, info.type);
77  }
78 }
79 
80 static
81 void
83  if (!(info.type == INT2OID || info.type == INT4OID)) {
84  ereport(ERROR,
85  (errmsg_internal("Unexpected type in column '%s'.", info.name),
86  errhint("Expected SMALLINT or INTEGER")));
87  }
88 }
89 
90 static
91 void
93  if (!(info.type == INT2OID
94  || info.type == INT4OID
95  || info.type == INT8OID)) {
96  ereport(ERROR,
97  (errmsg_internal("Unexpected type in column '%s'.", info.name),
98  errhint("Expected ANY-INTEGER")));
99  }
100 }
101 
102 static
103 void
105  if (!(info.type == INT2ARRAYOID
106  || info.type == INT4ARRAYOID)) {
107  elog(ERROR,
108  "Unexpected Column '%s' type. Expected SMALLINT-ARRAY or INTEGER-ARRAY",
109  info.name);
110  }
111 }
112 
113 static
114 void
116  if (!(info.type == INT2ARRAYOID
117  || info.type == INT4ARRAYOID
118  || info.type == 1016)) {
119  elog(ERROR,
120  "Unexpected Column '%s' type. Expected ANY-INTEGER-ARRAY",
121  info.name);
122  }
123 }
124 
125 static
126 void
128  if (!(info.type == INT2OID
129  || info.type == INT4OID
130  || info.type == INT8OID
131  || info.type == FLOAT4OID
132  || info.type == FLOAT8OID
133  || info.type == NUMERICOID)) {
134  ereport(ERROR,
135  (errmsg_internal("Unexpected type in column '%s'.", info.name),
136  errhint("Found: %lu\nExpected ANY-NUMERICAL", info.type)));
137  }
138 }
139 
140 static
141 void
143  if (!(info.type == 1114)) {
144  elog(ERROR,
145  "Unexpected Column '%s' type. Expected TIMESTAMP",
146  info.name);
147  }
148 }
149 
150 static
151 bool
153  Column_info_t *info) {
154  /*
155  * [SPI_fnumber](https://www.postgresql.org/docs/12/spi-spi-fnumber.html)
156  */
157  info->colNumber = SPI_fnumber(SPI_tuptable->tupdesc, info->name);
158  if (info->strict && !column_found(info->colNumber)) {
159  elog(ERROR, "Column '%s' not Found", info->name);
160  }
161 
162  if (column_found(info->colNumber)) {
163  /*
164  * [SPI_gettypeid](https://www.postgresql.org/docs/12/spi-spi-gettypeid.html)
165  */
166  (info->type) = SPI_gettypeid(SPI_tuptable->tupdesc, (info->colNumber));
167  PGR_DBG("%s %ld", info->name, info->type);
168  if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
169  elog(ERROR, "Type of column '%s' not Found", info->name);
170  }
171  return true;
172  }
173  return false;
174 }
175 
176 static
177 int32_t
178 spi_getInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
179  Datum binval;
180  bool isnull;
181  int32_t value = 0;
182  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
183 
184  if (isnull) elog(ERROR, "Unexpected Null value in column %s", info.name);
185 
186  switch (info.type) {
187  case INT2OID:
188  value = (int32_t) DatumGetInt16(binval);
189  break;
190  case INT4OID:
191  value = (int32_t) DatumGetInt32(binval);
192  break;
193  default:
194  ereport(ERROR,
195  (errmsg_internal("Unexpected type in column '%s'.", info.name),
196  errhint("Found: %lu\nExpected INTEGER", info.type)));
197  }
198  return value;
199 }
200 
201 static
202 int64_t
203 spi_getBigInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
204  Datum binval;
205  bool isnull;
206  int64_t value = 0;
207  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
208 
209  if (isnull) elog(ERROR, "Unexpected Null value in column %s", info.name);
210 
211  switch (info.type) {
212  case INT2OID:
213  value = (int64_t) DatumGetInt16(binval);
214  break;
215  case INT4OID:
216  value = (int64_t) DatumGetInt32(binval);
217  break;
218  case INT8OID:
219  value = DatumGetInt64(binval);
220  break;
221  default:
222  ereport(ERROR,
223  (errmsg_internal("Unexpected type in column '%s'.", info.name),
224  errhint("Found: %lu\nExpected ANY-INTEGER", info.type)));
225  }
226  return value;
227 }
228 
229 static
231 spi_getTimeStamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
232  Datum binval;
233  bool isnull;
234  TTimestamp value = 0;
235  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
236 
237  if (isnull) elog(ERROR, "Unexpected Null value in column %s", info.name);
238 
239  switch (info.type) {
240  case 1114:
241  value = timestamp_without_timezone((TTimestamp) Int64GetDatum(binval));
242  break;
243  default:
244  elog(ERROR,
245  "[SPI_getTimeStamp] Unexpected type in column %s. found %ld expected 1114",
246  info.name, info.type);
247  }
248  return value;
249 }
250 
251 static
252 TInterval
253 spi_getInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
254  Datum binval;
255  bool isnull;
256  Interval* interval;
257 
258  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
259 
260  if (isnull) elog(ERROR, "Unexpected Null value in column %s", info.name);
261 
262  switch (info.type) {
263  case INTERVALOID:
264  interval = DatumGetIntervalP(binval);
265  break;
266  default:
267  elog(ERROR,
268  "[spi_getInterval] Unexpected type in column %s. found %ld expected %d",
269  info.name, info.type, INTERVALOID);
270  }
271  PGR_DBG("time %ld secs %ld", interval->time,
272  interval->time / 1000000
273  + interval->day * SECS_PER_DAY
274  + (int64_t)(interval->month * ((DAYS_PER_YEAR / (double) MONTHS_PER_YEAR) * SECS_PER_DAY)));
275 
276  return interval->time / 1000000
277  + interval->day * SECS_PER_DAY
278  + (int64_t)(interval->month * ((DAYS_PER_YEAR / (double) MONTHS_PER_YEAR) * SECS_PER_DAY));
279 }
280 
281 /*
282  @param[in] tuple input row to be examined.
283  @param[in] tupdesc input row description.
284  @param[in] info contain column information.
285  @param[in] default_value returned when column contain NULL value.
286 
287  @throw ERROR Unexpected Column type. Expected column type is CHAR.
288  @throw ERROR When value of column is NULL.
289 
290  @return Char type of column value is returned.
291 
292  * http://doxygen.postgresql.org/include_2catalog_2pg__type_8h.html;
293  * [SPI_getbinval](https://www.postgresql.org/docs/8.1/static/spi-spi-getbinval.html)
294  * [Datum](https://doxygen.postgresql.org/datum_8h.html)
295  * [DatumGetInt16](https://doxygen.postgresql.org/postgres_8h.html#aec991e04209850f29a8a63df0c78ba2d)
296  */
297 char
299  HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, char default_value) {
300  Datum binval;
301  bool isNull;
302  char value = default_value;
303 
304  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isNull);
305  if (!(info.type == BPCHAROID)) {
306  elog(ERROR, "Unexpected Column type of %s. Expected CHAR", info.name);
307  }
308  if (!isNull) {
309  value = ((char*)binval)[1];
310  } else {
311  if (info.strict) {
312  elog(ERROR, "Unexpected Null value in column %s", info.name);
313  }
314  value = default_value;
315  }
316  return value;
317 }
318 
319 int32_t
321  HeapTuple *tuple,
322  TupleDesc *tupdesc,
323  Column_info_t info) {
324  int32_t value = spi_getInt(tuple, tupdesc, info);
325  if (value < 0) {
326  ereport(
327  ERROR,
328  (errmsg("Invalid max_tasks value %d", value),
329  errhint(
330  "Maximum number of tasks must be greater than or equal to 0")));
331  }
332  return value;
333 }
334 
335 int64_t*
337  HeapTuple *tuple,
338  TupleDesc *tupdesc,
339  Column_info_t info,
340  size_t *the_size) {
341  bool is_null = false;
342 
343  Datum raw_array = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &is_null);
344  /*
345  * [DatumGetArrayTypeP](https://doxygen.postgresql.org/array_8h.html#aa1b8e77c103863862e06a7b7c07ec532)
346  * [pgr_get_bigIntArray](http://docs.pgrouting.org/doxy/2.2/arrays__input_8c_source.html)
347  */
348  ArrayType *pg_array = DatumGetArrayTypeP(raw_array);
349 
350  return pgr_get_bigIntArray((size_t*)the_size, pg_array);
351 }
352 
353 int64_t*
355  HeapTuple *tuple,
356  TupleDesc *tupdesc,
357  Column_info_t info,
358  size_t *the_size) {
359  bool is_null = false;
360 
361  Datum raw_array = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &is_null);
362  /*
363  * [DatumGetArrayTypeP](https://doxygen.postgresql.org/array_8h.html#aa1b8e77c103863862e06a7b7c07ec532)
364  * [pgr_get_bigIntArray](http://docs.pgrouting.org/doxy/2.2/arrays__input_8c_source.html)
365  */
366  if (!raw_array) {
367  *the_size = 0;
368  return NULL;
369  }
370 
371  ArrayType *pg_array = DatumGetArrayTypeP(raw_array);
372 
373  return pgr_get_bigIntArray_allowEmpty(the_size, pg_array);
374 }
375 
376 int64_t*
378  HeapTuple *tuple,
379  TupleDesc *tupdesc,
380  Column_info_t info,
381  size_t *the_size) {
382  int64_t *array = spi_getBigIntArr_allowEmpty(tuple, tupdesc, info, the_size);
383  for (size_t i = 0; i < *the_size; i++) {
384  if (array[i] < 0) {
385  elog(ERROR, "Unexpected Negative value %ld in array", array[i]);
386  }
387  }
388  return array;
389 }
390 
391 
392 uint32_t*
394  HeapTuple *tuple,
395  TupleDesc *tupdesc,
396  Column_info_t info,
397  size_t *the_size) {
398  bool is_null = false;
399 
400  Datum raw_array = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &is_null);
401  if (!raw_array) {
402  *the_size = 0;
403  return NULL;
404  }
405 
406  ArrayType *pg_array = DatumGetArrayTypeP(raw_array);
407 
408  return pgr_get_positiveIntArray_allowEmpty(the_size, pg_array);
409 }
410 
411 
422 get_TTimestamp_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value) {
423  return column_found(info.colNumber)?
424  (TTimestamp)spi_getBigInt(tuple, tupdesc, info)
425  : opt_value;
426 }
427 
441 get_PositiveTTimestamp_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value) {
442  TTimestamp value = get_TTimestamp_plain(tuple, tupdesc, info, opt_value);
443  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
444  return value;
445 }
446 
457 get_TTimestamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value) {
458  return column_found(info.colNumber)?
459  spi_getTimeStamp(tuple, tupdesc, info)
460  : opt_value;
461 }
462 
476 get_PositiveTTimestamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value) {
477  TTimestamp value = get_TTimestamp(tuple, tupdesc, info, opt_value);
478  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
479  return value;
480 }
481 
491 TInterval
492 get_TInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value) {
493  return column_found(info.colNumber)?
494  (TInterval)spi_getInterval(tuple, tupdesc, info)
495  : opt_value;
496 }
497 
510 TInterval
511 get_PositiveTInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value) {
512  TInterval value = get_TInterval(tuple, tupdesc, info, opt_value);
513  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
514  return (TInterval) value;
515 }
516 
526 TInterval
527 get_TInterval_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value) {
528  return column_found(info.colNumber)?
529  (TInterval)spi_getBigInt(tuple, tupdesc, info)
530  : opt_value;
531 }
532 
545 TInterval
546 get_PositiveTInterval_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value) {
547  TInterval value = get_TInterval_plain(tuple, tupdesc, info, opt_value);
548  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
549  return (TInterval) value;
550 }
551 
561 Id
562 get_Id(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Id opt_value) {
563  return column_found(info.colNumber)?
564  (Id)spi_getBigInt(tuple, tupdesc, info)
565  : opt_value;
566 }
567 
580 Idx
581 get_Idx(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Idx opt_value) {
582  Id value = get_Id(tuple, tupdesc, info, 0);
583  if (value <= 0) elog(ERROR, "Unexpected Negative value or Zero in column %s", info.name);
584  return column_found(info.colNumber)? (Idx) value : opt_value;
585 }
586 
596 StepType get_StepType(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info,
597  StepType opt_value) {
598  StepType step_type = column_found(info.colNumber)
599  ? spi_getInt(tuple, tupdesc, info)
600  : opt_value;
601  StepType min_value = 1;
602  StepType max_value = 6;
603  if (step_type < min_value || step_type > max_value) {
604  elog(ERROR, "Step value should lie between %d and %d", min_value, max_value);
605  }
606  return step_type;
607 }
608 
618 Amount
619 get_Amount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Amount opt_value) {
620  return (Amount) column_found(info.colNumber)?
621  spi_getBigInt(tuple, tupdesc, info)
622  : opt_value;
623 }
624 
637 PAmount
638 get_PositiveAmount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, PAmount opt_value) {
639  Amount value = get_Amount(tuple, tupdesc, info, 0);
640  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
641  return column_found(info.colNumber)? (PAmount) value : opt_value;
642 }
643 
644 
658 get_MatrixIndex(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, MatrixIndex opt_value) {
659  if (column_found(info.colNumber)) {
660  int64_t value = spi_getBigInt(tuple, tupdesc, info);
661  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
662  return (MatrixIndex) value;
663  }
664  return opt_value;
665 }
666 
667 
680 Duration
681 get_Duration(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Duration opt_value) {
682  if (column_found(info.colNumber)) {
683  int32_t value = spi_getInt(tuple, tupdesc, info);
684  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
685  return (Duration) value;
686  }
687  return opt_value;
688 }
689 
690 
704 get_Cost(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TravelCost opt_value) {
705  if (column_found(info.colNumber)) {
706  int32_t value = spi_getInt(tuple, tupdesc, info);
707  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
708  return (TravelCost)value;
709  }
710  return opt_value;
711 }
712 
713 
724 char
725 get_Kind(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, char opt_value) {
726  if (column_found(info.colNumber)) {
727  char value = spi_getChar(tuple, tupdesc, info, opt_value);
728  return value;
729  }
730  return opt_value;
731 }
732 
733 
746 Priority
747 get_Priority(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Priority opt_value) {
748  if (column_found(info.colNumber)) {
749  int32_t value = spi_getInt(tuple, tupdesc, info);
750  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
751  if (value > 100) elog(ERROR, "Priority exceeds the max priority 100");
752  return (Priority) value;
753  }
754  return opt_value;
755 }
756 
757 
770 Distance
771 get_Distance(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Distance opt_value) {
772  if (column_found(info.colNumber)) {
773  int32_t value = spi_getInt(tuple, tupdesc, info);
774  if (value < 0) elog(ERROR, "Unexpected Negative value in column %s", info.name);
775  return (Distance) value;
776  }
777  return opt_value;
778 }
779 
780 
781 double
782 spi_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
783  Datum binval;
784  bool isnull = false;
785  double value = 0.0;
786  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
787  if (isnull)
788  elog(ERROR, "Unexpected Null value in column %s", info.name);
789 
790  switch (info.type) {
791  case INT2OID:
792  value = (double) DatumGetInt16(binval);
793  break;
794  case INT4OID:
795  value = (double) DatumGetInt32(binval);
796  break;
797  case INT8OID:
798  value = (double) DatumGetInt64(binval);
799  break;
800  case FLOAT4OID:
801  value = (double) DatumGetFloat4(binval);
802  break;
803  case FLOAT8OID:
804  value = DatumGetFloat8(binval);
805  break;
806  case NUMERICOID:
807  /* Note: out-of-range values will be clamped to +-HUGE_VAL */
808  value = (double) DatumGetFloat8(DirectFunctionCall1(numeric_float8_no_overflow, binval));
809  break;
810  default:
811  ereport(ERROR,
812  (errmsg_internal("Unexpected type in column '%s'.", info.name),
813  errhint("Found: %lu\nExpected ANY-NUMERICAL", info.type)));
814  }
815  return value;
816 }
817 
819 spi_getCoordinate(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Coordinate opt_value) {
820  return column_found(info.colNumber)?
821  (Coordinate) spi_getFloat8(tuple, tupdesc, info)
822  : opt_value;
823 }
824 
828 /*
829  * [DatumGetCString](https://doxygen.postgresql.org/postgres_8h.html#ae401c8476d1a12b420e3061823a206a7)
830  */
831 char*
832 spi_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
833  char *val = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber));
834  return val;
835 }
836 
848  /*
849  * step 1
850  */
851  Timestamp date;
852  Timestamp time = timestamp;
853  TMODULO(time, date, USECS_PER_DAY);
854  if (time < INT64CONST(0)) {
855  time += USECS_PER_DAY;
856  date -= 1;
857  }
858  date += POSTGRES_EPOCH_JDATE;
859  /* Julian day routine does not work for negative Julian days */
860  if (date < 0 || date > (Timestamp) INT_MAX) {
861  ereport(ERROR,
862  (errcode(ERRCODE_INTERNAL_ERROR),
863  errmsg("Julian day routine does not work for negative Julian days")));
864  }
865 
866  /*
867  * using structure from time.h to store values
868  */
869  struct tm info;
870  fsec_t fsec;
871 
872  /*
873  * calling postgres functions
874  */
875  j2date((int) date, &info.tm_year, &info.tm_mon, &info.tm_mday);
876  dt2time(time, &info.tm_hour, &info.tm_min, &info.tm_sec, &fsec);
877 
878  /*
879  * adjust values before calling mktime
880  */
881  info.tm_isdst = -1;
882  info.tm_year = info.tm_year - 1900;
883  info.tm_mon = info.tm_mon - 1;
884 
885  /*
886  * mktime & timezone are defined in time.h
887  */
888  return mktime(&info) - timezone;
889 }
890 
891 
892 /*
893  * @param[in] colNumber Column number (count starts at 1).
894 
895  * [SPI_ERROR_NOATTRIBUTE](https://doxygen.postgresql.org/spi_8h.html#ac1512d8aaa23c2d57bb0d1eb8f453ee2)
896  * @return @b TRUE when colNumber exist.
897  * @b FALSE when colNumber was not found.
898 */
899 bool
900 column_found(int colNumber) {
901  return !(colNumber == SPI_ERROR_NOATTRIBUTE);
902 }
903 
904 
906  Column_info_t info[],
907  int info_size) {
908  for (int i = 0; i < info_size; ++i) {
909  if (fetch_column_info(&info[i])) {
910  switch (info[i].eType) {
911  case INTEGER:
912  check_integer_type(info[i]);
913  break;
914  case ANY_INTEGER:
915  check_any_integer_type(info[i]);
916  break;
917  case ANY_NUMERICAL:
918  check_any_numerical_type(info[i]);
919  break;
920  case TEXT:
921  check_text_type(info[i]);
922  break;
923  case JSONB:
924  check_jsonb_type(info[i]);
925  break;
926  case CHAR1:
927  check_char_type(info[i]);
928  break;
929  case INTEGER_ARRAY:
930  check_integerarray_type(info[i]);
931  break;
932  case ANY_INTEGER_ARRAY:
934  break;
935  case TIMESTAMP:
936  check_timestamp_type(info[i]);
937  break;
938  case INTERVAL:
939  check_interval_type(info[i]);
940  break;
941  default:
942  elog(ERROR, "Unknown type of column %s", info[i].name);
943  }
944  }
945  }
946 }
spi_getInterval
static TInterval spi_getInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
Definition: get_check_data.c:253
Column_info_t::colNumber
int colNumber
Definition: column_info_t.h:54
fetch_column_info
static bool fetch_column_info(Column_info_t *info)
Definition: get_check_data.c:152
postgres_connection.h
Column_info_t::strict
bool strict
Definition: column_info_t.h:56
TEXT
@ TEXT
Definition: column_info_t.h:42
spi_getBigIntArr
int64_t * spi_getBigIntArr(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
Definition: get_check_data.c:336
get_Distance
Distance get_Distance(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Distance opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:771
get_PositiveTTimestamp_plain
TTimestamp get_PositiveTTimestamp_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:441
get_TTimestamp
TTimestamp get_TTimestamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:457
spi_getText
char * spi_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
under development
Definition: get_check_data.c:832
get_MatrixIndex
MatrixIndex get_MatrixIndex(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, MatrixIndex opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:658
check_interval_type
static void check_interval_type(Column_info_t info)
Definition: get_check_data.c:44
arrays_input.h
check_text_type
static void check_text_type(Column_info_t info)
Definition: get_check_data.c:66
get_Priority
Priority get_Priority(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Priority opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:747
get_Id
Id get_Id(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Id opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:562
spi_getBigIntArr_allowEmpty
int64_t * spi_getBigIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
Definition: get_check_data.c:354
get_TInterval
TInterval get_TInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:492
check_any_integerarray_type
static void check_any_integerarray_type(Column_info_t info)
Definition: get_check_data.c:115
pgr_fetch_column_info
void pgr_fetch_column_info(Column_info_t info[], int info_size)
Function tells expected type of each column and then check the correspondence type of each column.
Definition: get_check_data.c:905
debug_macro.h
get_StepType
StepType get_StepType(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, StepType opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:596
pgr_get_bigIntArray
int64_t * pgr_get_bigIntArray(size_t *arrlen, ArrayType *input)
enforces the input array to be NOT empty
Definition: arrays_input.c:217
pgr_get_bigIntArray_allowEmpty
int64_t * pgr_get_bigIntArray_allowEmpty(size_t *arrlen, ArrayType *input)
Allows the input array to be empty.
Definition: arrays_input.c:223
check_char_type
static void check_char_type(Column_info_t info)
Definition: get_check_data.c:58
get_PositiveTTimestamp
TTimestamp get_PositiveTTimestamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:476
Column_info_t::name
char * name
Definition: column_info_t.h:57
Id
int64_t Id
Definition: typedefs.h:78
typedefs.h
timestamp_without_timezone
TTimestamp timestamp_without_timezone(TTimestamp timestamp)
Steps: 1) Similar to: https://doxygen.postgresql.org/backend_2utils_2adt_2timestamp_8c....
Definition: get_check_data.c:847
PGR_DBG
#define PGR_DBG(...)
Definition: debug_macro.h:34
INTERVAL
@ INTERVAL
Definition: column_info_t.h:48
check_any_integer_type
static void check_any_integer_type(Column_info_t info)
Definition: get_check_data.c:92
JSONB
@ JSONB
Definition: column_info_t.h:43
get_PositiveTInterval
TInterval get_PositiveTInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:511
check_any_numerical_type
static void check_any_numerical_type(Column_info_t info)
Definition: get_check_data.c:127
get_Duration
Duration get_Duration(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Duration opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:681
ANY_INTEGER_ARRAY
@ ANY_INTEGER_ARRAY
Definition: column_info_t.h:46
INTEGER_ARRAY
@ INTEGER_ARRAY
Definition: column_info_t.h:45
spi_getTimeStamp
static TTimestamp spi_getTimeStamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
Definition: get_check_data.c:231
pgr_get_positiveIntArray_allowEmpty
uint32_t * pgr_get_positiveIntArray_allowEmpty(size_t *arrlen, ArrayType *input)
Allows the input array, with non-negative elements to be empty.
Definition: arrays_input.c:228
spi_getChar
char spi_getChar(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, char default_value)
get value of specified column in char type.
Definition: get_check_data.c:298
TravelCost
uint32_t TravelCost
Definition: typedefs.h:82
TTimestamp
int64_t TTimestamp
Definition: typedefs.h:71
Coordinate
double Coordinate
Definition: typedefs.h:73
check_integer_type
static void check_integer_type(Column_info_t info)
Definition: get_check_data.c:82
Amount
int64_t Amount
Definition: typedefs.h:74
get_Kind
char get_Kind(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, char opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:725
Idx
uint64_t Idx
Definition: typedefs.h:79
spi_getCoordinate
Coordinate spi_getCoordinate(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Coordinate opt_value)
get a coordinate value
Definition: get_check_data.c:819
MatrixIndex
int64_t MatrixIndex
Definition: typedefs.h:80
ANY_INTEGER
@ ANY_INTEGER
Definition: column_info_t.h:40
Duration
uint32_t Duration
Definition: typedefs.h:81
spi_getMaxTasks
int32_t spi_getMaxTasks(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
gets the vehicle max tasks value
Definition: get_check_data.c:320
get_PositiveTInterval_plain
TInterval get_PositiveTInterval_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:546
spi_getPositiveBigIntArr_allowEmpty
int64_t * spi_getPositiveBigIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
Definition: get_check_data.c:377
spi_getPositiveIntArr_allowEmpty
uint32_t * spi_getPositiveIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
Definition: get_check_data.c:393
get_Amount
Amount get_Amount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Amount opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:619
check_jsonb_type
static void check_jsonb_type(Column_info_t info)
Definition: get_check_data.c:74
Distance
uint32_t Distance
Definition: typedefs.h:84
PAmount
uint32_t PAmount
Definition: typedefs.h:75
Priority
uint32_t Priority
Definition: typedefs.h:83
TInterval
int64_t TInterval
Definition: typedefs.h:72
get_TInterval_plain
TInterval get_TInterval_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:527
get_PositiveAmount
PAmount get_PositiveAmount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, PAmount opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:638
ANY_NUMERICAL
@ ANY_NUMERICAL
Definition: column_info_t.h:41
get_Idx
Idx get_Idx(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Idx opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:581
column_found
bool column_found(int colNumber)
Check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUTE).
Definition: get_check_data.c:900
get_check_data.h
spi_getBigInt
static int64_t spi_getBigInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
Definition: get_check_data.c:203
spi_getInt
static int32_t spi_getInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
Definition: get_check_data.c:178
Column_info_t::type
uint64_t type
Definition: column_info_t.h:55
TIMESTAMP
@ TIMESTAMP
Definition: column_info_t.h:47
CHAR1
@ CHAR1
Definition: column_info_t.h:44
check_integerarray_type
static void check_integerarray_type(Column_info_t info)
Definition: get_check_data.c:104
Column_info_t
Definition: column_info_t.h:52
INTEGER
@ INTEGER
Definition: column_info_t.h:39
get_TTimestamp_plain
TTimestamp get_TTimestamp_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:422
StepType
int32_t StepType
Definition: typedefs.h:86
check_timestamp_type
static void check_timestamp_type(Column_info_t info)
Definition: get_check_data.c:142
spi_getFloat8
double spi_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
gets value of specified column in double type.
Definition: get_check_data.c:782
get_Cost
TravelCost get_Cost(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TravelCost opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Definition: get_check_data.c:704