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

No comments support #56

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi!
I got 20120507 source and tried to use comments /**/ in sql.
Error: Uncaught exception 'UnableToCalculatePositionException' with message 
'cannot calculate position of / within  /*Oplia!*/
Are You going to implement comments (for hints in SQL, or some commentation) in 
your parser?
Thank You!

Original issue reported on code.google.com by filtru...@gmail.com on 8 May 2012 at 11:44

GoogleCodeExporter commented 8 years ago
Can you provide a complete example? I know optimizer hints in Oracle SQL, but 
in MySQL?

Thank you
Andre

Original comment by pho...@gmx.de on 8 May 2012 at 12:21

GoogleCodeExporter commented 8 years ago
smth like this:
insert /* +APPEND */ into TableName (Col1,col2) values(1,'pol')
the above one should add a new string at the bottom of the table, not using a 
fragmented free space. In Case we insert a sufficiently big bunch of data (like 
200MB) in 2*10^5 inserts, such hints would save us >50% of CPU and IO and Time. 
That would go for Oracle.
Eg:
SELECT * FROM table1 IGNORE INDEX (Four_Column_index) USE INDEX 
(One_Column_index) WHERE Boolean_Included_In_Large_Index is true;
Would go for MySql 
http://dev.mysql.com/doc/refman/5.0/en/index-hints.html
And would save us from walking on index, which size is close to table size, and 
prefer a ten times smaller index.
As well, MySql optimyser hints like /*! SQL_NO_CACHE */ or /*! LOW_PRIORITY */ 
or any of them.

Original comment by filtru...@gmail.com on 8 May 2012 at 12:47

GoogleCodeExporter commented 8 years ago
Forgot to mention, that in Mysql you can skip /* */ comment brackets, but then 
the code gets dependent to Mysql Optimiser. When using comment brackets will 
allow you to make cross db SQL statements - the optimiser will just skip 
unknown HINTS
Thank you!

Original comment by filtru...@gmail.com on 8 May 2012 at 12:51

GoogleCodeExporter commented 8 years ago
Thanks for the example, I'll what I can do. I change the issue to 
"enhancement". In the latest trunk I have changed the lexer a bit, so it 
handles comments as one token. Maybe it solves some problems till I have 
enhanced the parser.

Original comment by pho...@gmx.de on 8 May 2012 at 2:26

GoogleCodeExporter commented 8 years ago
Also it looks like the parser does not parse line sql comments properly, i.e. 
with query like:

SELECT --comment
* 
FROM 
-- comment
table

parse with positions throws exception, and without positions generates very 
strange parse tree. 

Original comment by smalys...@gmail.com on 13 Jun 2012 at 12:59

GoogleCodeExporter commented 8 years ago
I am running into similar issues with comments.  For example, the below query 
is not parsed correctly.  The "-- my comment" is being parsed as a column alias.

SELECT
user.host -- my comment
FROM mysql.user

Original comment by ryan.bro...@gmail.com on 29 Jul 2014 at 10:40

GoogleCodeExporter commented 8 years ago
Issue 146 has been merged into this issue.

Original comment by pho...@gmx.de on 15 Sep 2014 at 10:41