21 RCSID(
"$Id: e2fa5d0137bfc8d8f571a64a7fdf58eb6f0f4847 $")
23 #define LOG_PREFIX "sql - firebird"
26 #include <freeradius-devel/util/debug.h>
29 static char tpb[] = {isc_tpb_version3, isc_tpb_wait, isc_tpb_write,
30 isc_tpb_read_committed, isc_tpb_no_rec_version};
48 MEM(c->
sqlda_out = (XSQLDA *)_talloc_array(conn, 1, XSQLDA_LENGTH(5),
"XSQLDA"));
72 DEBUG2(
"Socket destructor called, closing socket");
77 isc_detach_database(c->
status, &(c->
dbh));
82 talloc_free_children(c);
95 bool deadlock =
false;
102 query_ctx->
tconn = tconn;
130 ROPTIONAL(
RERROR,
ERROR,
"conn_id rlm_sql_firebird,sql_query error: sql_code=%li, error='%s', query=%s",
177 query_ctx->
treq = NULL;
194 MEM(
names = talloc_array(query_ctx,
char const *, fields));
196 for (i = 0; i < fields; i++)
names[i] = conn->
sqlda_out->sqlvar[i].sqlname;
211 query_ctx->
row = NULL;
230 TALLOC_FREE(conn->
row);
246 TALLOC_FREE(conn->
row);
259 TALLOC_FREE(conn->
row);
282 if (!conn->
error)
return 0;
304 .name =
"sql_firebird",
308 .sql_query_resume = sql_query_resume,
309 .sql_select_query_resume = sql_query_resume,
319 .connection_alloc = sql_trunk_connection_alloc,
320 .request_mux = sql_trunk_request_mux,
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ CONNECTION_STATE_FAILED
Connection has failed.
@ CONNECTION_STATE_CONNECTED
File descriptor is open (ready for writing).
@ CONNECTION_FAILED
Connection is being reconnected because it failed.
fr_dcursor_eval_t void const * uctx
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
void unlang_interpret_mark_runnable(request_t *request)
Mark a request as resumable.
#define ROPTIONAL(_l_request, _l_global, _fmt,...)
Use different logging functions depending on whether request is NULL or not.
Stores all information relating to an event list.
static const conf_parser_t config[]
rlm_rcode_t
Return codes indicating the result of the module call.
fr_sql_query_status_t status
Status of the query.
trunk_connection_t * tconn
Trunk connection this query is being run on.
char const * query_str
Query string to run.
request_t * request
Request this query relates to.
sql_rcode_t
Action to take at end of an SQL query.
@ RLM_SQL_ALT_QUERY
Key constraint violation, use an alternative query.
@ RLM_SQL_RECONNECT
Stale connection, should reconnect.
@ RLM_SQL_ERROR
General connection/server error.
@ RLM_SQL_NO_MORE_ROWS
No more rows available.
#define RLM_SQL_RCODE_FLAGS_ALT_QUERY
Can distinguish between other errors and those.
rlm_sql_row_t row
Row data from the last query.
sql_rcode_t rcode
Result code.
trunk_request_t * treq
Trunk request for this query.
@ SQL_QUERY_RETURNED
Query has executed.
@ SQL_QUERY_FAILED
Failed to submit.
@ SQL_QUERY_PREPARED
Ready to submit.
static size_t sql_error(UNUSED TALLOC_CTX *ctx, sql_log_entry_t out[], NDEBUG_UNUSED size_t outlen, fr_sql_query_t *query_ctx)
Retrieves any errors associated with the query context.
static sql_rcode_t sql_fields(char const **out[], fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Returns name of fields.
static sql_rcode_t sql_finish_query(fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
End the query, such as freeing memory or result.
rlm_sql_driver_t rlm_sql_firebird
static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
Returns an individual row.
static void _sql_connection_close(UNUSED fr_event_list_t *el, void *h, UNUSED void *uctx)
static SQL_QUERY_RESUME void sql_request_complete(UNUSED request_t *request, void *preq, UNUSED void *rctx, UNUSED void *uctx)
static sql_rcode_t sql_free_result(fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Frees memory allocated for a result set.
static void sql_request_fail(UNUSED request_t *request, void *preq, UNUSED void *rctx, UNUSED trunk_request_state_t state, UNUSED void *uctx)
CC_NO_UBSAN(function)
Establish connection to the db.
static int sql_affected_rows(fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
Return the number of rows affected by the query (update, or insert)
Macros to reduce boilerplate in trunk SQL drivers.
#define SQL_TRUNK_CONNECTION_ALLOC
Allocate an SQL trunk connection.
void connection_signal_reconnect(connection_t *conn, connection_reason_t reason)
Asynchronously signal the connection should be reconnected.
int fb_sql_query(rlm_sql_firebird_conn_t *conn, char const *query)
int fb_connect(rlm_sql_firebird_conn_t *conn, rlm_sql_config_t const *config)
int fb_rollback(rlm_sql_firebird_conn_t *conn)
int fb_error(rlm_sql_firebird_conn_t *conn)
int fb_fetch(rlm_sql_firebird_conn_t *conn)
sql_rcode_t fb_store_row(rlm_sql_firebird_conn_t *conn)
int fb_commit(rlm_sql_firebird_conn_t *conn)
int fb_affected_rows(rlm_sql_firebird_conn_t *conn)
void fb_free_statement(rlm_sql_firebird_conn_t *conn)
#define DUPLICATE_KEY_SQL_CODE
#define DEADLOCK_SQL_CODE
ISC_STATUS status[20]
Magic interbase status code array (holds multiple error codes used to construct more detailed error m...
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
module_t common
Common fields for all loadable modules.
#define talloc_get_type_abort_const
static const char * names[8]
void trunk_request_signal_fail(trunk_request_t *treq)
Signal that a trunk request failed.
int trunk_connection_pop_request(trunk_request_t **treq_out, trunk_connection_t *tconn)
Pop a request off a connection's pending queue.
void trunk_request_signal_reapable(trunk_request_t *treq)
Signal that the request was written to a connection successfully, but no response is expected.
Associates request queues with a connection.
trunk_request_state_t
Used for sanity checks and to simplify freeing.
static fr_event_list_t * el
static size_t char ** out