The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
rlm_sql_freetds.c File Reference
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/util/debug.h>
#include <sys/stat.h>
#include <ctpublic.h>
#include "rlm_sql.h"
#include "rlm_sql_trunk.h"
+ Include dependency graph for rlm_sql_freetds.c:

Go to the source code of this file.

Data Structures

struct  rlm_sql_freetds_conn_t
 

Macros

#define LOG_PREFIX   "sql - freetds"
 
#define MAX_DATASTR_LEN   256
 

Functions

static void _sql_connection_close (UNUSED fr_event_list_t *el, void *h, UNUSED void *uctx)
 
 CC_NO_UBSAN (function)
 
static CS_RETCODE CS_PUBLIC clientmsg_callback (CS_CONTEXT *context, UNUSED CS_CONNECTION *conn, CS_CLIENTMSG *emsgp)
 Client-Library error handler. More...
 
static CS_RETCODE CS_PUBLIC csmsg_callback (CS_CONTEXT *context, CS_CLIENTMSG *emsgp)
 Client error handler. More...
 
static CS_RETCODE CS_PUBLIC servermsg_callback (CS_CONTEXT *context, UNUSED CS_CONNECTION *conn, CS_SERVERMSG *msgp)
 Server error handler. More...
 
static int sql_affected_rows (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
 
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. More...
 
static unlang_action_t sql_fetch_row (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
 
static sql_rcode_t sql_fields (char const **out[], fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
 
static sql_rcode_t sql_finish_query (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
 
static sql_rcode_t sql_finish_select_query (fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
 
static sql_rcode_t sql_query (request_t *request, rlm_sql_freetds_conn_t *conn, char const *query)
 
SQL_TRUNK_CONNECTION_ALLOC static SQL_QUERY_RESUME void sql_request_fail (request_t *request, void *preq, UNUSED void *rctx, UNUSED trunk_request_state_t state, UNUSED void *uctx)
 
static sql_rcode_t sql_select_query (request_t *request, rlm_sql_freetds_conn_t *conn, char const *query)
 Execute a query when we expected a result set. More...
 

Variables

rlm_sql_driver_t rlm_sql_freetds
 

Data Structure Documentation

◆ rlm_sql_freetds_conn_t

struct rlm_sql_freetds_conn_t

Definition at line 41 of file rlm_sql_freetds.c.

Data Fields
int colcount How many columns are in the current result set.
CS_COMMAND * command A prepared statement.
CS_CONTEXT * context Structure FreeTDS uses to avoid creating globals.
CS_CONNECTION * db Handle specifying a single connection to the database.
char * error The last error string created by one of the call backs.
bool established Set to false once the connection has been properly established.
CS_SMALLINT * ind Indicators of data length / NULL.
bool nulls Were there any NULL values in the last row.
char ** results Result strings from statement execution.
CS_INT rows_affected Rows affected by last INSERT / UPDATE / DELETE.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   "sql - freetds"

Definition at line 29 of file rlm_sql_freetds.c.

◆ MAX_DATASTR_LEN

#define MAX_DATASTR_LEN   256

Definition at line 54 of file rlm_sql_freetds.c.

Function Documentation

◆ _sql_connection_close()

static void _sql_connection_close ( UNUSED fr_event_list_t el,
void *  h,
UNUSED void *  uctx 
)
static

Definition at line 673 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ CC_NO_UBSAN()

CC_NO_UBSAN ( function  )

Definition at line 535 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ clientmsg_callback()

static CS_RETCODE CS_PUBLIC clientmsg_callback ( CS_CONTEXT *  context,
UNUSED CS_CONNECTION *  conn,
CS_CLIENTMSG *  emsgp 
)
static

Client-Library error handler.

Callback for any errors raised by the Client-Library. Will overwrite any previous errors associated with a connection.

Parameters
contextThe FreeTDS library context.
connDB connection handle.
emsgpPointer to the error structure.
Returns
CS_SUCCEED

Definition at line 66 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ csmsg_callback()

static CS_RETCODE CS_PUBLIC csmsg_callback ( CS_CONTEXT *  context,
CS_CLIENTMSG *  emsgp 
)
static

Client error handler.

Callback for any errors raised by the client. Will overwrite any previous errors associated with a connection.

Parameters
contextThe FreeTDS library context.
emsgpPointer to the error structure.
Returns
CS_SUCCEED

Definition at line 110 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ servermsg_callback()

static CS_RETCODE CS_PUBLIC servermsg_callback ( CS_CONTEXT *  context,
UNUSED CS_CONNECTION *  conn,
CS_SERVERMSG *  msgp 
)
static

Server error handler.

Callback for any messages sent back from the server.

There's no standard categorisation of messages sent back from the server, so we don't know they're errors, the only thing we can do is write them to the long as informational messages.

Parameters
contextThe FreeTDS library context.
connDB connection handle.
msgpPointer to the error structure.
Returns
CS_SUCCEED

Definition at line 157 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ sql_affected_rows()

static int sql_affected_rows ( fr_sql_query_t query_ctx,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 578 of file rlm_sql_freetds.c.

◆ sql_error()

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 
)
static

Retrieves any errors associated with the query context.

Note
Caller will free any memory allocated in ctx.
Parameters
ctxto allocate temporary error buffers in.
outArray of sql_log_entrys to fill.
outlenLength of out array.
query_ctxQuery context to retrieve error for.
configrlm_sql config.
Returns
number of errors written to the sql_log_entry_t array.

Definition at line 388 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ sql_fetch_row()

static unlang_action_t sql_fetch_row ( rlm_rcode_t p_result,
UNUSED int *  priority,
request_t request,
void *  uctx 
)
static

Definition at line 585 of file rlm_sql_freetds.c.

◆ sql_fields()

static sql_rcode_t sql_fields ( char const **  out[],
fr_sql_query_t query_ctx,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 333 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ sql_finish_query()

static sql_rcode_t sql_finish_query ( fr_sql_query_t query_ctx,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 657 of file rlm_sql_freetds.c.

◆ sql_finish_select_query()

static sql_rcode_t sql_finish_select_query ( fr_sql_query_t query_ctx,
UNUSED rlm_sql_config_t const *  config 
)
static

Definition at line 403 of file rlm_sql_freetds.c.

◆ sql_query()

static sql_rcode_t sql_query ( request_t request,
rlm_sql_freetds_conn_t conn,
char const *  query 
)
static

Definition at line 199 of file rlm_sql_freetds.c.

+ Here is the caller graph for this function:

◆ sql_request_fail()

SQL_TRUNK_CONNECTION_ALLOC static SQL_QUERY_RESUME void sql_request_fail ( request_t request,
void *  preq,
UNUSED void *  rctx,
UNUSED trunk_request_state_t  state,
UNUSED void *  uctx 
)
static

Definition at line 814 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:

◆ sql_select_query()

static sql_rcode_t sql_select_query ( request_t request,
rlm_sql_freetds_conn_t conn,
char const *  query 
)
static

Execute a query when we expected a result set.

Definition at line 425 of file rlm_sql_freetds.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ rlm_sql_freetds

rlm_sql_driver_t rlm_sql_freetds
Initial value:
= {
.common = {
.name = "sql_freetds"
},
.sql_query_resume = sql_query_resume,
.sql_select_query_resume = sql_query_resume,
.sql_fields = sql_fields,
.sql_affected_rows = sql_affected_rows,
.sql_fetch_row = sql_fetch_row,
.sql_error = sql_error,
.sql_finish_query = sql_finish_query,
.sql_finish_select_query = sql_finish_select_query,
.uses_trunks = true,
.trunk_io_funcs = {
.connection_alloc = sql_trunk_connection_alloc,
.request_mux = sql_trunk_request_mux,
.request_fail = sql_request_fail
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
#define RLM_SQL_RCODE_FLAGS_ALT_QUERY
Can distinguish between other errors and those.
Definition: rlm_sql.h:172
static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
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)
static sql_rcode_t sql_finish_query(fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
SQL_TRUNK_CONNECTION_ALLOC static SQL_QUERY_RESUME void sql_request_fail(request_t *request, void *preq, UNUSED void *rctx, UNUSED trunk_request_state_t state, UNUSED void *uctx)
static sql_rcode_t sql_finish_select_query(fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
static int sql_affected_rows(fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)

Definition at line 826 of file rlm_sql_freetds.c.