From 70a49de8f1b7ecf1b80a42f6e76c7e4834c6f39a Mon Sep 17 00:00:00 2001 From: Nick Porter Date: Thu, 1 Feb 2024 13:58:43 +0000 Subject: [PATCH] No need for begin / commit for independent UPDATE queries Whilst Oracle had these set to "COMMIT", queries are actually run with OCI_COMMIT_ON_SUCCESS so no need for a separate COMMIT --- .../sql/ippool/oracle/queries.conf | 8 ----- src/modules/rlm_sqlippool/rlm_sqlippool.c | 34 ------------------- 2 files changed, 42 deletions(-) diff --git a/raddb/mods-config/sql/ippool/oracle/queries.conf b/raddb/mods-config/sql/ippool/oracle/queries.conf index 8e824a7e80b8e..60397978b8980 100644 --- a/raddb/mods-config/sql/ippool/oracle/queries.conf +++ b/raddb/mods-config/sql/ippool/oracle/queries.conf @@ -124,7 +124,6 @@ pool_check = "\ # the module which by default will give a NAK reply. In this example # incrementing "counter" is used to achieve this. # -update_begin = "commit" update_update = "\ UPDATE ${ippool_table} \ SET \ @@ -134,7 +133,6 @@ update_update = "\ WHERE pool_name = '%{control.${pool_name}}' \ AND owner = '${owner}' \ AND address = '${requested_address}'" -update_commit = "commit" # # RADIUS (Accounting-Stop) @@ -144,7 +142,6 @@ update_commit = "commit" # # Queries to release a lease # -release_begin = "commit" release_clear = "\ UPDATE ${ippool_table} \ SET gateway = '', \ @@ -153,7 +150,6 @@ release_clear = "\ WHERE pool_name = '%{control.${pool_name}}' \ AND owner = '${owner}' \ AND address = '${requested_address}'" -release_commit = "commit" # # DHCPv4 (Decline) @@ -162,14 +158,12 @@ release_commit = "commit" # # Queries to mark leases as "bad" # -mark_begin = "commit" mark_update = "\ UPDATE ${ippool_table} \ SET status_id = (SELECT status_id FROM fr_ippool_status WHERE status = 'declined') \ WHERE pool_name = '%{control.${pool_name}}' \ AND address = '${requested_address}' \ AND owner = '${owner}'" -mark_commit = "commit" # # RADIUS (Accounting-On) @@ -179,7 +173,6 @@ mark_commit = "commit" # # Frees all IPs allocated to a gateway # -bulk_release_begin = "commit" bulk_release_clear = "\ UPDATE ${ippool_table} \ SET gateway = '', \ @@ -187,4 +180,3 @@ bulk_release_clear = "\ expiry_time = current_timestamp \ WHERE pool_name = '%{control.${pool_name}}' \ AND gateway = '${gateway}'" -bulk_release_commit = "commit" diff --git a/src/modules/rlm_sqlippool/rlm_sqlippool.c b/src/modules/rlm_sqlippool/rlm_sqlippool.c index 98d921c0099e5..a08370ac73e59 100644 --- a/src/modules/rlm_sqlippool/rlm_sqlippool.c +++ b/src/modules/rlm_sqlippool/rlm_sqlippool.c @@ -57,25 +57,17 @@ typedef struct { char const *pool_check; //!< Query to check for the existence of the pool. /* Update sequence */ - char const *update_begin; //!< SQL query to begin. char const *update_free; //!< SQL query to clear offered IPs char const *update_update; //!< SQL query to update an IP entry. - char const *update_commit; //!< SQL query to commit. /* Release sequence */ - char const *release_begin; //!< SQL query to begin. char const *release_clear; //!< SQL query to clear an IP entry. - char const *release_commit; //!< SQL query to commit. /* Bulk release sequence */ - char const *bulk_release_begin; //!< SQL query to begin. char const *bulk_release_clear; //!< SQL query to bulk clear several IPs. - char const *bulk_release_commit; //!< SQL query to commit. /* Mark sequence */ - char const *mark_begin; //!< SQL query to begin. char const *mark_update; //!< SQL query to mark an IP. - char const *mark_commit; //!< SQL query to commit. } rlm_sqlippool_t; static conf_parser_t module_config[] = { @@ -102,35 +94,19 @@ static conf_parser_t module_config[] = { { FR_CONF_OFFSET_FLAGS("pool_check", CONF_FLAG_XLAT, rlm_sqlippool_t, pool_check) }, - { FR_CONF_OFFSET_FLAGS("update_begin", CONF_FLAG_XLAT, rlm_sqlippool_t, update_begin) }, - { FR_CONF_OFFSET_FLAGS("update_free", CONF_FLAG_XLAT, rlm_sqlippool_t, update_free) }, { FR_CONF_OFFSET_FLAGS("update_update", CONF_FLAG_XLAT, rlm_sqlippool_t, update_update) }, - { FR_CONF_OFFSET_FLAGS("update_commit", CONF_FLAG_XLAT, rlm_sqlippool_t, update_commit) }, - - - { FR_CONF_OFFSET_FLAGS("release_begin", CONF_FLAG_XLAT, rlm_sqlippool_t, release_begin) }, { FR_CONF_OFFSET_FLAGS("release_clear", CONF_FLAG_XLAT, rlm_sqlippool_t, release_clear) }, - { FR_CONF_OFFSET_FLAGS("release_commit", CONF_FLAG_XLAT, rlm_sqlippool_t, release_commit) }, - - - { FR_CONF_OFFSET_FLAGS("bulk_release_begin", CONF_FLAG_XLAT, rlm_sqlippool_t, bulk_release_begin) }, { FR_CONF_OFFSET_FLAGS("bulk_release_clear", CONF_FLAG_XLAT, rlm_sqlippool_t, bulk_release_clear) }, - { FR_CONF_OFFSET_FLAGS("bulk_release_commit", CONF_FLAG_XLAT, rlm_sqlippool_t, bulk_release_commit) }, - - - { FR_CONF_OFFSET_FLAGS("mark_begin", CONF_FLAG_XLAT, rlm_sqlippool_t, mark_begin) }, { FR_CONF_OFFSET_FLAGS("mark_update", CONF_FLAG_XLAT, rlm_sqlippool_t, mark_update) }, - { FR_CONF_OFFSET_FLAGS("mark_commit", CONF_FLAG_XLAT, rlm_sqlippool_t, mark_commit) }, - CONF_PARSER_TERMINATOR }; @@ -511,8 +487,6 @@ static unlang_action_t CC_HINT(nonnull) mod_update(rlm_rcode_t *p_result, module RESERVE_CONNECTION(handle, inst->sql->pool, request); - DO_PART(update_begin); - /* * An optional query which can be used to tidy up before updates * primarily intended for multi-server setups sharing a common database @@ -528,8 +502,6 @@ static unlang_action_t CC_HINT(nonnull) mod_update(rlm_rcode_t *p_result, module RETURN_MODULE_FAIL; } - DO_PART(update_commit); - if (handle) fr_pool_connection_release(inst->sql->pool, request, handle); if (affected > 0) { @@ -555,9 +527,7 @@ static unlang_action_t CC_HINT(nonnull) mod_release(rlm_rcode_t *p_result, modul RESERVE_CONNECTION(handle, inst->sql->pool, request); - DO_PART(release_begin); DO_PART(release_clear); - DO_PART(release_commit); if (handle) fr_pool_connection_release(inst->sql->pool, request, handle); RETURN_MODULE_OK; @@ -577,9 +547,7 @@ static unlang_action_t CC_HINT(nonnull) mod_bulk_release(rlm_rcode_t *p_result, RESERVE_CONNECTION(handle, inst->sql->pool, request); - DO_PART(bulk_release_begin); DO_PART(bulk_release_clear); - DO_PART(bulk_release_commit); if (handle) fr_pool_connection_release(inst->sql->pool, request, handle); RETURN_MODULE_OK; @@ -600,9 +568,7 @@ static unlang_action_t CC_HINT(nonnull) mod_mark(rlm_rcode_t *p_result, module_c RESERVE_CONNECTION(handle, inst->sql->pool, request); - DO_PART(mark_begin); DO_PART(mark_update); - DO_PART(mark_commit); if (handle) fr_pool_connection_release(inst->sql->pool, request, handle); RETURN_MODULE_OK;