Skip to content

Commit 16f670a

Browse files
NoremosArtyom Abakumov
andauthored
Correction for passing zero-length SQL to trace (#8748)
* Pass SQL with zero length in trace correctly * Add forgotten change * Calculate size only when empty sql is encountered * Use explicit way to update calculate SQL length --------- Co-authored-by: Artyom Abakumov <artyom.abakumov@red-soft.ru>
1 parent d92e2d8 commit 16f670a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/jrd/trace/TraceDSQLHelpers.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ class TraceDSQLPrepare
5353

5454
m_start_clock = fb_utils::query_performance_counter();
5555

56-
static const char empty_string[] = "";
57-
if (!string)
58-
{
59-
m_string = empty_string;
60-
m_string_len = 0;
61-
}
56+
if (m_string == nullptr)
57+
traceEmptyStatement();
6258
else if (m_string_len == 0)
59+
{
6360
m_string_len = fb_strlen(m_string);
61+
if (m_string_len == 0)
62+
traceEmptyStatement();
63+
}
6464
}
6565

6666
~TraceDSQLPrepare()
@@ -100,6 +100,15 @@ class TraceDSQLPrepare
100100
}
101101

102102
private:
103+
void traceEmptyStatement()
104+
{
105+
static constexpr const char* empty_string = "<empty statement>";
106+
static FB_SIZE_T empty_string_length = fb_strlen(empty_string);
107+
108+
m_string = empty_string;
109+
m_string_len = empty_string_length;
110+
}
111+
103112
bool m_need_trace;
104113
Attachment* m_attachment;
105114
jrd_tra* const m_transaction;

0 commit comments

Comments
 (0)