提交 7e28946b authored 作者: Eliot Gable's avatar Eliot Gable

Make error message slightly more verbose.

上级 3dec8fb4
...@@ -607,6 +607,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t ...@@ -607,6 +607,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
char *errmsg = NULL; char *errmsg = NULL;
char *tmp = NULL; char *tmp = NULL;
char *type = NULL;
switch_mutex_t *io_mutex = dbh->io_mutex; switch_mutex_t *io_mutex = dbh->io_mutex;
if (io_mutex) switch_mutex_lock(io_mutex); if (io_mutex) switch_mutex_lock(io_mutex);
...@@ -618,17 +619,20 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t ...@@ -618,17 +619,20 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
switch (dbh->type) { switch (dbh->type) {
case SCDB_TYPE_PGSQL: case SCDB_TYPE_PGSQL:
{ {
type = "PGSQL";
status = switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, sql, &errmsg); status = switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, sql, &errmsg);
} }
break; break;
case SCDB_TYPE_ODBC: case SCDB_TYPE_ODBC:
{ {
type = "ODBC";
status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, NULL, &errmsg); status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, NULL, &errmsg);
} }
break; break;
case SCDB_TYPE_CORE_DB: case SCDB_TYPE_CORE_DB:
{ {
int ret = switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, NULL, NULL, &errmsg); int ret = switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, NULL, NULL, &errmsg);
type = "NATIVE";
if (ret == SWITCH_CORE_DB_OK) { if (ret == SWITCH_CORE_DB_OK) {
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
...@@ -645,7 +649,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t ...@@ -645,7 +649,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
if (errmsg) { if (errmsg) {
if (!switch_stristr("already exists", errmsg) && !switch_stristr("duplicate key name", errmsg)) { if (!switch_stristr("already exists", errmsg) && !switch_stristr("duplicate key name", errmsg)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n%s\n", errmsg, sql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s SQL ERR [%s]\n%s\n", (type ? type : "Unknown"), errmsg, sql);
} }
if (err) { if (err) {
*err = errmsg; *err = errmsg;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论