[Phpmyadmin-devel] New SQL Parser - now mostly complete

Marc Delisle Delislma at CollegeSherbrooke.qc.ca
Fri Jun 21 06:51:07 CEST 2002


Robin,

very cool!

Robin Johnson wrote:

> Hi List,
> 
> The new SQL parser is functional now, and very capable as well as fast.
> Again I am looking for hints and ideas about PHP3 incompatibilites if
> there are any in my code (I'm not sure).


If nobody can test it under PHP3 before 2.3.0-final,I would say: just 
check the PHP version and do not parse if < PHP4, because PHP3 users can 
live without coloring :)


> 
> http://games.techbc.ca/~robbat2/sqlparse.php
> 
> If there is some long and convoluted but still valid query that you want
> me to test my code on, please send it my way. Check out the LARGE_* query
> tests before you do though.


You made a good test case, and I would not be afraid to merge this code, 
  so that masses of users can test convoluted queries on it :)

But can you


> 
> I'd like suggestions on how to make it even faster on the huge query sets,
> like the SQL_MS_SQL* tests that I have in the test harness.
> 
> The current code now uses absoltely NO Regex or PCRE functions, and does
> nearly everything via strings with a few arrays.
> 
> I'd also like suggestions on what we want the indenting to look like, so
> that I can code it in as well. Any specific preferences?


This is only a suggestion (for future versions?): when I look your 
FUNC_1 test, the raw version, I see

  SELECT job,dept.loc,AVG(sal)
    FROM emp,dept
    WHERE dept.deptno=emp.deptno
    GROUP BY dept.loc,job
    ORDER BY 3

and this is exactly the way I like to code my queries.

Now, I would like to see the color output formatted like the raw 
version, only with colors added.  A newline after each major sections of 
a SELECT.

The same thing applies to an insert:
start the VALUES on a new line, and put each record on a different line.


> 
> The only thing that remains in my code is more SQL validator, which is
> mainly for the structure, like missing brackets/quotes etc. I don't think
> I will do validation of the keywords or number of function arguments.
> 
> 


-- 
Marc Delisle






More information about the Developers mailing list