Skip to content

Commit

Permalink
[CBRD-24682] Fix error handling problem caused by CBRD-24585 (CUBRID#…
Browse files Browse the repository at this point in the history
…4147)

http://jira.cubrid.org/browse/CBRD-24682

- Set error contexts in prepare() and execute() functions correctly.
- In execute(), setting error should be done again after ER_QPROC_INVALID_XASLNODE is handled.
- Remove redundant setting error context after db_execute_and_keep_statement ().
  • Loading branch information
hgryoo authored Mar 6, 2023
1 parent 08ac06f commit acb0f0e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
31 changes: 22 additions & 9 deletions src/method/method_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,16 @@ namespace cubmethod
}
else
{
if (handler->prepare (sql, flag) == NO_ERROR)
int error = handler->prepare (sql, flag);
if (error == NO_ERROR)
{
// add to statement handler cache
m_sql_handler_map.emplace (sql, handler->get_id ());
}
else
{
m_error_ctx.set_error (db_error_code (), db_error_string (1), __FILE__, __LINE__);
}
}
}

Expand Down Expand Up @@ -161,8 +166,8 @@ namespace cubmethod
if (handler == nullptr)
{
// TODO: proper error code
m_error_ctx.set_error (METHOD_CALLBACK_ER_NO_MORE_MEMORY, NULL, __FILE__, __LINE__);
return ER_FAILED;
m_error_ctx.set_error (METHOD_CALLBACK_ER_INTERNAL, NULL, __FILE__, __LINE__);
assert (false); // the error should have been handled in prepare function
}
else
{
Expand All @@ -180,14 +185,22 @@ namespace cubmethod
else
{
/* XASL cache is not found */
m_error_ctx.clear ();
handler->prepare_retry ();
handler->execute (request);
if (error == ER_QPROC_INVALID_XASLNODE)
{
m_error_ctx.clear ();
handler->prepare_retry ();
error = handler->execute (request);
}

if (error != NO_ERROR)
{
m_error_ctx.set_error (db_error_code (), db_error_string (1), __FILE__, __LINE__);
}
}
}

/* DDL audit */
logddl_write_end ();
/* DDL audit */
logddl_write_end ();
}

if (m_error_ctx.has_error())
{
Expand Down
1 change: 0 additions & 1 deletion src/method/method_query_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ namespace cubmethod
int n = db_execute_and_keep_statement (m_session, stmt_id, &result);
if (n < 0)
{
m_error_ctx.set_error (n, NULL, __FILE__, __LINE__);
return ER_FAILED;
}
else if (result != NULL)
Expand Down

0 comments on commit acb0f0e

Please sign in to comment.