Rename SQL data types so they don't conflict with drivers
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_null / rlm_sql_null.c
1 /*
2  * sql_null.c           SQL Module
3  *
4  * Version:     $Id$
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
23 #include <freeradius-devel/ident.h>
24 RCSID("$Id$")
25
26 #include <freeradius-devel/radiusd.h>
27
28 #include        "rlm_sql.h"
29
30
31 /* Prototypes */
32 static int sql_free_result(rlm_sql_handle_t*, rlm_sql_config_t*);
33
34 static const void *fake = "fake";
35
36 /*************************************************************************
37  *
38  *      Function: sql_create_socket
39  *
40  *      Purpose: Establish connection to the db
41  *
42  *************************************************************************/
43 static int sql_init_socket(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
44 {
45         memcpy(&handle->conn, &fake, sizeof(handle->conn));
46         return 0;
47 }
48
49 /*************************************************************************
50  *
51  *      Function: sql_destroy_socket
52  *
53  *      Purpose: Free socket and any private connection data
54  *
55  *************************************************************************/
56 static int sql_destroy_socket(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config)
57 {
58         handle->conn = NULL;
59
60         return 0;
61 }
62
63
64 /*************************************************************************
65  *
66  *      Function: sql_query
67  *
68  *      Purpose: Issue a query to the database
69  *
70  *************************************************************************/
71 static int sql_query(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config, UNUSED char *querystr)
72 {
73         return 0;
74 }
75
76
77 /*************************************************************************
78  *
79  *      Function: sql_store_result
80  *
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.
84  *
85  *************************************************************************/
86 static int sql_store_result(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
87 {
88         return 0;
89 }
90
91
92 /*************************************************************************
93  *
94  *      Function: sql_num_fields
95  *
96  *      Purpose: database specific num_fields function. Returns number
97  *               of columns from query
98  *
99  *************************************************************************/
100 static int sql_num_fields(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
101 {
102         return 0;
103 }
104
105
106 /*************************************************************************
107  *
108  *      Function: sql_select_query
109  *
110  *      Purpose: Issue a select query to the database
111  *
112  *************************************************************************/
113 static int sql_select_query(UNUSED rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t *config,
114                             UNUSED char *querystr)
115 {
116         return 0;
117 }
118
119
120 /*************************************************************************
121  *
122  *      Function: sql_num_rows
123  *
124  *      Purpose: database specific num_rows. Returns number of rows in
125  *               query
126  *
127  *************************************************************************/
128 static int sql_num_rows(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
129 {
130         return 0;
131 }
132
133
134 /*************************************************************************
135  *
136  *      Function: sql_fetch_row
137  *
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.
141  *
142  *************************************************************************/
143 static int sql_fetch_row(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
144 {
145         return 0;
146 }
147
148
149 /*************************************************************************
150  *
151  *      Function: sql_free_result
152  *
153  *      Purpose: database specific free_result. Frees memory allocated
154  *               for a result set
155  *
156  *************************************************************************/
157 static int sql_free_result(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
158 {
159         return 0;
160 }
161
162
163
164 /*************************************************************************
165  *
166  *      Function: sql_error
167  *
168  *      Purpose: database specific error. Returns error associated with
169  *               connection
170  *
171  *************************************************************************/
172 static const char *sql_error(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
173 {
174         return "Unknown error";
175 }
176
177
178 /*************************************************************************
179  *
180  *      Function: sql_close
181  *
182  *      Purpose: database specific close. Closes an open database
183  *               connection
184  *
185  *************************************************************************/
186 static int sql_close(rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
187 {
188         handle->conn = NULL;
189         return 0;
190 }
191
192
193 /*************************************************************************
194  *
195  *      Function: sql_finish_query
196  *
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.
200  *
201  *************************************************************************/
202 static int sql_finish_query(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
203 {
204         return 0;
205 }
206
207
208
209 /*************************************************************************
210  *
211  *      Function: sql_finish_select_query
212  *
213  *      Purpose: End the select query, such as freeing memory or result
214  *
215  *************************************************************************/
216 static int sql_finish_select_query(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
217 {
218         return 0;
219 }
220
221
222 /*************************************************************************
223  *
224  *      Function: sql_affected_rows
225  *
226  *      Purpose: End the select query, such as freeing memory or result
227  *
228  *************************************************************************/
229 static int sql_affected_rows(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_config_t *config)
230 {
231         return 1;
232 }
233
234
235 /* Exported to rlm_sql */
236 rlm_sql_module_t rlm_sql_null = {
237         "rlm_sql_null",
238         sql_init_socket,
239         sql_destroy_socket,
240         sql_query,
241         sql_select_query,
242         sql_store_result,
243         sql_num_fields,
244         sql_num_rows,
245         sql_fetch_row,
246         sql_free_result,
247         sql_error,
248         sql_close,
249         sql_finish_query,
250         sql_finish_select_query,
251         sql_affected_rows
252 };