vrpRouting  0.3
get_check_data.h File Reference
Include dependency graph for get_check_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool column_found (int colNumber)
 Check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUTE). More...
 
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. More...
 
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. More...
 
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. More...
 
char spi_getChar (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, char default_value)
 get value of specified column in char type. More...
 
double spi_getFloat8 (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
 gets value of specified column in double type. More...
 
int32_t spi_getMaxTasks (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
 gets the vehicle max tasks value More...
 
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. More...
 
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. More...
 
char * spi_getText (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
 gets string representation of the value of specified column. More...
 
timestamp related
TTimestamp get_PositiveTTimestamp (HeapTuple *, TupleDesc *, Column_info_t, TTimestamp)
 gets a timestamp value from postgres type TIMESTAMP >= 1970-01-01 00:00:00 More...
 
TTimestamp get_PositiveTTimestamp_plain (HeapTuple *, TupleDesc *, Column_info_t, TTimestamp)
 gets a timestamp value from ANY-INTEGER > 0 More...
 
TTimestamp get_TTimestamp (HeapTuple *, TupleDesc *, Column_info_t, TTimestamp)
 gets a timestamp value from postgres type TIMESTAMP More...
 
TTimestamp get_TTimestamp_plain (HeapTuple *, TupleDesc *, Column_info_t, TTimestamp)
 gets a timestamp value from ANY-INTEGER More...
 
TTimestamp timestamp_without_timezone (TTimestamp timestamp)
 Converts timestamp to timestamp without timezone. More...
 
interval related
Amount get_Amount (HeapTuple *, TupleDesc *, Column_info_t, Amount)
 get Amount from data More...
 
TravelCost get_Cost (HeapTuple *, TupleDesc *, Column_info_t, TravelCost)
 get TravelCost from data More...
 
Distance get_Distance (HeapTuple *, TupleDesc *, Column_info_t, Distance)
 get Distance from data More...
 
Duration get_Duration (HeapTuple *, TupleDesc *, Column_info_t, Duration)
 get Duration from data More...
 
Id get_Id (HeapTuple *, TupleDesc *, Column_info_t, Id)
 get Id from data More...
 
Idx get_Idx (HeapTuple *, TupleDesc *, Column_info_t, Idx)
 get Idx from data More...
 
char get_Kind (HeapTuple *, TupleDesc *, Column_info_t, char)
 get Kind from data More...
 
MatrixIndex get_MatrixIndex (HeapTuple *, TupleDesc *, Column_info_t, MatrixIndex)
 get MatrixIndex from data More...
 
PAmount get_PositiveAmount (HeapTuple *, TupleDesc *, Column_info_t, PAmount)
 get positive Amount from data More...
 
TInterval get_PositiveTInterval (HeapTuple *, TupleDesc *, Column_info_t, TInterval)
 gets an interval value from postgres type INTERVAL > 0 More...
 
TInterval get_PositiveTInterval_plain (HeapTuple *, TupleDesc *, Column_info_t, TInterval)
 gets an interval value from ANY-INTEGER > 0 More...
 
Priority get_Priority (HeapTuple *, TupleDesc *, Column_info_t, Priority)
 get Priority from data More...
 
StepType get_StepType (HeapTuple *, TupleDesc *, Column_info_t, StepType)
 get StepType from data More...
 
TInterval get_TInterval (HeapTuple *, TupleDesc *, Column_info_t, TInterval)
 gets an interval value from postgres type INTERVAL More...
 
TInterval get_TInterval_plain (HeapTuple *, TupleDesc *, Column_info_t, TInterval)
 gets an interval value from ANY-INTEGER More...
 
Coordinate spi_getCoordinate (HeapTuple *, TupleDesc *, Column_info_t, Coordinate)
 get a coordinate value More...
 

Function Documentation

◆ column_found()

bool column_found ( int  colNumber)

◆ get_Amount()

Amount get_Amount ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
Amount  opt_value 
)

get Amount from data

get Amount from data

Returns
The value found
opt_value when the column does not exist

Definition at line 619 of file get_check_data.c.

619  {
620  return (Amount) column_found(info.colNumber)?
621  spi_getBigInt(tuple, tupdesc, info)
622  : opt_value;
623 }

References Column_info_t::colNumber, column_found(), and spi_getBigInt().

Referenced by get_PositiveAmount().

◆ get_Cost()

TravelCost get_Cost ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TravelCost  opt_value 
)

get TravelCost from data

get TravelCost from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for non-negative values only

Definition at line 704 of file get_check_data.c.

704  {
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 }

References Column_info_t::colNumber, column_found(), Column_info_t::name, and spi_getInt().

Referenced by fetch_matrix().

◆ get_Distance()

Distance get_Distance ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
Distance  opt_value 
)

