# function.
# auto_escape = no
+ # When the SQL module is called in accounting and post-auth one or
+ # more queries may be run, until at least one record is updated.
+ #
+ # It can be helpful to know which query was run. E.g. the default
+ # queries for Interim-Update handling, start with an UPDATE and
+ # if that does not update any records, an INSERT is run. Knowing
+ # which query updated data indicates the state of the data prior
+ # to the update.
+ #
+ # Setting this to 'yes', will cause `&control:SQL-Query-Number` to be
+ # populated with the number of the query which updated data.
+# record_query_number = no
+
# Read database-specific queries
$INCLUDE ${modconfdir}/${.:name}/main/${dialect}/queries.conf
}
# X99-Fast 1077 integer
ATTRIBUTE Rewrite-Rule 1078 string
# SQL-Group is now dynamically created
+ATTRIBUTE SQL-Query-Number 1079 integer
ATTRIBUTE Response-Packet-Type 1080 integer virtual
ATTRIBUTE Digest-HA1 1081 string
ATTRIBUTE MS-CHAP-Use-NTLM-Auth 1082 integer
{ "safe-characters", FR_CONF_OFFSET(PW_TYPE_STRING | PW_TYPE_DEPRECATED, rlm_sql_config_t, allowed_chars), NULL },
{ "safe_characters", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_sql_config_t, allowed_chars), "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /" },
{ "auto_escape", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sql_config_t, driver_specific_escape), "no" },
+ { "record_query_number", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_sql_config_t, record_query_number), "no" },
/*
* This only works for a few drivers.
rlm_sql_handle_t *handle = NULL;
int sql_ret;
int numaffected = 0;
+ int query_number = 1;
CONF_ITEM *item;
CONF_PAIR *pair;
(inst->module->sql_finish_query)(handle, inst->config);
RDEBUG("%i record(s) updated", numaffected);
- if (numaffected > 0) break; /* A query succeeded, we're done! */
+ if (numaffected > 0) {
+ if (inst->config->record_query_number) {
+ VALUE_PAIR *vp = fr_pair_find_by_num(request->config, PW_SQL_QUERY_NUMBER, 0, 0);
+ if (!vp) vp = radius_pair_create(request, &request->config, PW_SQL_QUERY_NUMBER, 0);
+ vp->vp_integer = query_number;
+ }
+ break; /* A query succeeded, we're done! */
+ }
next:
/*
* We assume all entries with the same name form a redundant
goto finish;
}
+ query_number ++;
RDEBUG("Trying next query...");
}
//!< a fake stop packet, to terminate any
//!< stale sessions.
+ bool record_query_number; //!< Whether we should populate SQL-Query-Number
+ ///< when an "acct_redundant" query succeeds
+
char const *allowed_chars; //!< Chars which done need escaping..
bool driver_specific_escape; //!< Use the driver specific SQL escape method
uint32_t query_timeout; //!< How long to allow queries to run for.