-
-
Notifications
You must be signed in to change notification settings - Fork 262
Correction for passing zero-length SQL to trace #8745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correction for passing zero-length SQL to trace #8745
Conversation
|
I'm OK with the correction for master, but I'm not sure we can backport |
Done: #8748 |
src/jrd/trace/TraceDSQLHelpers.h
Outdated
| static const char empty_string[] = ""; | ||
| if (!string) | ||
| static constexpr std::string_view empty_string = "<empty statement>"; | ||
| if (m_string == nullptr || (m_string_len == 0 && (m_string_len = fb_strlen(m_string)) == 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this if wih attribution of m_string_len is very confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this option suitable (more code, but cleaner execution):
diff --git a/src/jrd/trace/TraceDSQLHelpers.h b/src/jrd/trace/TraceDSQLHelpers.h
index c8c2a230bf..a47d5aacca 100644
--- a/src/jrd/trace/TraceDSQLHelpers.h
+++ b/src/jrd/trace/TraceDSQLHelpers.h
@@ -55,11 +55,17 @@ public:
m_start_clock = fb_utils::query_performance_counter();
- static constexpr std::string_view empty_string = "<empty statement>";
- if (m_string == nullptr || (m_string_len == 0 && (m_string_len = fb_strlen(m_string)) == 0))
+ if (m_string == nullptr)
{
- m_string = empty_string.data();
- m_string_len = empty_string.length();
+ traceEmptyStatement();
+ }
+ else
+ {
+ if (m_string_len == 0)
+ m_string_len = fb_strlen(m_string);
+
+ if (m_string_len == 0)
+ traceEmptyStatement();
}
}
@@ -105,6 +111,13 @@ public:
}
private:
+ void traceEmptyStatement()
+ {
+ static constexpr std::string_view empty_string = "<empty statement>";
+ m_string = empty_string.data();
+ m_string_len = empty_string.length();
+ }
+
bool m_need_trace;
Attachment* m_attachment;
jrd_tra* const m_transaction;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this:
if (m_string == nullptr)
traceEmptyStatement();
else if (m_string_len == 0)
{
m_string_len = fb_strlen(m_string);
if (m_string_len == 0)
traceEmptyStatement();
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I applied these changes.
Postfix for #8738