get Distance from data

get Distance from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for non-negative values only

Definition at line 771 of file get_check_data.c.

771  {
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 }

References Column_info_t::colNumber, column_found(), Column_info_t::name, and spi_getInt().

◆ get_Duration()

Duration get_Duration ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
Duration  opt_value 
)

get Duration from data

get Duration from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for non-negative values only

Definition at line 681 of file get_check_data.c.

681  {
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 }

References Column_info_t::colNumber, column_found(), Column_info_t::name, and spi_getInt().

Referenced by fetch_breaks(), fetch_jobs(), fetch_matrix(), fetch_shipments(), fetch_time_windows(), and fetch_vehicles().

◆ get_Id()

Id get_Id ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
Id  opt_value 
)

get Id from data

get Id from data

Returns
The value found
opt_value when the column does not exist

Definition at line 562 of file get_check_data.c.

562  {
563  return column_found(info.colNumber)?
564  (Id)spi_getBigInt(tuple, tupdesc, info)
565  : opt_value;
566 }

References Column_info_t::colNumber, column_found(), and spi_getBigInt().

Referenced by fetch_euclidean(), fetch_plain(), fetch_raw(), fetch_timestamps(), and get_Idx().

◆ get_Idx()

Idx get_Idx ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
Idx  opt_value 
)

get Idx from data

get Idx from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is not positive

Precondition
for positive values only

Definition at line 581 of file get_check_data.c.

581  {
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 }

References Column_info_t::colNumber, column_found(), get_Id(), and Column_info_t::name.

Referenced by fetch_breaks(), fetch_jobs(), fetch_shipments(), fetch_time_windows(), and fetch_vehicles().

◆ get_Kind()

char get_Kind ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
char  opt_value 
)

get Kind from data

get Kind from data

Returns
The value found
opt_value when the column does not exist

Definition at line 725 of file get_check_data.c.

725  {
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 }

References Column_info_t::colNumber, column_found(), and spi_getChar().

Referenced by fetch_time_windows().

◆ get_MatrixIndex()

MatrixIndex get_MatrixIndex ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
MatrixIndex  opt_value 
)

get MatrixIndex from data

get MatrixIndex from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is not positive

Precondition
for positive values only

Definition at line 658 of file get_check_data.c.

658  {
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 }

References Column_info_t::colNumber, column_found(), Column_info_t::name, and spi_getBigInt().

Referenced by fetch_jobs(), fetch_matrix(), fetch_shipments(), and fetch_vehicles().

◆ get_PositiveAmount()

PAmount get_PositiveAmount ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
PAmount  opt_value 
)

get positive Amount from data

get positive Amount from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for non-negative values only

Definition at line 638 of file get_check_data.c.

638  {
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 }

References Column_info_t::colNumber, column_found(), get_Amount(), and Column_info_t::name.

Referenced by fetch_euclidean(), fetch_raw(), and fetch_timestamps().

◆ get_PositiveTInterval()

TInterval get_PositiveTInterval ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TInterval  opt_value 
)

gets an interval value from postgres type INTERVAL > 0

gets an interval value from postgres type INTERVAL > 0

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for positive values only

Definition at line 511 of file get_check_data.c.

511  {
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 }

References get_TInterval(), and Column_info_t::name.

Referenced by fetch_breaks(), fetch_jobs(), fetch_matrix(), fetch_shipments(), and fetch_timestamps().

◆ get_PositiveTInterval_plain()

TInterval get_PositiveTInterval_plain ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TInterval  opt_value 
)

gets an interval value from ANY-INTEGER > 0

gets an interval value from ANY-INTEGER > 0

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for positive values only

Definition at line 546 of file get_check_data.c.

546  {
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 }

References get_TInterval_plain(), and Column_info_t::name.

Referenced by fetch_euclidean(), fetch_plain(), and fetch_raw().

◆ get_PositiveTTimestamp()

TTimestamp get_PositiveTTimestamp ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TTimestamp  opt_value 
)

gets a timestamp value from postgres type TIMESTAMP >= 1970-01-01 00:00:00

