<table><tr><td style="">jfita created this revision.<br />jfita added reviewers: staniek, piggz.<br />Herald added a project: KDb.<br />Herald added a subscriber: Kexi-Devel-list.<br />jfita requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D29327">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Currently, the parse error message for a query like</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">SELECT select #1/1a/2020#;</pre></div>

<p>is</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">org.kde.kdb.core: Parse error: tokens left globalCurrentPos: 18 sql.length(): 19 globalToken: ";"
org.kde.kdb.core: error:
org.kde.kdb.core: at character  18  near tooken  ";"</pre></div>

<p>and Kexi, in SQL text mode, moves the cursor next to the semicolon.</p>

<p>The query is indeed incorrect, but the error message is misleading<br />
because the error is in the “a” within the date literal, not the<br />
terminating semicolon.</p>

<p>This is due the lack of a “fallback” rule within the DATE_OR_TIME start<br />
condition and, because it is an exclusive condition, Flex provides its<br />
default rule that returns nothing to the parser. Therefore, the<br />
globalCurrentPos is not incremented and, at the end, KDbParser can<br />
detect something went wrong, but can not pinpoint the error’s correct<br />
location at that stage.</p>

<p>I added a new rule that simply returns any other non-recognized<br />
character to the parser so that it can detect the erroneous input and<br />
present a more accurate position of where the error is. With that change<br />
Kexi moves the cursor next to the “a”.</p>

<p>I also changed the last rule of the INITIAL start condition to match any<br />
character, because otherwise it also reports the error at the position<br />
of the semicolon in queries like the following:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">SELECT 1' FROM input;</pre></div>

<p>There was, however, another issue with Flex’s action for its default<br />
rule: it calls the ECHO macro that, by default, is defined as write the<br />
matched input to stdout.</p>

<p>This is not a problem for Kexi — in fact, i am unable to see that write<br />
in the console —, but it messes up the output of SqlParseTest. This is<br />
particularly important when called with the ‘-xml’ or ‘-tap’ parameters,<br />
that need to maintain their strict format or then QtCreator or Perl’s<br />
prove can not parse the output.</p>

<p>FIXED-IN:3.2.1</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R15 KDb</div></div></div><br /><div><strong>BRANCH</strong><div><div>3.2</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D29327">https://phabricator.kde.org/D29327</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/parser/KDbSqlScanner.l<br />
src/parser/generated/sqlscanner.cpp</div></div></div><br /><div><strong>To: </strong>jfita, staniek, piggz<br /><strong>Cc: </strong>Kexi-Devel-list, barman, wicik, staniek<br /></div>