Skip to content

Commit da9c341

Browse files
authored
Merge pull request #997 from apsnazii/isssue972
Doxygen documentation of get_check_data
2 parents 56b2873 + 2963031 commit da9c341

File tree

2 files changed

+171
-1
lines changed

2 files changed

+171
-1
lines changed

include/c_common/get_check_data.h

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,186 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2929
#include "c_common/postgres_connection.h"
3030
#include "c_types/column_info_t.h"
3131

32+
/*!
33+
@brief Function will check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUTE).
34+
35+
@param[in] colNumber Column number (count starts at 1).
36+
37+
@return @b TRUE when colNumber exist.
38+
@b FALSE when colNumber was not found.
39+
40+
*/
3241
bool column_found(int colNumber);
3342

43+
/*!
44+
@brief Function tells expected type of each column and then check the correspondence type of each column.
45+
46+
@param[in] info[] contain one or more column information.
47+
@param[in] info_size number of columns.
48+
49+
@throw ERROR Unknown type of column.
50+
51+
@return NULL is always returned.
52+
53+
*/
3454
void pgr_fetch_column_info(
3555
Column_info_t info[],
3656
int info_size);
3757

58+
/*!
59+
@brief The function check whether column type is ANY-INTEGER or not.
60+
Where ANY-INTEGER is SQL type:
61+
SMALLINT, INTEGER, BIGINT
62+
63+
@param[in] info contain column information.
64+
65+
@throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER.
66+
67+
*/
3868
void pgr_check_any_integer_type(Column_info_t info);
69+
70+
/*!
71+
@brief The function check whether column type is ANY-NUMERICAL.
72+
Where ANY-NUMERICAL is SQL type:
73+
SMALLINT, INTEGER, BIGINT, REAL, FLOAT
74+
75+
@param[in] info contain column information.
76+
77+
@throw ERROR Unexpected Column type. Expected column type is ANY-NUMERICAL.
78+
79+
*/
3980
void pgr_check_any_numerical_type(Column_info_t info);
81+
82+
/*!
83+
@brief The function check whether column type is CHAR or not.
84+
Where CHAR is SQL type:
85+
CHARACTER
86+
87+
@param[in] info contain column information.
88+
89+
@throw ERROR Unexpected Column type. Expected column type is CHAR.
90+
91+
*/
4092
void pgr_check_char_type(Column_info_t info);
93+
94+
/*!
95+
@brief The function check whether column type is TEXT or not.
96+
Where TEXT is SQL type:
97+
TEXT
98+
99+
@param[in] info contain column information.
100+
101+
@throw ERROR Unexpected Column type. Expected column type is TEXT.
102+
103+
*/
41104
void pgr_check_text_type(Column_info_t info);
42105
void pgr_check_boolean_type(Column_info_t info);
106+
107+
/*!
108+
@brief The function check whether column type is ANY-INTEGER-ARRAY or not.
109+
Where ANY-INTEGER-ARRAY is SQL type:
110+
SMALLINT[], INTEGER[], BIGINT[]
111+
112+
@param[in] info contain column information.
113+
114+
@throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER-ARRAY.
115+
116+
*/
117+
43118
void pgr_check_any_integerarray_type(Column_info_t info);
44119

120+
/*!
121+
@brief Function return the value of specified column in char type.
122+
123+
@param[in] tuple input row to be examined.
124+
@param[in] tupdesc input row description.
125+
@param[in] info contain column information.
126+
@param[in] strict boolean value of strict.
127+
@param[in] default_value returned when column contain NULL value.
128+
129+
@throw ERROR Unexpected Column type. Expected column type is CHAR.
130+
@throw ERROR When value of column is NULL.
45131
132+
@return Char type of column value is returned.
133+
134+
*/
46135
char pgr_SPI_getChar(
47136
HeapTuple *tuple,
48137
TupleDesc *tupdesc,
49138
Column_info_t info,
50139
bool strict,
51140
char default_value);
52141

142+
/*!
143+
@brief Function returns the values of specified columns in array.
144+
145+
@param[in] tuple input row to be examined.
146+
@param[in] tupdesc input row description.
147+
@param[in] info contain column information.
148+
@param[out] the_size number of element in array.
149+
150+
@throw ERROR No elements found in ARRAY.
151+
@throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER-ARRAY.
152+
@throw ERROR NULL value found in Array.
153+
154+
@return Array of columns value is returned.
155+
156+
*/
157+
53158
int64_t*
54159
pgr_SPI_getBigIntArr(
55160
HeapTuple *tuple,
56161
TupleDesc *tupdesc,
57162
Column_info_t info,
58163
uint64_t *the_size);
59164

165+
/*!
166+
@brief Function returns the value of specified column in integer type.
167+
168+
@param[in] tuple input row to be examined.
169+
@param[in] tupdesc input row description.
170+
@param[in] info contain column information.
171+
172+
@throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER.
173+
@throw ERROR When value of column is NULL.
174+
175+
@return Integer type of column value is returned.
176+
177+
*/
178+
60179
int64_t pgr_SPI_getBigInt(
61180
HeapTuple *tuple,
62181
TupleDesc *tupdesc,
63182
Column_info_t info);
64183