gets a timestamp value from postgres type TIMESTAMP >= 1970-01-01 00:00:00

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for positive values only

Definition at line 476 of file get_check_data.c.

476  {
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 }

References get_TTimestamp(), and Column_info_t::name.

Referenced by fetch_time_windows(), and fetch_vehicles().

◆ get_PositiveTTimestamp_plain()

TTimestamp get_PositiveTTimestamp_plain ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TTimestamp  opt_value 
)

gets a timestamp value from ANY-INTEGER > 0

gets a timestamp value from ANY-INTEGER > 0

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for positive values only

Definition at line 441 of file get_check_data.c.

441  {
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 }

References get_TTimestamp_plain(), and Column_info_t::name.

◆ get_Priority()

Priority get_Priority ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
Priority  opt_value 
)

get Priority from data

get Priority from data

Returns
The value found
opt_value when the column does not exist

exceptions when the value is negative

Precondition
for non-negative values only

Definition at line 747 of file get_check_data.c.

747  {
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 }

References Column_info_t::colNumber, column_found(), Column_info_t::name, and spi_getInt().

Referenced by fetch_jobs(), and fetch_shipments().

◆ get_StepType()

StepType get_StepType ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
StepType  opt_value 
)

get StepType from data

get StepType from data

Returns
The value found
opt_value when the column does not exist

Definition at line 596 of file get_check_data.c.

597  {
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 }

References Column_info_t::colNumber, column_found(), and spi_getInt().

◆ get_TInterval()

TInterval get_TInterval ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TInterval  opt_value 
)

gets an interval value from postgres type INTERVAL

gets an interval value from postgres type INTERVAL

Returns
The value found
opt_value when the column does not exist

Definition at line 492 of file get_check_data.c.

492  {
493  return column_found(info.colNumber)?
494  (TInterval)spi_getInterval(tuple, tupdesc, info)
495  : opt_value;
496 }

References Column_info_t::colNumber, column_found(), and spi_getInterval().

Referenced by fetch_timestamps(), and get_PositiveTInterval().

◆ get_TInterval_plain()

TInterval get_TInterval_plain ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TInterval  opt_value 
)

gets an interval value from ANY-INTEGER

gets an interval value from ANY-INTEGER

Returns
The value found
opt_value when the column does not exist

Definition at line 527 of file get_check_data.c.

527  {
528  return column_found(info.colNumber)?
529  (TInterval)spi_getBigInt(tuple, tupdesc, info)
530  : opt_value;
531 }

References Column_info_t::colNumber, column_found(), and spi_getBigInt().

Referenced by fetch_euclidean(), fetch_raw(), and get_PositiveTInterval_plain().

◆ get_TTimestamp()

TTimestamp get_TTimestamp ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TTimestamp  opt_value 
)

gets a timestamp value from postgres type TIMESTAMP

gets a timestamp value from postgres type TIMESTAMP

Returns
The value found
opt_value when the column does not exist

Definition at line 457 of file get_check_data.c.

457  {
458  return column_found(info.colNumber)?
459  spi_getTimeStamp(tuple, tupdesc, info)
460  : opt_value;
461 }

References Column_info_t::colNumber, column_found(), and spi_getTimeStamp().

Referenced by fetch_timestamps(), and get_PositiveTTimestamp().

◆ get_TTimestamp_plain()

TTimestamp get_TTimestamp_plain ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
TTimestamp  opt_value 
)

gets a timestamp value from ANY-INTEGER

gets a timestamp value from ANY-INTEGER

Returns
The value found
opt_value when the column does not exist

Definition at line 422 of file get_check_data.c.

422  {
423  return column_found(info.colNumber)?
424  (TTimestamp)spi_getBigInt(tuple, tupdesc, info)
425  : opt_value;
426 }

References Column_info_t::colNumber, column_found(), and spi_getBigInt().

Referenced by fetch_euclidean(), fetch_raw(), and get_PositiveTTimestamp_plain().

◆ 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 at line 905 of file get_check_data.c.

907  {
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 }

References ANY_INTEGER, ANY_INTEGER_ARRAY, ANY_NUMERICAL, CHAR1, check_any_integer_type(), check_any_integerarray_type(), check_any_numerical_type(), check_char_type(), check_integer_type(), check_integerarray_type(), check_interval_type(), check_jsonb_type(), check_text_type(), check_timestamp_type(), fetch_column_info(), INTEGER, INTEGER_ARRAY, INTERVAL, JSONB, TEXT, and TIMESTAMP.

