rem: if(begin_transaction(_h, sql_buf)) return(-1); if (submit_query(_h, sql_buf) < 0) { LOG(L_ERR, "db_update(): Error while updating\n"); return -2; } free_query(_h); commit_transaction(_h); return(0);
add: params = 0; update = 0;  update = print_update(con, ucols, keys, ops, un, n); if (!update) goto err;  params = new_pg_params(n + un); if (!params) goto err; if (params_add(params, con, uvals, un) < 0) goto err; if (params_add(params, con, vals, n) < 0) goto err;  do { ret = submit_query(0, con, update, params); if (ret < 0) goto err;                        if (ret > 0) {                                if (reconnect(con) < 0) goto err;     else continue;                        } } while(ret != 0);  free_pg_params(params); pkg_free(update); return 0;  err: if (params) free_pg_params(params); if (update) pkg_free(update); return -1;
context: int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,	      db_key_t* _uk, db_val_t* _uv, int _n, int _un){	int off;	off = snprintf(sql_buf, SQL_BUF_LEN, "update %s set ", CON_TABLE(_h));	off += print_set(sql_buf + off, SQL_BUF_LEN - off, _uk, _uv, _un);	if (_n) {		off += snprintf(sql_buf + off, SQL_BUF_LEN - off, " where ");		off += print_where(sql_buf + off, SQL_BUF_LEN - off, _k,			_o, _v, _n);		*(sql_buf + off) = '\0';	}	if(begin_transaction(_h, sql_buf)) return(-1);	if (submit_query(_h, sql_buf) < 0) {		LOG(L_ERR, "db_update(): Error while updating\n");		return -2;	}	free_query(_h);	commit_transaction(_h);	return(0);}