mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-21 01:01:02 +00:00
res_odbc: Add basic query logging.
When Asterisk is connected and used with a database the response time of the database can cause problems in Asterisk if it is long. Normally the only way to see this problem would be to retrieve a backtrace from Asterisk and examine where things are blocked, or examine the database to see if there is any indication of a problem. This change adds some basic query logging to make it easier to investigate such a problem. When logging is enabled res_odbc will now keep track of the number of queries executed, as well as the query that has taken the longest time to execute. There is also an option which will cause a WARNING message to be output if a query takes longer than a configurable amount of time to execute. This makes it easier and clearer for users that their database may be experiencing a problem that could impact Asterisk. ASTERISK-28277 Change-Id: I173cf4928b10754478a6a8c27dfa96ede0f058a6
This commit is contained in:
@@ -51,6 +51,7 @@ struct odbc_obj {
|
||||
char function[80];
|
||||
int lineno;
|
||||
#endif
|
||||
char *sql_text; /*!< The SQL text currently executing */
|
||||
AST_LIST_ENTRY(odbc_obj) list;
|
||||
};
|
||||
|
||||
@@ -160,6 +161,22 @@ SQLHSTMT ast_odbc_direct_execute(struct odbc_obj *obj, SQLHSTMT (*exec_cb)(struc
|
||||
*/
|
||||
SQLHSTMT ast_odbc_prepare_and_execute(struct odbc_obj *obj, SQLHSTMT (*prepare_cb)(struct odbc_obj *obj, void *data), void *data);
|
||||
|
||||
/*!
|
||||
* \brief Prepares a SQL query on a statement.
|
||||
* \param obj The ODBC object
|
||||
* \param stmt The statement
|
||||
* \parma sql The SQL query
|
||||
* \note This should be used in place of SQLPrepare
|
||||
*/
|
||||
int ast_odbc_prepare(struct odbc_obj *obj, SQLHSTMT *stmt, const char *sql);
|
||||
|
||||
/*! \brief Execute a nonprepared SQL query.
|
||||
* \param obj The ODBC object
|
||||
* \param sql The SQL query
|
||||
* \note This should be used in place of SQLExecDirect
|
||||
*/
|
||||
SQLRETURN ast_odbc_execute_sql(struct odbc_obj *obj, SQLHSTMT *stmt, const char *sql);
|
||||
|
||||
/*!
|
||||
* \brief Find or create an entry describing the table specified.
|
||||
* \param database Name of an ODBC class on which to query the table
|
||||
|
||||
Reference in New Issue
Block a user