sqlfiddle
sqlfiddle copied to clipboard
Comments not working properly in Oracle, WebSQL
The -- coments don't work properly if the comment is not followed by a query: http://sqlfiddle.com/#!4/ee7da/3121 http://sqlfiddle.com/#!7/04eca/159 Or if the commented out line contains ";": http://sqlfiddle.com/#!4/ee7da/3122 http://sqlfiddle.com/#!7/04eca/160 It seems to work fine for other databases but I only tested one version of each.
Ah, yes this is because those comments are being executed by themselves. I may have to have a specific catch in there to handle this type of error. Thanks for the bug report!
Oh, it seems that I missed MySQL and it affects it as well. http://sqlfiddle.com/#!9/a2581/40 It also seems to give an error with c style comments for other db: http://sqlfiddle.com/#!1/6ccc5/878 So rather than catching error it would be great if the comments wouldn't be executed at all (that would also prevent empty results though those are rather a small thing).
MySQL apparently doesn't like -- style comments with no space between the dashes and the comment. Compare this fiddle to yours, for example:
http://sqlfiddle.com/#!9/a2581/59 (vs. http://sqlfiddle.com/#!9/a2581/40)
The PostgreSQL error, the other MySQL error, and the other "c style" errors in Oracle and SQLite were due to my "simple" (read: stupid) batch parsing logic. I check for a statement delimiter at the end of each newline and break the statement there. This includes within comments. So, compare the two pg fiddles:
Mine: http://sqlfiddle.com/#!1/6ccc5/1054 Yours: http://sqlfiddle.com/#!1/6ccc5/878
As much as I would like to have a smarter statement parser.... it's just not going to happen. Such a thing would require far too much analysis of the statement and knowledge of the particularities of the given database. As it stands, people will simply have to live with my stupid parser and deal with not having trailing semi-colons in their fiddles. I've tried to mitigate this problem by letting people choose another statement separator (the little [ ; ] button under each panel).
This leaves the problem with running statements which are nothing but a comment. This is something I think I can fix by catching the specific error.
Is pg 9.1.8 okay? I can't load the examples here or any else fiddle with it. Hmm...
There was some problem with it, not sure what. Restarting postgres fixed it. Thanks. (btw direct email might be easier if you see something like this again - admin at sqlfiddle dot com)