1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
/*PGR-GNU*****************************************************************
File: get_check_data.h
Copyright (c) 2015 Celia Virginia Vergara Castillo
vicky_vergara@hotmail.com
------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
#ifndef INCLUDE_C_COMMON_GET_CHECK_DATA_H_
#define INCLUDE_C_COMMON_GET_CHECK_DATA_H_
#pragma once
#include "c_common/postgres_connection.h"
typedef struct Column_info_t Column_info_t;
/*!
* @brief Function will check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUTE).
*
* @param[in] colNumber Column number (count starts at 1).
*
* @return @b TRUE when colNumber exist.
* @b FALSE when colNumber was not found.
*
*/
bool column_found(int colNumber);
/*!
* @brief Function tells expected type of each column and then check the correspondence type of each column.
*
* @throw ERROR Unknown type of column.
*/
void pgr_fetch_column_info(
Column_info_t info[],
int info_size);
/*!
* @brief The function check whether column type is ANY-INTEGER or not.
* Where ANY-INTEGER is SQL type:
* SMALLINT, INTEGER, BIGINT
*
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER.
*
*/
void pgr_check_any_integer_type(Column_info_t info);
/*!
* @brief The function check whether column type is ANY-NUMERICAL.
* Where ANY-NUMERICAL is SQL type:
* SMALLINT, INTEGER, BIGINT, REAL, FLOAT
*
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected column type is ANY-NUMERICAL.
*
*/
void pgr_check_any_numerical_type(Column_info_t info);
/*!
* @brief The function check whether column type is CHAR or not.
* Where CHAR is SQL type:
* CHARACTER
*
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected column type is CHAR.
*
*/
void pgr_check_char_type(Column_info_t info);
/*!
* @brief The function check whether column type is TEXT or not.
* Where TEXT is SQL type:
* TEXT
*
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected column type is TEXT.
*
*/
void pgr_check_text_type(Column_info_t info);
void pgr_check_boolean_type(Column_info_t info);
/*!
* @brief The function check whether column type is ANY-INTEGER-ARRAY or not.
* Where ANY-INTEGER-ARRAY is SQL type:
* SMALLINT[], INTEGER[], BIGINT[]
*
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected ANY-INTEGER-ARRAY.
*
*/
void pgr_check_any_integerarray_type(Column_info_t info);
/*!
* @brief Function return the value of specified column in char type.
*
* @param[in] tuple input row to be examined.
* @param[in] tupdesc input row description.
* @param[in] info contain column information.
* @param[in] strict boolean value of strict.
* @param[in] default_value returned when column contain NULL value.
*
* @throw ERROR Unexpected Column type. Expected column type is CHAR.
* @throw ERROR When value of column is NULL.
*
* @return Char type of column value is returned.
*
*/
char pgr_SPI_getChar(
HeapTuple *tuple,
TupleDesc *tupdesc,
Column_info_t info,
bool strict,
char default_value);
/*!
* @brief Function returns the values of specified columns in array.
*
* @param[in] tuple input row to be examined.
* @param[in] tupdesc input row description.
* @param[in] info contain column information.
* @param[out] the_size number of element in array.
*
* @throw ERROR No elements found in ARRAY.
* @throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER-ARRAY.
* @throw ERROR NULL value found in Array.
*
* @return Array of columns value is returned.
*
*/
int64_t*
pgr_SPI_getBigIntArr(
HeapTuple *tuple,
TupleDesc *tupdesc,
Column_info_t info,
uint64_t *the_size);
/*!
* @brief Function returns the value of specified column in integer type.
*
* @param[in] tuple input row to be examined.
* @param[in] tupdesc input row description.
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected column type is ANY-INTEGER.
* @throw ERROR When value of column is NULL.
*
* @return Integer type of column value is returned.
*
*/
int64_t pgr_SPI_getBigInt(
HeapTuple *tuple,
TupleDesc *tupdesc,
Column_info_t info);
/*!
* @brief Function returns the value of specified column in double type.
*
* @param[in] tuple input row to be examined.
* @param[in] tupdesc input row description.
* @param[in] info contain column information.
*
* @throw ERROR Unexpected Column type. Expected column type is ANY-NUMERICAL.
* @throw ERROR When value of column is NULL.
*
* @return Double type of column value is returned.
*
*/
double pgr_SPI_getFloat8(
HeapTuple *tuple,
TupleDesc *tupdesc,
Column_info_t info);
/*!
* @brief Function returns the string representation of the value of specified column.
*
* @return Pointer of string is returned.
*
*/
char* pgr_SPI_getText(
HeapTuple *tuple,
TupleDesc *tupdesc,
Column_info_t info);
#endif // INCLUDE_C_COMMON_GET_CHECK_DATA_H_
|