mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
extconfig: Allow explicit DB result set ordering to be disabled.
Added a new boolean configuration flag - `order_multi_row_results_by_initial_column` - to both res_pgsql.conf and res_config_odbc.conf that allows the administrator to disable the explicit `ORDER BY` that was previously being added to all generated SQL statements that returned multiple rows. Fixes: #179
This commit is contained in:
@@ -82,6 +82,7 @@ static char dbappname[MAX_DB_OPTION_SIZE] = "";
|
||||
static char dbsock[MAX_DB_OPTION_SIZE] = "";
|
||||
static int dbport = 5432;
|
||||
static time_t connect_time = 0;
|
||||
static int order_multi_row_results_by_initial_column = 1;
|
||||
|
||||
static int parse_config(int reload);
|
||||
static int pgsql_reconnect(const char *database);
|
||||
@@ -624,7 +625,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
|
||||
ast_str_append(&sql, 0, " AND %s%s '%s'%s", field->name, op, ast_str_buffer(escapebuf), escape);
|
||||
}
|
||||
|
||||
if (initfield) {
|
||||
if (initfield && order_multi_row_results_by_initial_column) {
|
||||
ast_str_append(&sql, 0, " ORDER BY %s", initfield);
|
||||
}
|
||||
|
||||
@@ -1524,6 +1525,10 @@ static int parse_config(int is_reload)
|
||||
requirements = RQ_CREATECHAR;
|
||||
}
|
||||
|
||||
/* Result set ordering is enabled by default */
|
||||
s = ast_variable_retrieve(config, "general", "order_multi_row_results_by_initial_column");
|
||||
order_multi_row_results_by_initial_column = !s || ast_true(s);
|
||||
|
||||
ast_config_destroy(config);
|
||||
|
||||
if (DEBUG_ATLEAST(1)) {
|
||||
|
Reference in New Issue
Block a user