From 708b69abede2ae1f675754cf427f2bf71df766af Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 13 Jul 2017 08:18:20 +0300 Subject: [PATCH] Using lexer: better error messages [#CLICKHOUSE-2]. --- dbms/src/Parsers/parseQuery.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/dbms/src/Parsers/parseQuery.cpp b/dbms/src/Parsers/parseQuery.cpp index fc3eecf9bf8..f3d79e98477 100644 --- a/dbms/src/Parsers/parseQuery.cpp +++ b/dbms/src/Parsers/parseQuery.cpp @@ -76,13 +76,21 @@ void writeQueryWithHighlightedErrorPositions( const char * current_position_to_hilite = positions_to_hilite[position_to_hilite_idx]; out.write(pos, current_position_to_hilite - pos); - size_t bytes_to_hilite = UTF8::seqLength(*current_position_to_hilite); + if (current_position_to_hilite == end) + { + out << "\033[41;1m \033[0m"; + pos = end; + } + else + { + size_t bytes_to_hilite = UTF8::seqLength(*current_position_to_hilite); - /// Bright on red background. - out << "\033[41;1m"; - out.write(current_position_to_hilite, bytes_to_hilite); - out << "\033[0m"; - pos = current_position_to_hilite + bytes_to_hilite; + /// Bright on red background. + out << "\033[41;1m"; + out.write(current_position_to_hilite, bytes_to_hilite); + out << "\033[0m"; + pos = current_position_to_hilite + bytes_to_hilite; + } } out.write(pos, end - pos); }