This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch odbc_logmessage_fix
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 476d9369956ca13f2b9169c98274a5115216491f
Author: Robert Middleton <[email protected]>
AuthorDate: Tue May 2 22:52:58 2023 -0400

    Column mappings are required to insert messages
---
 src/main/cpp/odbcappender.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp
index f6f93158..0f10aefa 100644
--- a/src/main/cpp/odbcappender.cpp
+++ b/src/main/cpp/odbcappender.cpp
@@ -200,6 +200,9 @@ void ODBCAppender::activateOptions(log4cxx::helpers::Pool&)
 #if !LOG4CXX_HAVE_ODBC
        LogLog::error(LOG4CXX_STR("Can not activate ODBCAppender unless 
compiled with ODBC support."));
 #else
+    if(_priv->mappedName.size() == 0){
+        LogLog::error("No column mappings have been defined, messages cannot 
be inserted");
+    }
        auto specs = getFormatSpecifiers();
        for (auto& name : _priv->mappedName)
        {
@@ -623,12 +626,11 @@ void ODBCAppender::flushBuffer(Pool& p)
                                        throw SQLException(SQL_HANDLE_STMT, 
_priv->preparedStatement, "Failed to execute prepared statement", p);
                                }
 #endif
-                       }
-                       else
-                       {
-                               auto sql = getLogStatement(logEvent, p);
-                               execute(sql, p);
-                       }
+            }
+            else
+            {
+                _priv->errorHandler->error(LOG4CXX_STR("No colum mappings 
defined"));
+            }
                }
                catch (SQLException& e)
                {

Reply via email to