PGROUTING  2.5
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)
 
void pgr_check_any_integer_type (Column_info_t info)
 
void pgr_check_any_integerarray_type (Column_info_t info)
 
void pgr_check_any_numerical_type (Column_info_t info)
 
void pgr_check_boolean_type (Column_info_t info)
 
void pgr_check_char_type (Column_info_t info)
 
void pgr_check_text_type (Column_info_t info)
 
void pgr_fetch_column_info (Column_info_t info[], int info_size)
 
int64_t pgr_SPI_getBigInt (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
 
char pgr_SPI_getChar (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, bool strict, char default_value)
 
double pgr_SPI_getFloat8 (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
 
char * pgr_SPI_getText (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
 under development More...
 
char * pgr_stradd (const char *a, const char *b)
 

Function Documentation

bool column_found ( int  colNumber)

Definition at line 40 of file get_check_data.c.

Referenced by fetch_basic_edge(), fetch_column_info(), fetch_edge(), fetch_edge_with_xy(), fetch_pd_orders(), fetch_point(), fetch_vehicles(), and pgr_fetch_row().

40  {
41  return !(colNumber == SPI_ERROR_NOATTRIBUTE);
42 }

Here is the caller graph for this function:

void pgr_check_any_integer_type ( Column_info_t  info)

Definition at line 115 of file get_check_data.c.

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

Referenced by pgr_fetch_column_info().

115  {
116  if (!(info.type == INT2OID
117  || info.type == INT4OID
118  || info.type == INT8OID)) {
119  elog(ERROR,
120  "Unexpected Column '%s' type. Expected ANY-INTEGER",
121  info.name);
122  }
123 }
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

void pgr_check_any_integerarray_type ( Column_info_t  info)

Definition at line 126 of file get_check_data.c.

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

Referenced by pgr_fetch_column_info().

126  {
127  if (!(info.type == INT2ARRAYOID
128  || info.type == INT4ARRAYOID
129  || info.type == 1016)) {
130  elog(ERROR,
131  "Unexpected Column '%s' type. Expected ANY-INTEGER-ARRAY",
132  info.name);
133  }
134 }
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

void pgr_check_any_numerical_type ( Column_info_t  info)

Definition at line 136 of file get_check_data.c.

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

Referenced by pgr_fetch_column_info().

136  {
137  if (!(info.type == INT2OID
138  || info.type == INT4OID
139  || info.type == INT8OID
140  || info.type == FLOAT4OID
141  || info.type == FLOAT8OID)) {
142  elog(ERROR,
143  "Unexpected Column '%s' type. Expected ANY-NUMERICAL",
144  info.name);
145  }
146 }
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

void pgr_check_boolean_type ( Column_info_t  info)
void pgr_check_char_type ( Column_info_t  info)

Definition at line 101 of file get_check_data.c.

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

Referenced by pgr_fetch_column_info().

101  {
102  if (!(info.type == BPCHAROID)) {
103  elog(ERROR, "Unexpected Column '%s' type. Expected CHAR", info.name);
104  }
105 }
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

void pgr_check_text_type ( Column_info_t  info)

Definition at line 108 of file get_check_data.c.

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

Referenced by pgr_fetch_column_info().

108  {
109  if (!(info.type == TEXTOID)) {
110  elog(ERROR, "Unexpected Column '%s' type. Expected TEXT", info.name);
111  }
112 }
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

void pgr_fetch_column_info ( Column_info_t  info[],
int  info_size 
)

Definition at line 70 of file get_check_data.c.

References ANY_INTEGER, ANY_INTEGER_ARRAY, ANY_NUMERICAL, CHAR1, fetch_column_info(), pgr_check_any_integer_type(), pgr_check_any_integerarray_type(), pgr_check_any_numerical_type(), pgr_check_char_type(), pgr_check_text_type(), and TEXT.

Referenced by get_edges_5_columns(), get_edges_9_columns(), get_edges_basic(), get_edges_flow(), pgr_get_coordinates(), pgr_get_matrixRows(), pgr_get_pd_orders_general(), pgr_get_points(), pgr_get_restriction_data(), and pgr_get_vehicles_general().

72  {
73  int i;
74  for (i = 0; i < info_size; ++i) {
75  if (fetch_column_info(&info[i])) {
76  switch (info[i].eType) {
77  case ANY_INTEGER:
79  break;
80  case ANY_NUMERICAL:
82  break;
83  case TEXT:
84  pgr_check_text_type(info[i]);
85  break;
86  case CHAR1:
87  pgr_check_char_type(info[i]);
88  break;
89  case ANY_INTEGER_ARRAY:
91  break;
92  default:
93  elog(ERROR, "Unknown type of column %s", info[i].name);
94  }
95  }
96  }
97 }
void pgr_check_text_type(Column_info_t info)
void pgr_check_any_numerical_type(Column_info_t info)
void pgr_check_any_integer_type(Column_info_t info)
void pgr_check_char_type(Column_info_t info)
static bool fetch_column_info(Column_info_t *info)
void pgr_check_any_integerarray_type(Column_info_t info)

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t pgr_SPI_getBigInt ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info 
)

Definition at line 176 of file get_check_data.c.

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

Referenced by fetch_basic_edge(), fetch_edge(), fetch_edge_with_xy(), fetch_pd_orders(), fetch_point(), fetch_restriction(), fetch_vehicles(), and pgr_fetch_row().

176  {
177  Datum binval;
178  bool isnull;
179  int64_t value = 0;
180  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
181  if (isnull)
182  elog(ERROR, "Unexpected Null value in column %s", info.name);
183  switch (info.type) {
184  case INT2OID:
185  value = (int64_t) DatumGetInt16(binval);
186  break;
187  case INT4OID:
188  value = (int64_t) DatumGetInt32(binval);
189  break;
190  case INT8OID:
191  value = DatumGetInt64(binval);
192  break;
193  default:
194  elog(ERROR,
195  "Unexpected Column type of %s. Expected ANY-INTEGER",
196  info.name);
197  }
198 #if 0
199  PGR_DBG("Variable: %s Value: %ld", info.name, value);
200 #endif
201  return value;
202 }
#define PGR_DBG(...)
Definition: debug_macro.h:34
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

char pgr_SPI_getChar ( HeapTuple *  tuple,
TupleDesc *  tupdesc,
Column_info_t  info,
bool  strict,
char  default_value 
)

Definition at line 153 of file get_check_data.c.

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

Referenced by fetch_point().

155  {
156  Datum binval;
157  bool isNull;
158  char value = default_value;
159 
160  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isNull);
161  if (!(info.type == BPCHAROID)) {
162  elog(ERROR, "Unexpected Column type of %s. Expected CHAR", info.name);
163  }
164  if (!isNull) {
165  value = ((char*)binval)[1];
166  } else {
167  if (strict) {
168  elog(ERROR, "Unexpected Null value in column %s", info.name);
169  }
170  value = default_value;
171  }
172  return value;
173 }
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

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

Definition at line 205 of file get_check_data.c.

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

Referenced by fetch_basic_edge(), fetch_edge(), fetch_edge_with_xy(), fetch_pd_orders(), fetch_point(), fetch_restriction(), fetch_vehicles(), and pgr_fetch_row().

205  {
206  Datum binval;
207  bool isnull = false;
208  double value = 0.0;
209  binval = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &isnull);
210  if (isnull)
211  elog(ERROR, "Unexpected Null value in column %s", info.name);
212 
213  switch (info.type) {
214  case INT2OID:
215  value = (double) DatumGetInt16(binval);
216  break;
217  case INT4OID:
218  value = (double) DatumGetInt32(binval);
219  break;
220  case INT8OID:
221  value = (double) DatumGetInt64(binval);
222  break;
223  case FLOAT4OID:
224  value = (double) DatumGetFloat4(binval);
225  break;
226  case FLOAT8OID:
227  value = DatumGetFloat8(binval);
228  break;
229  default:
230  elog(ERROR,
231  "Unexpected Column type of %s. Expected ANY-NUMERICAL",
232  info.name);
233  }
234 #if 0
235  PGR_DBG("Variable: %s Value: %lf", info.name, value);
236 #endif
237  return value;
238 }
#define PGR_DBG(...)
Definition: debug_macro.h:34
uint64_t type
Definition: column_info_t.h:77

Here is the caller graph for this function:

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

under development

Definition at line 244 of file get_check_data.c.

References Column_info_t::colNumber.

244  {
245  return DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber));
246 }
char* pgr_stradd ( const char *  a,
const char *  b 
)

Definition at line 32 of file get_check_data.c.

32  {
33  size_t len = strlen(a) + strlen(b);
34  char *ret = (char*)malloc(len * sizeof(char) + 1);
35  *ret = '\0';
36  return strcat(strcat(ret, a), b);
37 }