The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rlm_sql_null.c
Go to the documentation of this file.
1/*
2 * sql_null.c SQL Module
3 *
4 * Version: $Id: f5a70a4b1eeb6759378f8be624f40b12b6d228c1 $
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 * @copyright 2012 Alan DeKok (aland@freeradius.org)
21 */
22
23RCSID("$Id: f5a70a4b1eeb6759378f8be624f40b12b6d228c1 $")
24
25#include <freeradius-devel/server/base.h>
26
27#include "rlm_sql.h"
28#include "rlm_sql_trunk.h"
29
30static const void *fake = "fake";
31
32static void _sql_connection_close(UNUSED fr_event_list_t *el, UNUSED void *h, UNUSED void *uctx)
33{
34 return;
35}
36
37CC_NO_UBSAN(function) /* UBSAN: false positive - public vs private connection_t trips --fsanitize=function */
39{
40 *h = UNCONST(void *, fake);
42}
43
45
47
48CC_NO_UBSAN(function) /* UBSAN: false positive - public vs private connection_t trips --fsanitize=function */
50 UNUSED connection_t *conn, UNUSED void *uctx)
51{
52 trunk_request_t *treq;
53 request_t *request;
54 fr_sql_query_t *query_ctx;
55
56 while (trunk_connection_pop_request(&treq, tconn) != 0) {
57 if (!treq) return;
58
59 query_ctx = talloc_get_type_abort(treq->preq, fr_sql_query_t);
60 request = query_ctx->request;
61 query_ctx->tconn = tconn;
62 query_ctx->rcode = RLM_SQL_OK;
63
65 if (request) unlang_interpret_mark_runnable(request);
66 }
67}
68
70{
71 return 0;
72}
73
74static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
75{
76 fr_sql_query_t *query_ctx = talloc_get_type_abort(uctx, fr_sql_query_t);
77 query_ctx->row = NULL;
78 query_ctx->rcode = RLM_SQL_NO_MORE_ROWS;
80}
81
83{
84 return 0;
85}
86
87/** Stub function for retrieving errors, should not be called
88 *
89 */
90static size_t sql_error(UNUSED TALLOC_CTX *ctx, UNUSED sql_log_entry_t out[], UNUSED size_t outlen,
91 UNUSED fr_sql_query_t *query_ctx)
92{
93 return 0;
94}
95
97{
98 return 0;
99}
100
102{
103 return 1;
104}
105
106/* Exported to rlm_sql */
109 .common = {
110 .magic = MODULE_MAGIC_INIT,
111 .name = "sql_null"
112 },
113 .sql_query_resume = sql_query_resume,
114 .sql_select_query_resume = sql_query_resume,
115 .sql_num_rows = sql_num_rows,
116 .sql_fetch_row = sql_fetch_row,
117 .sql_free_result = sql_free_result,
118 .sql_error = sql_error,
119 .sql_finish_query = sql_finish_query,
120 .sql_finish_select_query = sql_finish_query,
121 .sql_affected_rows = sql_affected_rows,
122 .trunk_io_funcs = {
123 .connection_alloc = sql_trunk_connection_alloc,
124 .request_mux = sql_trunk_request_mux,
125 }
126};
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Definition build.h:167
#define RCSID(id)
Definition build.h:483
#define CC_NO_UBSAN(_sanitize)
Definition build.h:426
#define UNUSED
Definition build.h:315
connection_state_t
Definition connection.h:45
@ CONNECTION_STATE_CONNECTED
File descriptor is open (ready for writing).
Definition connection.h:52
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
void unlang_interpret_mark_runnable(request_t *request)
Mark a request as resumable.
Definition interpret.c:1359
Stores all information relating to an event list.
Definition event.c:411
static const conf_parser_t config[]
Definition base.c:183
#define RETURN_MODULE_OK
Definition rcode.h:57
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:40
Prototypes and functions for the SQL module.
trunk_connection_t * tconn
Trunk connection this query is being run on.
Definition rlm_sql.h:134
request_t * request
Request this query relates to.
Definition rlm_sql.h:132
sql_rcode_t
Action to take at end of an SQL query.
Definition rlm_sql.h:44
@ RLM_SQL_OK
Success.
Definition rlm_sql.h:47
@ RLM_SQL_NO_MORE_ROWS
No more rows available.
Definition rlm_sql.h:50
rlm_sql_row_t row
Row data from the last query.
Definition rlm_sql.h:140
sql_rcode_t rcode
Result code.
Definition rlm_sql.h:139
Definition rlm_sql.h:61
static const void * fake
rlm_sql_driver_t rlm_sql_null
static void _sql_connection_close(UNUSED fr_event_list_t *el, UNUSED void *h, UNUSED void *uctx)
static unlang_action_t sql_fetch_row(rlm_rcode_t *p_result, UNUSED int *priority, UNUSED request_t *request, void *uctx)
static int sql_affected_rows(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
static int sql_num_rows(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
static sql_rcode_t sql_finish_query(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
static connection_state_t _sql_connection_init(void **h, UNUSED connection_t *conn, UNUSED void *uctx)
static size_t sql_error(UNUSED TALLOC_CTX *ctx, UNUSED sql_log_entry_t out[], UNUSED size_t outlen, UNUSED fr_sql_query_t *query_ctx)
Stub function for retrieving errors, should not be called.
static sql_rcode_t sql_free_result(UNUSED fr_sql_query_t *query_ctx, UNUSED rlm_sql_config_t const *config)
SQL_TRUNK_CONNECTION_ALLOC static SQL_QUERY_RESUME void sql_trunk_request_mux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, UNUSED connection_t *conn, UNUSED void *uctx)
Macros to reduce boilerplate in trunk SQL drivers.
#define SQL_QUERY_RESUME
#define SQL_TRUNK_CONNECTION_ALLOC
Allocate an SQL trunk connection.
module_t common
Common fields for all loadable modules.
Definition rlm_sql.h:194
int trunk_connection_pop_request(trunk_request_t **treq_out, trunk_connection_t *tconn)
Pop a request off a connection's pending queue.
Definition trunk.c:3883
void trunk_request_signal_reapable(trunk_request_t *treq)
Signal that the request was written to a connection successfully, but no response is expected.
Definition trunk.c:2072
Associates request queues with a connection.
Definition trunk.c:134
Wraps a normal request.
Definition trunk.c:100
static fr_event_list_t * el
static size_t char ** out
Definition value.h:997