Bug #44772 TRUNCATE TABLE is reported as "TK_LITERAL TK_SQL_TABLE" by the tokenizer
Submitted: 11 May 2009 2:44 Modified: 6 Jul 2010 13:32
Reporter: Diego Medina Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Agent Severity:S3 (Non-critical)
Version:2.1.0.1036 OS:Any
Assigned to: Jan Kneschke CPU Architecture:Any

[11 May 2009 2:44] Diego Medina
Description:
If you send a TRUNCATE query through the proxy, and try to use the tokenizer, you will not get a TK_SQL_TRUNCATE

See related bug http://bugs.mysql.com/bug.php?id=36277

How to repeat:
1- Start the MySQL Proxy using the tutorial file tutorial-tokenize.lua
2- Send this query

TRUNCATE TABLE t1;
3- See the output on the terminal where you started the mysql proxy

Suggested fix:
Add it to lib/sql-tokenizer.c
[17 Jun 2009 17:15] Jan Kneschke
TRUNCATE is not a token.

  CREATE TABLE truncate ( id INT ); 

is valid SQL.

The tokenizer doesn't have the information to seperate one from the other. An upper layer/parser should take care of the positional behaviour.
[17 Jun 2009 17:17] Jan Kneschke
This bug is a duplicate of http://bugs.mysql.com/bug.php?id=36277
[17 Jun 2009 17:42] Diego Medina
When running these queries through the query analyzer:

truncate table t1;

you will see on the dashboard:

truncate TABLE t1

(note how truncate is not in capital letters)
[6 May 2010 15:04] Jan Kneschke
Fixed for 2.2.x as part of

revno: 1849
committer: jan@mysql.com
branch nick: trunk
timestamp: Thu 2010-05-06 16:49:38 +0200
message:
  added DO *, LOAD XML ... and the HANDLER stmts as pseudo-SQL-keywords
------------------------------------------------------------
revno: 1848
fixes bug(s): http://bugs.mysql.com/53419
committer: jan@mysql.com
branch nick: trunk
timestamp: Thu 2010-05-06 15:59:41 +0200
message:
  upper-case some common pseudo-SQL-keywords (fixes #53419/EM-4470 and #44772)
  
    * commit, rollback
    * CREATE temporary TABLE
    * truncate TABLE
    * LOAD data INFILE
------------------------------------------------------------
revno: 1847
fixes bug(s): http://bugs.mysql.com/53425
committer: jan@mysql.com
branch nick: trunk
timestamp: Wed 2010-05-05 10:16:08 +0200
message:
  added more unit-tests for query-type (for #53425/EM-4471)
------------------------------------------------------------
revno: 1846
committer: jan@mysql.com
branch nick: trunk
timestamp: Tue 2010-05-04 15:35:05 +0200
message:
  added the old 'quan.lua' test from the 2.1 tree back as t_normalize.lua
[6 Jul 2010 12:45] Enterprise Tools JIRA Robot
Diego Medina writes: 
Verified fixed on 2.2.2.1727
[6 Jul 2010 13:32] MC Brown
A note has been added to the 2.2.2 changelog: 

A <literal>TRUNCATE TABLE</literal> statement could be
mis-identified in the tokenizer.