Permalink
Browse files

fixed #590 cut SphinxQL error message larger 512 chars

  • Loading branch information...
tomatolog committed Dec 17, 2018
1 parent 6362881 commit 8868b207644f4f8cc1ab0c270adb35493fed22e1
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/searchd.cpp
@@ -11532,6 +11532,8 @@ enum MysqlColumnFlag_e
MYSQL_COL_UNSIGNED_FLAG = 32
};

#define SPH_MYSQL_ERROR_MAX_LENGTH 512

void SendMysqlErrorPacket ( ISphOutputBuffer & tOut, BYTE uPacketID, const char * sStmt,
const char * sError, int iCID, MysqlErrors_e iErr )
{
@@ -11541,6 +11543,17 @@ void SendMysqlErrorPacket ( ISphOutputBuffer & tOut, BYTE uPacketID, const char
LogSphinxqlError ( sStmt, sError, iCID );

int iErrorLen = strlen(sError)+1; // including the trailing zero

// cut the error message to fix isseue with long message for popular clients
if ( iErrorLen>SPH_MYSQL_ERROR_MAX_LENGTH )
{
iErrorLen = SPH_MYSQL_ERROR_MAX_LENGTH;
char * sErr = const_cast<char *>( sError );
sErr[iErrorLen-3] = '.';
sErr[iErrorLen-2] = '.';
sErr[iErrorLen-1] = '.';
sErr[iErrorLen] = '\0';
}
int iLen = 9 + iErrorLen;
int iError = iErr; // pretend to be mysql syntax error for now

default:
// default case, unknown command
sError.SetSprintf ( "unknown command (code=%d)", uMysqlCmd );
SendMysqlErrorPacket ( tOut, uPacketID, NULL, sError.cstr(), tThd.m_iConnID, MYSQL_ERR_UNKNOWN_COM_ERROR );
SendMysqlErrorPacket ( tOut, uPacketID, NULL, sError.cstr(), tThd.m_iConnID, MYSQL_ERR_UNKNOWN_COM_ERROR );
break;
}

0 comments on commit 8868b20

Please sign in to comment.