Bug #36506 Proxy quits with a failed assertion when feeding it incomplete queries
Submitted: 5 May 2008 13:44 Modified: 3 Jun 2009 16:20
Reporter: Maarten Sander (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Proxy: Core Severity:S2 (Serious)
Version:0.6.1 OS:Linux (Debian Lenny - Linux 2.6.16-1-em64t-p4-smp)
Assigned to: Kay Roepke CPU Architecture:Any
Tags: mysql-proxy, sql-tokenizer.l

[5 May 2008 13:44] Maarten Sander
Description:
When passing a query with an unterminated string to the proxy, it quits with the following message:

  file sql-tokenizer.l: line 402 (sql_token_append_last_token): assertion failed:
(tokens->len > 0)

This only happens with 'bad' queries, in which case the MySQL server would have responded with something like:

  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'baz')' at line 1

How to repeat:
Execute a bad query twice in a row:
1) REPLACE INTO foo VALUES ('bar'baz')
2) REPLACE INTO foo VALUES ('bar'baz')
[5 May 2008 13:45] Maarten Sander
Test case.

Attachment: test.php (application/x-httpd-php, text), 231 bytes.

[5 May 2008 13:45] Maarten Sander
MySQL Proxy output for test.php

Attachment: test.out (application/octet-stream, text), 1.48 KiB.

[7 May 2008 9:21] Jan De Poorter
We see this behaviour too on a production machine. (Client does some rather strange SQL queries)
[7 May 2008 9:23] Jan De Poorter
Forgot to mention:

We are still on version 0.6.0 from debian backports (0.6.0-1~bpo40+1).
[13 May 2008 18:02] Kay Roepke
Some types of bad queries leave the flex based tokenizer in a bad state.
This can occur with unterminated strings or comments like

SELECT "foo

and

SELECT /* foo
[14 May 2008 10:39] Kay Roepke
fixed in revision 666
[26 Sep 2008 9:03] Sveta Smirnova
Bug #38340 was marked as duplicate of this one.
[3 Jun 2009 16:20] Kay Roepke
fixed in version 0.7.1