Skip to content

Commit c50923c

Browse files
committed
unify sphinxql log error
2 parallel functions are error-prone, let's use just one.
1 parent e76545e commit c50923c

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/daemon/logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ class LogStmtGuard_c
8181

8282
// used by Buddy
8383
enum class BuddyQuery_e : BYTE { SQL, HTTP };
84-
void LogSphinxqlError ( const char * sStmt, const Str_t & sError );
84+
void LogSphinxqlError ( const char * szStmt, const Str_t & sError );
8585
void LogSphinxqlError ( const Str_t & sStmt, const Str_t & sError );
8686
void LogBuddyQuery ( Str_t sQuery, BuddyQuery_e tType );

src/daemon/query_log.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -759,28 +759,20 @@ void LogQuery ( const CSphQuery & q, const CSphQuery & tJoinOptions, const CSphQ
759759
}
760760
}
761761

762-
void LogSphinxqlError ( const char * sStmt, const Str_t & sError )
762+
void LogSphinxqlError ( const char * szStmt, const Str_t & sError )
763763
{
764-
if ( g_eLogFormat != LOG_FORMAT::SPHINXQL || g_iQueryLogFile < 0 || !sStmt || IsEmpty ( sError ) )
765-
return;
766-
767-
// some mysql cli, like mysql 9.0.1, 9.1.0, 9.3.0, may be others, fire 'select $$' query after connect
768-
// that produces some noise in query log, so let's just filter out these queries. #2772
769-
if ( !strcmp (sStmt, "select $$") )
770-
return;
771-
772-
StringBuilder_c tBuf;
773-
tBuf << "/* ";
774-
FormatTimeConnClient ( tBuf );
775-
tBuf << " */ " << sStmt << " # error=" << sError << '\n';
776-
777-
WriteQuery ( tBuf );
764+
LogSphinxqlError ( FromSz ( szStmt ), sError );
778765
}
779766

780-
781767
void LogSphinxqlError ( const Str_t & sStmt, const Str_t & sError )
782768
{
783-
if ( g_eLogFormat != LOG_FORMAT::SPHINXQL || g_iQueryLogFile < 0 || IsEmpty ( sStmt ) || IsEmpty ( sError ) )
769+
if ( g_eLogFormat != LOG_FORMAT::SPHINXQL || g_iQueryLogFile < 0 || !IsFilled ( sStmt ) || IsEmpty ( sError ) )
770+
return;
771+
772+
// some mysql cli, like mysql 9.0.1, 9.1.0, 9.3.0, may be others, fire 'select $$' query after connect
773+
// that produces some noise in query log, so let's just filter out these queries. #2772
774+
constexpr Str_t selectSS = FROMS("select $$");
775+
if ( sStmt.second==selectSS.second && !strncmp (sStmt.first, selectSS.first, selectSS.second) )
784776
return;
785777

786778
QuotationEscapedBuilder tBuf;

0 commit comments

Comments
 (0)