}\
sql_set_last_error_printf(conn, "Failed to retrieve " _t " data at column %s (%d): %s", \
_col_name, i, cass_error_desc(_ret));\
- TALLOC_FREE(handle->row);\
+ TALLOC_FREE(query_ctx->row);\
query_ctx->rcode = RLM_SQL_ERROR;\
RETURN_MODULE_FAIL;\
} while(0)
/*
* Free the previous result (also gets called on finish_query)
*/
- talloc_free(handle->row);
- MEM(row = handle->row = talloc_zero_array(handle, char *, fields + 1));
+ talloc_free(query_ctx->row);
+ MEM(row = query_ctx->row = talloc_zero_array(query_ctx, char *, fields + 1));
for (i = 0; i < fields; i++) {
CassValue const *value;
sql_set_last_error_printf(conn,
"Failed to retrieve data at column %s (%d): Unsupported data type",
col_name, i);
- talloc_free(handle->row);
+ talloc_free(query_ctx->row);
query_ctx->rcode = RLM_SQL_ERROR;
RETURN_MODULE_FAIL;
}
{
rlm_sql_cassandra_conn_t *conn = query_ctx->handle->conn;
- if (query_ctx->handle->row) TALLOC_FREE(query_ctx->handle->row);
+ if (query_ctx->row) TALLOC_FREE(query_ctx->row);
if (conn->iterator) {
cass_iterator_free(conn->iterator);
rlm_sql_db2_conn_t *conn;
rlm_sql_handle_t *handle = query_ctx->handle;
- TALLOC_FREE(handle->row);
+ TALLOC_FREE(query_ctx->row);
conn = handle->conn;
c = sql_num_fields(handle, config);
RETURN_MODULE_OK;
}
- MEM(row = (rlm_sql_row_t)talloc_zero_array(handle, char *, c + 1));
+ MEM(row = (rlm_sql_row_t)talloc_zero_array(query_ctx, char *, c + 1));
for (i = 0; i < c; i++) {
/* get column length */
SQLColAttribute(conn->stmt, i + 1, SQL_DESC_DISPLAY_SIZE, NULL, 0, NULL, &len);
if (slen == SQL_NULL_DATA) row[i][0] = '\0';
}
- handle->row = row;
+ query_ctx->row = row;
query_ctx->rcode = RLM_SQL_OK;
RETURN_MODULE_OK;
rlm_sql_db2_conn_t *conn;
conn = query_ctx->handle->conn;
- TALLOC_FREE(query_ctx->handle->row);
+ TALLOC_FREE(query_ctx->row);
SQLFreeHandle(SQL_HANDLE_STMT, conn->stmt);
return RLM_SQL_OK;
rlm_sql_firebird_conn_t *conn = handle->conn;
int res;
- handle->row = NULL;
+ query_ctx->row = NULL;
if (conn->statement_type != isc_info_sql_stmt_exec_procedure) {
res = fb_fetch(conn);
fb_store_row(conn);
- handle->row = conn->row;
+ query_ctx->row = conn->row;
query_ctx->rcode = RLM_SQL_OK;
RETURN_MODULE_OK;
rlm_sql_freetds_conn_t *conn = handle->conn;
CS_INT ret, count;
- handle->row = NULL;
+ query_ctx->row = NULL;
ret = ct_fetch(conn->command, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count);
switch (ret) {
RETURN_MODULE_OK;
case CS_SUCCEED:
- handle->row = conn->results;
+ query_ctx->row = conn->results;
query_ctx->rcode = RLM_SQL_OK;
RETURN_MODULE_OK;
RETURN_MODULE_FAIL;
}
- TALLOC_FREE(handle->row); /* Clear previous row set */
+ TALLOC_FREE(query_ctx->row); /* Clear previous row set */
retry_fetch_row:
row = mysql_fetch_row(conn->result);
field_lens = mysql_fetch_lengths(conn->result);
- MEM(handle->row = talloc_zero_array(handle, char *, num_fields + 1));
+ MEM(query_ctx->row = talloc_zero_array(query_ctx, char *, num_fields + 1));
for (i = 0; i < num_fields; i++) {
- MEM(handle->row[i] = talloc_bstrndup(handle->row, row[i], field_lens[i]));
+ MEM(query_ctx->row[i] = talloc_bstrndup(query_ctx->row, row[i], field_lens[i]));
}
query_ctx->rcode = RLM_SQL_OK;
mysql_free_result(conn->result);
conn->result = NULL;
}
- TALLOC_FREE(query_ctx->handle->row);
+ TALLOC_FREE(query_ctx->row);
return RLM_SQL_OK;
}
static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
{
fr_sql_query_t *query_ctx = talloc_get_type_abort(uctx, fr_sql_query_t);
- query_ctx->handle->row = NULL;
+ query_ctx->row = NULL;
query_ctx->rcode = RLM_SQL_NO_MORE_ROWS;
RETURN_MODULE_OK;
}
RETURN_MODULE_FAIL;
}
- handle->row = NULL;
+ query_ctx->row = NULL;
status = OCIStmtFetch(conn->query, conn->error, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
if (status == OCI_SUCCESS) {
- handle->row = conn->row;
+ query_ctx->row = conn->row;
query_ctx->rcode = RLM_SQL_OK;
RETURN_MODULE_OK;
int records, i, len;
rlm_sql_postgres_conn_t *conn = handle->conn;
- handle->row = NULL;
+ query_ctx->row = NULL;
query_ctx->rcode = RLM_SQL_NO_MORE_ROWS;
if (conn->cur_row >= PQntuples(conn->result)) RETURN_MODULE_OK;
strlcpy(conn->row[i], PQgetvalue(conn->result, conn->cur_row, i), len + 1);
}
conn->cur_row++;
- handle->row = conn->row;
+ query_ctx->row = conn->row;
query_ctx->rcode = RLM_SQL_OK;
}
rlm_sql_sqlite_conn_t *conn = handle->conn;
char **row;
- TALLOC_FREE(handle->row);
+ TALLOC_FREE(query_ctx->row);
/*
* Executes the SQLite query and iterates over the results
/*
* Free the previous result (also gets called on finish_query)
*/
- MEM(row = handle->row = talloc_zero_array(handle->conn, char *, conn->col_count + 1));
+ MEM(row = query_ctx->row = talloc_zero_array(query_ctx, char *, conn->col_count + 1));
for (i = 0; i < conn->col_count; i++) {
switch (sqlite3_column_type(conn->statement, i)) {
rlm_sql_sqlite_conn_t *conn = query_ctx->handle->conn;
if (conn->statement) {
- TALLOC_FREE(query_ctx->handle->row);
+ TALLOC_FREE(query_ctx->row);
(void) sqlite3_finalize(conn->statement);
conn->statement = NULL;
rlm_sql_unixodbc_conn_t *conn = handle->conn;
long err_handle;
- handle->row = NULL;
+ query_ctx->row = NULL;
err_handle = SQLFetch(conn->stmt);
if (err_handle == SQL_NO_DATA_FOUND) {
query_ctx->rcode = sql_check_error(err_handle, handle, &query_ctx->inst->config);
if (query_ctx->rcode != RLM_SQL_OK) RETURN_MODULE_FAIL;
- handle->row = conn->row;
+ query_ctx->row = conn->row;
query_ctx->rcode = RLM_SQL_OK;
RETURN_MODULE_OK;
do {
inst->fetch_row(&p_result, NULL, request, query_ctx);
- row = query_ctx->handle->row;
+ row = query_ctx->row;
switch (query_ctx->rcode) {
case RLM_SQL_OK:
if (row[0]) break;
*/
while ((inst->fetch_row(p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
(query_ctx->rcode == RLM_SQL_OK)) {
- row = query_ctx->handle->row;
+ row = query_ctx->row;
rows++;
for (map = map_list_head(maps), j = 0;
map && (j < MAX_SQL_FIELD_INDEX);
while ((inst->fetch_row(&p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
(query_ctx->rcode == RLM_SQL_OK)) {
- row = query_ctx->handle->row;
+ row = query_ctx->row;
if (!row[0]){
RDEBUG2("row[0] returned NULL");
(inst->driver->sql_finish_select_query)(query_ctx, &inst->config);
typedef struct {
void *conn; //!< Database specific connection handle.
- rlm_sql_row_t row; //!< Row data from the last query.
rlm_sql_t const *inst; //!< The rlm_sql instance this connection belongs to.
TALLOC_CTX *log_ctx; //!< Talloc pool used to avoid allocing memory
//!< when log strings need to be copied.
fr_sql_query_type_t type; //!< Type of query.
fr_sql_query_status_t status; //!< Status of the query.
sql_rcode_t rcode; //!< Result code.
+ rlm_sql_row_t row; //!< Row data from the last query.
} fr_sql_query_t;
extern fr_table_num_sorted_t const sql_rcode_description_table[];
/** Call the driver's sql_fetch_row function
*
* Calls the driver's sql_fetch_row logging any errors. On success, will
- * write row data to ``uctx->handle->row``.
+ * write row data to ``uctx->row``.
*
* The rcode within the query context is updated to
* - #RLM_SQL_OK on success.
(inst->driver->sql_fetch_row)(p_result, NULL, request, query_ctx);
switch (query_ctx->rcode) {
case RLM_SQL_OK:
- fr_assert(query_ctx->handle->row != NULL);
+ fr_assert(query_ctx->row != NULL);
RETURN_MODULE_OK;
case RLM_SQL_NO_MORE_ROWS:
- fr_assert(query_ctx->handle->row == NULL);
+ fr_assert(query_ctx->row == NULL);
RETURN_MODULE_OK;
default:
(query_ctx->rcode == RLM_SQL_OK)) {
map_t *map;
- row = query_ctx->handle->row;
+ row = query_ctx->row;
if (map_afrom_fields(ctx, &map, &parent, request, row[2], row[4], row[3], &lhs_rules, &rhs_rules) < 0) {
RPEDEBUG("Error parsing user data from database result");
goto error;
goto finish;
}
- row = query_ctx->handle->row;
+ row = query_ctx->row;
if (!row) {
RDEBUG2("SQL query did not return any results");
goto finish;