Skip to content

Commit

Permalink
No need for begin / commit for independent UPDATE queries
Browse files Browse the repository at this point in the history
Whilst Oracle had these set to "COMMIT", queries are actually run with
OCI_COMMIT_ON_SUCCESS so no need for a separate COMMIT
  • Loading branch information
ndptech committed Feb 1, 2024
1 parent 60b4957 commit 70a49de
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
8 changes: 0 additions & 8 deletions raddb/mods-config/sql/ippool/oracle/queries.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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)
Expand All @@ -144,7 +142,6 @@ update_commit = "commit"
#
# Queries to release a lease
#
release_begin = "commit"
release_clear = "\
UPDATE ${ippool_table} \
SET gateway = '', \
Expand All @@ -153,7 +150,6 @@ release_clear = "\
WHERE pool_name = '%{control.${pool_name}}' \
AND owner = '${owner}' \
AND address = '${requested_address}'"
release_commit = "commit"

#
# DHCPv4 (Decline)
Expand All @@ -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)
Expand All @@ -179,12 +173,10 @@ mark_commit = "commit"
#
# Frees all IPs allocated to a gateway
#
bulk_release_begin = "commit"
bulk_release_clear = "\
UPDATE ${ippool_table} \
SET gateway = '', \
owner = '0', \
expiry_time = current_timestamp \
WHERE pool_name = '%{control.${pool_name}}' \
AND gateway = '${gateway}'"
bulk_release_commit = "commit"
34 changes: 0 additions & 34 deletions src/modules/rlm_sqlippool/rlm_sqlippool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand All @@ -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
};

Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 70a49de

Please sign in to comment.