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
Incomprehensible error messages for ROWS [CORE1088] #1509
Comments
Modified by: @pcisarWorkflow: jira [ 11501 ] => Firebird [ 15488 ] |
Commented by: @jasonwharton I was able to see this error in my regression testing app for IB Objects. Here is my setup: CREATE TABLE COUNT_TEST ( // Populate with 1001 rows from ID 0 to 1000.
// Executing this query seems fine: SELECT ID, COL1, COL2 // Executing this query reliably reproduces this undesirable message: SELECT ID, COL1, COL2 This is an excerpt from the IBO SQL trace showing the error when the query is executed: /*--- SELECT ID, COL1, COL2 FROM COUNT_TEST ROWS 200 TO 100 PLAN (COUNT_TEST NATURAL) FIELDS = [ Version 1 SQLd 3 SQLn 30 ERRCODE = 335544817 ISC ERROR MESSAGE: STATEMENT: //>>> SQL MESSAGE <<<// SQL ERROR MESSAGE: |
Commented by: @jasonwharton Also, it seems this bug entry is addressing the confusing nature of the error message. I'd like to hear from someone to acknowledge this and let me know what can/should be done about it. |
Commented by: @dyemanov I respectfully disagree regarding the "valid SQL". ROWS 200 TO 100 is a confusing construct. You expect it to return zero rows, someone else might expect it to return 100 rows in the reverse order starting with 200th row. The one who knows that it's just a syntax sugar for FIRST/SKIP understands it as -100 rows to be returned and both Firebird and the SQL standard treats negative values there as an error condition. ROWS 2 TO 1 works incidentally, because it's transformed to FIRST 0 SKIP 1 and zero rows filter is allowed. This is just an implementation artefact that should not be treated as a common rule. |
Commented by: @jasonwharton Of course a person isn't going to write such a query adhoc, but that isn't the only situation to be dealt with. For example, in code I rely upon the fact that such a condition will result in zero iterations in a for loop. It should simply evaluate what is there and return zero records just as it does with the other example that doesn't complain. What you are saying is that C++ or Delphi should raise a runtime exception if someone passes in such a situation to a for loop and that simply is not practical. Code becomes really messy to have to guard against such a situation when the simplest and most logical thing to do is to simply move on quietly with no action. |
Commented by: @dyemanov Unlike C++/Delphi, SQL is a declarative language, and SELECT is not a loop. They cannot be compared directly. |
Commented by: @jasonwharton I respectfully disagree with your ultimate conclusion to do nothing about this issue. I would much prefer a practical and common sense implementation than a complicated mess such as now exists. Quietly returning zero records is the best answer and thankfully that is what InterBase does. They got this one right. |
Commented by: @dyemanov I don't ultimately object to change the current behavior, but I don't agree in treating this issue as a showstopper. Your InterBase argument sounds important though. One of the reasons behind the ROWS syntax was the InterBase compatibility, so complying with their semantics might be a good idea. |
Commented by: @jasonwharton Apologies if I assumed you intended to do nothing about it. I also agree this doesn't merit "showstopper" status. Perhaps Minor importance is fine. Thus, we are back to my original question. Do we associate further with this misleading error message issue or should I go ahead and post a new issue that focuses on this more specific issue of not having the same behavior as exists with the InterBase handling of the ROWS clause? |
Commented by: @dyemanov I'd prefer to have both issues in the same ticket, as both are about ROWS not being just a syntax sugar for FIRST/SKIP but handling the arguments a bit differently. |
Commented by: @jasonwharton Ok, thanks for your attention. |
Submitted by: @paulvink
Is duplicated by CORE1888
Votes: 2
If you supply a wrong argument to ROWS, you get the old "Invalid parameter to FIRST/SKIP" error message. Also (because of the internal conversion to FIRST/SKIP arguments) the user is sometimes told that a param should be >= 0 when in fact it was 0 (but maps to SKIP -1).
All this is utterly confusing to the average human being.
The text was updated successfully, but these errors were encountered: