chenster / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

parser dies when calculating position of _utf8 #50

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. execute this code :

$parser = new PHPSQLParser();

$sql = "SELECT _utf8'hi'";
$parser->parse($sql, true);

2. script dies with this message :

cannot calculate position of _utf8 within  _utf8'hi'

What is the expected output? What do you see instead?

Expected the parser to return an array with one element in the SELECT array.

What version of the product are you using? On what operating system?

rev 235 on windows 7.

Please provide any additional information below.

failing test case :
-----------

<?php
require_once(dirname(__FILE__) . '/../../../php-sql-parser.php');
require_once(dirname(__FILE__) . '/../../test-more.php');

$parser = new PHPSQLParser();

$sql = "SELECT _utf8'hi'";
$parser->parse($sql, true);
$p = $parser->parsed;

$expected = getExpectedValue(dirname(__FILE__), 'issue50.serialized');
eq_array($p, $expected, 'does not die if query contains _utf8 construct');

Original issue reported on code.google.com by nderm...@adequasys.com on 24 Apr 2012 at 9:31

GoogleCodeExporter commented 8 years ago
The error occurs, because the parser sets _utf8  as colref and 'hi' as 
constant. There is a rule on the position calculator, which doesn't await a ' 
right after a column reference. At the moment the parser cannot handle charsets.

Original comment by pho...@gmx.de on 26 Apr 2012 at 7:03

GoogleCodeExporter commented 8 years ago
I have changed the type to enhancement.

Original comment by pho...@gmx.de on 30 Apr 2012 at 7:40

GoogleCodeExporter commented 8 years ago
some useful information
http://dev.mysql.com/doc/refman/5.6/en/charset-literal.html

Original comment by pho...@gmx.de on 1 Jun 2012 at 7:24