MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / db_postgres_convert_row

Function db_postgres_convert_row

modules/db_postgres/res.c:320–351  ·  view source on GitHub ↗

* Convert a row from the result query into db API representation */

Source from the content-addressed store, hash-verified

318 * Convert a row from the result query into db API representation
319 */
320int db_postgres_convert_row(const db_con_t* _h, db_res_t* _r, db_row_t* _row,
321 char **row_buf)
322{
323 int col, len;
324
325 if (!_h || !_r || !_row) {
326 LM_ERR("invalid parameter value\n");
327 return -1;
328 }
329
330 /* Save the number of columns in the ROW structure */
331 ROW_N(_row) = RES_COL_N(_r);
332
333 /* For each column in the row */
334 for(col = 0; col < ROW_N(_row); col++) {
335 /* compute the len of the value */
336 if ( row_buf[col]==NULL || row_buf[col][0]=='\0')
337 len = 0;
338 else
339 len = strlen(row_buf[col]);
340
341 /* Convert the string representation into the value representation */
342 if (db_postgres_str2val(RES_TYPES(_r)[col], &(ROW_VALUES(_row)[col]),
343 row_buf[col], len) < 0) {
344 LM_ERR("failed to convert value\n");
345 LM_DBG("free row at %pn", _row);
346 db_free_row(_row);
347 return -3;
348 }
349 }
350 return 0;
351}

Callers 1

db_postgres_convert_rowsFunction · 0.85

Calls 2

db_postgres_str2valFunction · 0.85
db_free_rowFunction · 0.85

Tested by

no test coverage detected