-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL-chunking algorithm may treat invalid SQL as a comment #14
Comments
It's funny - when I was reading this code while reviewing your earlier PR I was kind of surprised that there was no quote token in the list of tokens. I guess I just shrugged it off, but that seems to be the issue here. If you're willing to do the rock-paper-scissor upgrade then I say go for it. At some point this whole thing should get some attention, but it can probably stand up to a little bit more complexity before it needs to be gutted. It's your call. |
Nice diagram! This sounds good but I'm curious about a few things, some of which may be due to me misunderstanding the diagram so feel free to correct me. Does it handle the following:
Also, the goal of the original sql_prep is to replace certain parts of the SQL with their C equivalents (mostly comments) - is that represented here? How is that being handled? |
To address your points:
* I have added the self-transitions which should help to illustrate the behavior described. I had notated _some_ of them in the previous version of the diagram but omitted others. They should now all be present. Correct me if I'm wrong below... The goal of implementing the map of states and transitions – illustrated in my previous comment – should be to:
** I was leaning towards simply stripping out all the block _and_ single-line comments and not even giving them to ECPG; it seems slightly easier than doing a transformation on them _in some cases_ ( |
Yes. This sounds great. Thanks for updating the diagram - it's much more clear to me now. All of your plans look sound to me. I'll leave it up to you, but the reason I opted to convert -- to // was that I felt it left less room for error. However, finding the next \n and stripping the contents should be pretty easy to get right. Like I said - your call. I'm looking forward to seeing what you come up with! |
I forgot to state it in my commit-comment, but 46573e8 fixes this issue. |
Although I did end up stripping the contents of end-of-line
For that reason, I decided to leave block comments alone when preprocessing input so that any related errors can be correctly detected. |
At least on my own system, the following passes with exit-code 0:
Despite the fact the above statements should actually fail with something like:
No error is emitted because the statement is incorrectly prepared as:
I presume that ECPG just ignores everything after the first semicolon above, and therefore the invalid SQL in this example is simply not encountered.
I discovered this when I was trying to understand how the chunking algorithm did its thing, having wanted to grok it before trying to implement the ability to step over psql-commands.
More realistic instances similar to the above scenario likely exist under use of
$$
.Short of fully integrating a tokenizer to get around this, I could probably just up the rock-paper-scissors game that's already going on in
prepare_sql()
with theif not in_block_comment
business. Doing so should allow psql-stuff to be handled more readily.What's your take?
The text was updated successfully, but these errors were encountered: