]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use instance methods for calling SQL functions
authorNick Porter <nick@portercomputing.co.uk>
Fri, 3 May 2024 07:54:30 +0000 (08:54 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 7 Jun 2024 02:26:58 +0000 (22:26 -0400)
Preparation so we can switch functions as drivers move to use trunk code

src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sql/sql.c

index 1f9219efb9ebe149be532d6dd750ae8943493206..ac31fab0258ea8f104cc7249393f921b623283a4 100644 (file)
@@ -430,7 +430,7 @@ static xlat_action_t sql_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
                MEM(query_ctx = fr_sql_query_alloc(unlang_interpret_frame_talloc_ctx(request), inst, handle,
                                                   arg->vb_strvalue, SQL_QUERY_OTHER));
-               rlm_sql_query(&p_result, NULL, request, query_ctx);
+               inst->query(&p_result, NULL, request, query_ctx);
                if (query_ctx->rcode != RLM_SQL_OK) {
                query_error:
                        RERROR("SQL query failed: %s", fr_table_str_by_value(sql_rcode_description_table,
@@ -456,11 +456,11 @@ static xlat_action_t sql_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        MEM(query_ctx = fr_sql_query_alloc(unlang_interpret_frame_talloc_ctx(request), inst, handle,
                                           arg->vb_strvalue, SQL_QUERY_SELECT));
-       rlm_sql_select_query(&p_result, NULL, request, query_ctx);
+       inst->select(&p_result, NULL, request, query_ctx);
        if (query_ctx->rcode != RLM_SQL_OK) goto query_error;
 
        do {
-               rlm_sql_fetch_row(&p_result, NULL, request, query_ctx);
+               inst->fetch_row(&p_result, NULL, request, query_ctx);
                row = query_ctx->handle->row;
                switch (query_ctx->rcode) {
                case RLM_SQL_OK:
@@ -613,7 +613,7 @@ static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void const *mod_inst,
        }
 
        MEM(query_ctx = fr_sql_query_alloc(unlang_interpret_frame_talloc_ctx(request), inst, handle, query_str, SQL_QUERY_SELECT));
-       rlm_sql_select_query(p_result, NULL, request, query_ctx);
+       inst->select(p_result, NULL, request, query_ctx);
        handle = query_ctx->handle;
 
        if (query_ctx->rcode != RLM_SQL_OK) {
@@ -695,7 +695,7 @@ static unlang_action_t mod_map_proc(rlm_rcode_t *p_result, void const *mod_inst,
         *      Note: Not all SQL client libraries provide a row count,
         *      so we have to do the count here.
         */
-       while ((rlm_sql_fetch_row(p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
+       while ((inst->fetch_row(p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
               (query_ctx->rcode == RLM_SQL_OK)) {
                row = query_ctx->handle->row;
                rows++;
@@ -887,14 +887,14 @@ static int sql_get_grouplist(rlm_sql_t const *inst, rlm_sql_handle_t **handle, r
 
        MEM(query_ctx = fr_sql_query_alloc(unlang_interpret_frame_talloc_ctx(request), inst, *handle, query, SQL_QUERY_SELECT ));
 
-       rlm_sql_select_query(&p_result, NULL, request, query_ctx);
+       inst->select(&p_result, NULL, request, query_ctx);
        if (query_ctx->rcode != RLM_SQL_OK) {
                talloc_free(query_ctx);
                return -1;
        }
        *handle = query_ctx->handle;
 
-       while ((rlm_sql_fetch_row(&p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
+       while ((inst->fetch_row(&p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
                (query_ctx->rcode == RLM_SQL_OK)) {
                row = query_ctx->handle->row;
                if (!row[0]){
@@ -1530,7 +1530,7 @@ static unlang_action_t mod_sql_redundant_resume(rlm_rcode_t *p_result, UNUSED in
        MEM(query_ctx = fr_sql_query_alloc(unlang_interpret_frame_talloc_ctx(request), inst, redundant_ctx->handle,
                                           query->vb_strvalue, SQL_QUERY_SELECT));
 
-       rlm_sql_query(p_result, NULL, request, query_ctx);
+       inst->query(p_result, NULL, request, query_ctx);
        talloc_free(query);
 
        RDEBUG2("SQL query returned: %s", fr_table_str_by_value(sql_rcode_description_table, query_ctx->rcode, "<INVALID>"));
index e79022ba18606797ed527bc589ac53a8b4be4b51..7bb0ec8db32a1b4238ef15d16b7768789142ed0e 100644 (file)
@@ -101,7 +101,7 @@ void *sql_mod_conn_create(TALLOC_CTX *ctx, void *instance, fr_time_delta_t timeo
                fr_sql_query_t  *query_ctx;
                rlm_rcode_t     p_result;
                MEM(query_ctx = fr_sql_query_alloc(ctx, inst, handle, inst->config.connect_query, SQL_QUERY_OTHER));
-               rlm_sql_query(&p_result, NULL, NULL, query_ctx);
+               inst->query(&p_result, NULL, NULL, query_ctx);
                if (query_ctx->rcode != RLM_SQL_OK) {
                        talloc_free(query_ctx);
                        goto fail;
@@ -643,7 +643,7 @@ int sql_get_map_list(TALLOC_CTX *ctx, rlm_sql_t const *inst, request_t *request,
        fr_assert(request);
 
        MEM(query_ctx = fr_sql_query_alloc(unlang_interpret_frame_talloc_ctx(request), inst, *handle, query, SQL_QUERY_SELECT));
-       rlm_sql_select_query(&p_result, NULL, request, query_ctx);
+       inst->select(&p_result, NULL, request, query_ctx);
        if (query_ctx->rcode != RLM_SQL_OK) {
        error:
                *handle = query_ctx->handle;
@@ -651,7 +651,7 @@ int sql_get_map_list(TALLOC_CTX *ctx, rlm_sql_t const *inst, request_t *request,
                return -1;
        }
 
-       while ((rlm_sql_fetch_row(&p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
+       while ((inst->fetch_row(&p_result, NULL, request, query_ctx) == UNLANG_ACTION_CALCULATE_RESULT) &&
               (query_ctx->rcode == RLM_SQL_OK)) {
                map_t *map;