184+
/*!
185+
@brief Function returns the value of specified column in double type.
186+
187+
@param[in] tuple input row to be examined.
188+
@param[in] tupdesc input row description.
189+
@param[in] info contain column information.
190+
191+
@throw ERROR Unexpected Column type. Expected column type is ANY-NUMERICAL.
192+
@throw ERROR When value of column is NULL.
193+
194+
@return Double type of column value is returned.
195+
196+
*/
197+
65198
double pgr_SPI_getFloat8(
66199
HeapTuple *tuple,
67200
TupleDesc *tupdesc,
68201
Column_info_t info);
202+
/*!
203+
@brief Function returns the string representation of the value of specified column.
204+
205+
@param[in] tuple input row to be examined.
206+
@param[in] tupdesc input row description.
207+
@param[in] info contain column information.
208+
209+
@return Pointer of string is returned.
210+
211+
*/
69212

70213
char* pgr_SPI_getText(
71214
HeapTuple *tuple,

src/common/get_check_data.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,37 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3232

3333
bool
3434
column_found(int colNumber) {
35+
/*
36+
* [SPI_ERROR_NOATTRIBUTE](https://doxygen.postgresql.org/spi_8h.html#ac1512d8aaa23c2d57bb0d1eb8f453ee2)
37+
*/
3538
return !(colNumber == SPI_ERROR_NOATTRIBUTE);
3639
}
3740

3841
static
3942
bool
4043
fetch_column_info(
4144
Column_info_t *info) {
45+
/* TODO(vicky) Remove unused code */
4246
#if 0
4347
PGR_DBG("Fetching column info of %s", info->name);
4448
#endif
49+
/*
50+
* [SPI_fnumber](https://www.postgresql.org/docs/8.2/static/spi-spi-fnumber.html)
51+
*/
4552
info->colNumber = SPI_fnumber(SPI_tuptable->tupdesc, info->name);
4653
if (info->strict && !column_found(info->colNumber)) {
4754
elog(ERROR, "Column '%s' not Found", info->name);
4855
}
4956

5057
if (column_found(info->colNumber)) {
58+
/*
59+
* [SPI_gettypeid](https://www.postgresql.org/docs/9.1/static/spi-spi-gettypeid.html)
60+
*/
5161
(info->type) = SPI_gettypeid(SPI_tuptable->tupdesc, (info->colNumber));
5262
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
5363
elog(ERROR, "Type of column '%s' not Found", info->name);
5464
}
65+
/* TODO(vicky) Remove unused code */
5566
#if 0
5667
PGR_DBG("Column %s found: %lu", info->name, info->type);
5768
#endif
@@ -91,7 +102,10 @@ void pgr_fetch_column_info(
91102
}
92103
}
93104

94-
105+
/*
106+
* [BPCHAROID](https://doxygen.postgresql.org/include_2catalog_2pg__type_8h.html#afa7749dbe36d31874205189d9d6b21d7)
107+
* [INT2ARRAYOID](https://doxygen.postgresql.org/include_2catalog_2pg__type_8h.html#ac265fe7b0bb75fead13b16bf072722e9)
108+
*/
95109

96110
void
97111
pgr_check_char_type(Column_info_t info) {
@@ -144,7 +158,11 @@ void pgr_check_any_numerical_type(Column_info_t info) {
144158

145159
/*
146160
* http://doxygen.postgresql.org/include_2catalog_2pg__type_8h.html;
161+
* [SPI_getbinval](https://www.postgresql.org/docs/8.1/static/spi-spi-getbinval.html)
162+
* [Datum](https://doxygen.postgresql.org/datum_8h.html)
163+
* [DatumGetInt16](https://doxygen.postgresql.org/postgres_8h.html#aec991e04209850f29a8a63df0c78ba2d)
147164
*/
165+
148166
char
149167
pgr_SPI_getChar(
150168
HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info,
@@ -180,6 +198,10 @@ pgr_SPI_getBigIntArr(
180198
bool is_null = false;
181199

182200
Datum raw_array = SPI_getbinval(*tuple, *tupdesc, info.colNumber, &is_null);
201+
/*
202+
* [DatumGetArrayTypeP](https://doxygen.postgresql.org/array_8h.html#aa1b8e77c103863862e06a7b7c07ec532)
203+
* [pgr_get_bigIntArray](http://docs.pgrouting.org/doxy/2.2/arrays__input_8c_source.html)
204+
*/
183205
ArrayType *pg_array = DatumGetArrayTypeP(raw_array);
184206

185207
return (int64_t*) pgr_get_bigIntArray(the_size, pg_array);
@@ -210,6 +232,7 @@ pgr_SPI_getBigInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
210232
"Unexpected Column type of %s. Expected ANY-INTEGER",
211233
info.name);
212234
}
235+
/* TODO(vicky) Remove unused code */
213236
#if 0
214237
PGR_DBG("Variable: %s Value: %ld", info.name, value);
215238
#endif
@@ -246,6 +269,7 @@ pgr_SPI_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
246269
"Unexpected Column type of %s. Expected ANY-NUMERICAL",
247270
info.name);
248271
}
272+
/* TODO(vicky) Remove unused code */
249273
#if 0
250274
PGR_DBG("Variable: %s Value: %lf", info.name, value);
251275
#endif
@@ -255,6 +279,9 @@ pgr_SPI_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
255279
/**
256280
* under development
257281
*/
282+
/*
283+
* [DatumGetCString](https://doxygen.postgresql.org/postgres_8h.html#ae401c8476d1a12b420e3061823a206a7)
284+
*/
258285
char*
259286
pgr_SPI_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info) {
260287
return DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber));

0 commit comments

Comments
 (0)