2 * sql_null.c SQL Module
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.
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.
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
20 * Copyright 2012 Alan DeKok <aland@freeradius.org>
23 #include <freeradius-devel/ident.h>
26 #include <freeradius-devel/radiusd.h>
32 static int sql_free_result(rlm_sql_handle_t*, rlm_sql_config_t*);
34 static const void *fake = "fake";
36 /*************************************************************************
38 * Function: sql_create_socket
40 * Purpose: Establish connection to the db
42 *************************************************************************/
43 static int sql_init_socket(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
45 memcpy(&handle->conn, &fake, sizeof(handle->conn));
49 /*************************************************************************
51 * Function: sql_destroy_socket
53 * Purpose: Free socket and any private connection data
55 *************************************************************************/
56 static int sql_destroy_socket(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
64 /*************************************************************************
68 * Purpose: Issue a query to the database
70 *************************************************************************/
71 static int sql_query(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config, UNUSED char *querystr)
77 /*************************************************************************
79 * Function: sql_store_result
81 * Purpose: database specific store_result function. Returns a result
82 * set for the query. In case of multiple results, get the
83 * first non-empty one.
85 *************************************************************************/
86 static int sql_store_result(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
92 /*************************************************************************
94 * Function: sql_num_fields
96 * Purpose: database specific num_fields function. Returns number
97 * of columns from query
99 *************************************************************************/
100 static int sql_num_fields(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
106 /*************************************************************************
108 * Function: sql_select_query
110 * Purpose: Issue a select query to the database
112 *************************************************************************/
113 static int sql_select_query(UNUSED rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config,
114 UNUSED char *querystr)
120 /*************************************************************************
122 * Function: sql_num_rows
124 * Purpose: database specific num_rows. Returns number of rows in
127 *************************************************************************/
128 static int sql_num_rows(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
134 /*************************************************************************
136 * Function: sql_fetch_row
138 * Purpose: database specific fetch_row. Returns a rlm_sql_row_t struct
139 * with all the data for the query in 'handle->row'. Returns
140 * 0 on success, -1 on failure, SQL_DOWN if database is down.
142 *************************************************************************/
143 static int sql_fetch_row(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
149 /*************************************************************************
151 * Function: sql_free_result
153 * Purpose: database specific free_result. Frees memory allocated
156 *************************************************************************/
157 static int sql_free_result(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
164 /*************************************************************************
166 * Function: sql_error
168 * Purpose: database specific error. Returns error associated with
171 *************************************************************************/
172 static const char *sql_error(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
174 return "Unknown error";
178 /*************************************************************************
180 * Function: sql_close
182 * Purpose: database specific close. Closes an open database
185 *************************************************************************/
186 static int sql_close(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
193 /*************************************************************************
195 * Function: sql_finish_query
197 * Purpose: As a single SQL statement may return multiple results
198 * sets, (for example stored procedures) it is necessary to check
199 * whether more results exist and process them in turn if so.
201 *************************************************************************/
202 static int sql_finish_query(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
209 /*************************************************************************
211 * Function: sql_finish_select_query
213 * Purpose: End the select query, such as freeing memory or result
215 *************************************************************************/
216 static int sql_finish_select_query(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
222 /*************************************************************************
224 * Function: sql_affected_rows
226 * Purpose: End the select query, such as freeing memory or result
228 *************************************************************************/
229 static int sql_affected_rows(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
235 /* Exported to rlm_sql */
236 rlm_sql_module_t rlm_sql_null = {
250 sql_finish_select_query,