Skip to content

Commit e1afda2

Browse files
committed
OTel: Fix the way statements without result sets are detected.
Note: rowsCount() can not be called for certain types of results (forward only). Also, we don't want to count all rows of a potentially huge row set here.
1 parent 5bca406 commit e1afda2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

jdbc/driver/mysql_statement.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ MySQL_Statement::do_query(const ::sql::SQLString &q)
120120

121121
sql::mysql::util::throwSQLException(*proxy_p.get());
122122
}
123+
124+
// Note: If statement has no results then we close the span here, otherwise
125+
// it will be closed after reading all result sets.
126+
127+
if ((0 == proxy_p->field_count()) && !proxy_p->more_results())
128+
telemetry.span_end(this);
123129
}
124130
catch(sql::SQLException &e)
125131
{
@@ -243,11 +249,6 @@ try
243249
logger
244250
);
245251
CPP_INFO_FMT("rset=%p", tmp);
246-
if (tmp->isClosed() || tmp->rowsCount() == 0)
247-
{
248-
// Close span if the result set is closed or empty
249-
telemetry.span_end(this);
250-
}
251252
return tmp;
252253
}
253254
catch (sql::SQLException &e)

0 commit comments

Comments
 (0)