All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
sql.c File Reference
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <ctype.h>
#include "rlm_sql.h"
+ Include dependency graph for sql.c:

Go to the source code of this file.

Functions

static int _mod_conn_free (rlm_sql_handle_t *conn)
 
void * mod_conn_create (TALLOC_CTX *ctx, void *instance, struct timeval const *timeout)
 Create a new connection pool handle. More...
 
sql_rcode_t rlm_sql_fetch_row (rlm_sql_row_t *out, rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle)
 Call the driver's sql_fetch_row function. More...
 
void rlm_sql_print_error (rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t *handle, bool force_debug)
 Retrieve any errors from the SQL driver. More...
 
sql_rcode_t rlm_sql_query (rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle, char const *query)
 Call the driver's sql_query method, reconnecting if necessary. More...
 
void rlm_sql_query_log (rlm_sql_t const *inst, REQUEST *request, sql_acct_section_t *section, char const *query)
 
sql_rcode_t rlm_sql_select_query (rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle, char const *query)
 Call the driver's sql_select_query method, reconnecting if necessary. More...
 
int sql_fr_pair_list_afrom_str (TALLOC_CTX *ctx, REQUEST *request, VALUE_PAIR **head, rlm_sql_row_t row)
 
int sql_getvpdata (TALLOC_CTX *ctx, rlm_sql_t const *inst, REQUEST *request, rlm_sql_handle_t **handle, VALUE_PAIR **pair, char const *query)
 

Variables

const FR_NAME_NUMBER sql_rcode_table []
 

Function Documentation

static int _mod_conn_free ( rlm_sql_handle_t conn)
static

Definition at line 56 of file sql.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* mod_conn_create ( TALLOC_CTX *  ctx,
void *  instance,
struct timeval const *  timeout 
)

Create a new connection pool handle.

Create a new connection to Couchbase within the pool and initialize information associated with the connection instance.

Parameters
ctxThe connection parent context.
instanceThe module instance.
timeoutMaximum time to establish the connection.
Returns
  • New connection handle.
  • NULL on error.

Create a new connection pool handle.

Create a new ldap connection and allocate memory for a new rlm_handle_t

Create a new connection pool handle.

Matches the fr_connection_create_t function prototype, is passed to fr_connection_pool_init, and called when a new connection is required by the connection pool API.

Creates an instances of rlm_rest_handle_t, and rlm_rest_curl_context_t which hold the context data required for generating requests and parsing responses.

If instance->connect_uri is not NULL libcurl will attempt to open a TCP socket to the server specified in the URI. This is done so that when the socket is first used, there will already be a cached TCP connection to the REST server associated with the curl handle.

See Also
fr_connection_pool_init
fr_connection_create_t
connection.c

Definition at line 67 of file sql.c.

+ Here is the call graph for this function:

sql_rcode_t rlm_sql_fetch_row ( rlm_sql_row_t out,
rlm_sql_t const *  inst,
REQUEST request,
rlm_sql_handle_t **  handle 
)

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 (*handle)->row.

Parameters
outWhere to write row data.
instInstance of rlm_sql_t.
requestThe Current request, may be NULL.
handleHandle to retrieve errors for.
Returns

Definition at line 249 of file sql.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rlm_sql_print_error ( rlm_sql_t const *  inst,
REQUEST request,
rlm_sql_handle_t handle,
bool  force_debug 
)

Retrieve any errors from the SQL driver.

Retrieves errors from the driver from the last operation and writes them to to request/global log, in the ERROR, WARN, INFO and DEBUG categories.

Parameters
instInstance of rlm_sql.
requestCurrent request, may be NULL.
handleHandle to retrieve errors for.
force_debugForce all errors to be logged as debug messages.

Definition at line 280 of file sql.c.

+ Here is the caller graph for this function:

sql_rcode_t rlm_sql_query ( rlm_sql_t const *  inst,
REQUEST request,
rlm_sql_handle_t **  handle,
char const *  query 
)

Call the driver's sql_query method, reconnecting if necessary.

Note
Caller must call (inst->module->sql_finish_query)(handle, inst->config); after they're done with the result.
Parameters
handleto query the database with. *handle should not be NULL, as this indicates previous reconnection attempt has failed.
requestCurrent request.
instrlm_sql_t instance data.
queryto execute. Should not be zero length.
Returns

Definition at line 337 of file sql.c.

+ Here is the call graph for this function:

void rlm_sql_query_log ( rlm_sql_t const *  inst,
REQUEST request,
sql_acct_section_t section,
char const *  query 
)

Definition at line 535 of file sql.c.

+ Here is the call graph for this function:

sql_rcode_t rlm_sql_select_query ( rlm_sql_t const *  inst,
REQUEST request,
rlm_sql_handle_t **  handle,
char const *  query 
)

Call the driver's sql_select_query method, reconnecting if necessary.

Note
Caller must call (inst->module->sql_finish_select_query)(handle, inst->config); after they're done with the result.
Parameters
instrlm_sql_t instance data.
requestCurrent request.
handleto query the database with. *handle should not be NULL, as this indicates previous reconnection attempt has failed.
queryto execute. Should not be zero length.
Returns

Definition at line 438 of file sql.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int sql_fr_pair_list_afrom_str ( TALLOC_CTX *  ctx,
REQUEST request,
VALUE_PAIR **  head,
rlm_sql_row_t  row 
)

Definition at line 128 of file sql.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int sql_getvpdata ( TALLOC_CTX *  ctx,
rlm_sql_t const *  inst,
REQUEST request,
rlm_sql_handle_t **  handle,
VALUE_PAIR **  pair,
char const *  query 
)

Definition at line 504 of file sql.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const FR_NAME_NUMBER sql_rcode_table[]
Initial value:
= {
{ "success", RLM_SQL_OK },
{ "need alt query", RLM_SQL_ALT_QUERY },
{ "server error", RLM_SQL_ERROR },
{ "query invalid", RLM_SQL_QUERY_INVALID },
{ "no connection", RLM_SQL_RECONNECT },
{ NULL, 0 }
}
General connection/server error.
Definition: rlm_sql.h:46
Key constraint violation.
Definition: rlm_sql.h:49
Stale connection, should reconnect.
Definition: rlm_sql.h:48
Success.
Definition: rlm_sql.h:47
Query syntax error.
Definition: rlm_sql.h:45

Definition at line 46 of file sql.c.