Referenced by db_get_breaks(), db_get_jobs(), db_get_matrix(), db_get_shipments(), db_get_time_windows(), db_get_vehicles(), get_matrixRows_general(), get_timeMultipliersGeneral(), and pgr_get_pd_orders_general().

◆ 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 at line 336 of file get_check_data.c.

340  {
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 }

References Column_info_t::colNumber, and pgr_get_bigIntArray().

◆ 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 at line 354 of file get_check_data.c.

358  {
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 }

References Column_info_t::colNumber, and pgr_get_bigIntArray_allowEmpty().

Referenced by fetch_euclidean(), fetch_raw(), fetch_timestamps(), and spi_getPositiveBigIntArr_allowEmpty().

◆ 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 at line 298 of file get_check_data.c.

299  {
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 }

References Column_info_t::colNumber, Column_info_t::name, Column_info_t::strict, and Column_info_t::type.

Referenced by get_Kind().

◆ spi_getCoordinate()

Coordinate spi_getCoordinate ( HeapTuple *  ,
TupleDesc *  ,
Column_info_t  ,
Coordinate   
)

get a coordinate value

Definition at line 819 of file get_check_data.c.

819  {
820  return column_found(info.colNumber)?
821  (Coordinate) spi_getFloat8(tuple, tupdesc, info)
822  : opt_value;
823 }

References Column_info_t::colNumber, column_found(), and spi_getFloat8().

Referenced by fetch_euclidean().

◆ spi_getFloat8()

double spi_getFloat8 ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info 
)

gets value of specified column in double type.

Definition at line 782 of file get_check_data.c.

782  {
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 }

References Column_info_t::colNumber, Column_info_t::name, and Column_info_t::type.

Referenced by fetch_euclidean(), fetch_raw(), fetch_timestamps(), fetch_vehicles(), and spi_getCoordinate().

◆ spi_getMaxTasks()

int32_t spi_getMaxTasks ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info 
)

gets the vehicle max tasks value

Definition at line 320 of file get_check_data.c.

323  {
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 }

References spi_getInt().

Referenced by fetch_vehicles().

◆ 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 at line 377 of file get_check_data.c.

381  {
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 }

References spi_getBigIntArr_allowEmpty().

Referenced by fetch_jobs(), fetch_shipments(), and fetch_vehicles().

◆ 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 at line 393 of file get_check_data.c.

397  {
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 }

References Column_info_t::colNumber, and pgr_get_positiveIntArray_allowEmpty().

Referenced by fetch_jobs(), fetch_shipments(), and fetch_vehicles().

◆ spi_getText()

char* spi_getText ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info 
)

gets string representation of the value of specified column.

gets string representation of the value of specified column.

Definition at line 832 of file get_check_data.c.

832  {
833  char *val = DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber));
834  return val;
835 }

References Column_info_t::colNumber.

Referenced by fetch_breaks(), fetch_jobs(), fetch_shipments(), and fetch_vehicles().

◆ timestamp_without_timezone()

TTimestamp timestamp_without_timezone ( TTimestamp  timestamp)

Converts timestamp to timestamp without timezone.

Converts timestamp to timestamp without timezone.

from time.h struct tm timezone

Definition at line 847 of file get_check_data.c.

847  {
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 }

Referenced by process(), and spi_getTimeStamp().

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
Column_info_t::strict
bool strict
Definition: column_info_t.h:56
TEXT
@ TEXT
Definition: column_info_t.h:42
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
check_interval_type
static void check_interval_type(Column_info_t info)
Definition: get_check_data.c:44
check_text_type
static void check_text_type(Column_info_t info)
Definition: get_check_data.c:66
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_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
Column_info_t::name
char * name
Definition: column_info_t.h:57
Id
int64_t Id
Definition: typedefs.h:78
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
check_any_numerical_type
static void check_any_numerical_type(Column_info_t info)
Definition: get_check_data.c:127
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
Idx
uint64_t Idx
Definition: typedefs.h:79
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
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
PAmount
uint32_t PAmount
Definition: typedefs.h:75
Distance
uint32_t Distance
Definition: typedefs.h:84
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
ANY_NUMERICAL
@ ANY_NUMERICAL
Definition: column_info_t.h:41
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
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
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