MCPcopy Create free account
hub / github.com/apache/cloudberry / ecpg_get_data

Function ecpg_get_data

src/interfaces/ecpg/ecpglib/data.c:205–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205bool
206ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
207 enum ECPGttype type, enum ECPGttype ind_type,
208 char *var, char *ind, long varcharsize, long offset,
209 long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
210{
211 struct sqlca_t *sqlca = ECPGget_sqlca();
212 char *pval = (char *) PQgetvalue(results, act_tuple, act_field);
213 int binary = PQfformat(results, act_field);
214 int size = PQgetlength(results, act_tuple, act_field);
215 int value_for_indicator = 0;
216 long log_offset;
217
218 if (sqlca == NULL)
219 {
220 ecpg_raise(lineno, ECPG_OUT_OF_MEMORY,
221 ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
222 return false;
223 }
224
225 /*
226 * If we are running in a regression test, do not log the offset variable,
227 * it depends on the machine's alignment.
228 */
229 if (ecpg_internal_regression_mode)
230 log_offset = -1;
231 else
232 log_offset = offset;
233
234 ecpg_log("ecpg_get_data on line %d: RESULT: %s offset: %ld; array: %s\n", lineno, pval ? (binary ? "BINARY" : pval) : "EMPTY", log_offset, ECPG_IS_ARRAY(isarray) ? "yes" : "no");
235
236 /* pval is a pointer to the value */
237 if (!pval)
238 {
239 /*
240 * This should never happen because we already checked that we found
241 * at least one tuple, but let's play it safe.
242 */
243 ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
244 return false;
245 }
246
247 /* We will have to decode the value */
248
249 /*
250 * check for null value and set indicator accordingly, i.e. -1 if NULL and
251 * 0 if not
252 */
253 if (PQgetisnull(results, act_tuple, act_field))
254 value_for_indicator = -1;
255
256 switch (ind_type)
257 {
258 case ECPGt_short:
259 case ECPGt_unsigned_short:
260 *((short *) (ind + ind_offset * act_tuple)) = value_for_indicator;
261 break;
262 case ECPGt_int:

Callers 3

ecpg_set_compat_sqldaFunction · 0.85
ecpg_set_native_sqldaFunction · 0.85
ecpg_store_resultFunction · 0.85

Calls 15

ECPGget_sqlcaFunction · 0.85
PQgetvalueFunction · 0.85
PQfformatFunction · 0.85
PQgetlengthFunction · 0.85
ecpg_raiseFunction · 0.85
ecpg_logFunction · 0.85
PQgetisnullFunction · 0.85
ECPGset_noind_nullFunction · 0.85
ecpg_type_nameFunction · 0.85
garbage_leftFunction · 0.85
check_special_valueFunction · 0.85
ecpg_hex_enc_lenFunction · 0.85

Tested by

no test coverage detected