Hi List,
Just a question to ask the list.
Alex posted these fixes to libraries/sqlparser.lib.php3:
@@ -171,6 +171,10 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
return $sql;
}
+ // rabus: Convert all line feeds to Unix style
+ $sql = str_replace("\r\n", "\n", $sql);
+ $sql = str_replace("\r", "\n", $sql);
+
$len = $GLOBALS['PMA_strlen']($sql);
if ($len == 0) {
return array();
This changes newline contents for the query before any parsing is done.
I think this should be avoided at this point, as it removes some newlines out of string escaped variables. Eg I might have
SELECT 'foo\n\r\n\rbar'; # foo, bar, sepereated by TWO lines we should actually preserve the contents of strings as they are.
If anybody can show me a testcase where we actually need this str_replace, then we can revise it, but I can't think of any, so in the name of speed, it should get removed.
@@ -227,7 +231,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
// ANSI style --
if (($c == '#')
|| (($count2 + 1 < $len) && ($c == '/') && ($sql[$count2 + 1] == '*'))
- || (($count2 + 2 < $len) && ($c == '-') && ($sql[$count2 + 1] == '-') && ($sql[$count2 + 2] == ' '))) {
+ || (($count2 + 2 < $len) && ($c == '-') && ($sql[$count2 + 1] == '-') && ereg("(\n|[space])", $sql[$count2 + 2]))) {
$count2++;
$pos = 0;
$type = 'bad';
Intend that it could match broken ANSI comments of '--\n' in addition to the standard '-- '.
Should we support this as it is partially supported by MySQL?
I say partially, because the MySQL commandline client strips out anything matching '--.*\n',
but the actualy MySQL server if it is sent raw commands throws a syntax error on '--\n'.
I would say that we should follow the MySQL server in handling the input.
If we do keep it, lets change it to use only direct comparisions instead of regular expressions.
Regex should be avoided inside the parser, as it makes code much slower.
--
Robin Hugh Johnson
E-Mail : robbat2(a)orbis-terrarum.net
Home Page : http://www.orbis-terrarum.net/?l=people.robbat2
ICQ# : 30269588 or 41961639
GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85