Issue Details (XML | Word | Printable)

Key: CORE-5783
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vlad Khorsun
Reporter: Polesov
Votes: 0
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Firebird Core

execute statement ignores the text of the SQL-query after a comment of the form "-"

Created: 29/Mar/18 08:54 AM   Updated: 07/Apr/18 06:46 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.0.4, 4.0 Beta 1

QA Status: Done successfully


 Description  « Hide
If the text of the SQL query executed in the execute statement contains comments "-", then starting with the "-" characters, all text is ignored to the end.

For example:

create or alter procedure STMT_ERR
returns (
    LEN integer,
    NAME varchar(100))
as
  declare variable SQL blob;
begin
  SQL =
'select RDB$FIELD_LENGTH, RDB$FIELD_NAME
  from RDB$FIELDS
 where not RDB$FIELD_NAME is null
-- comment
   and RDB$FIELD_LENGTH > 2
 order by RDB$FIELD_LENGTH
';

  for
    execute statement ( :SQL )
    into :LEN, :NAME
  do
    suspend;
end


 All   Comments   Change History   Subversion Commits      Sort Order: Descending order - Click to sort in ascending order
Kovalenko Dmitry added a comment - 07/Apr/18 06:46 AM
I detect your changes in my test system :)

From my point of view - it is problem of "blob filter".

---
Some time ago (~5 years) I asked Alex(?) about support of '\r' as EOL. He said - 'NO'.

Vlad Khorsun added a comment - 30/Mar/18 08:31 AM
The issue have 3 parts:

a) when EXEC STMT get SQL query text from binary BLOB variable (as in this test case), engine uses special blob filter to convert binary blob to text (filter_text).
I don't know why, but this blob filter uses \n (new-line) as segment boundary and *removes* it from output !
Thus EXEC STMT got SQL query text with plain \r as line endings (if there was \r\n stored at blob - as in this case)

Correspondingly, there is a simple workaround - use BLOB SUB_TYPE TEXT (or VARCHAR) for SQL text.

b) EXEC STMT preprocessor doesn't handle \r as end of line, thus it can't find end of single-line comment

c) same problem exists at DSQL lexer - it also can't handle plain \r as end of line

I going to fix both (b) and (c) but not going to change blob filter at (a)