Issue Details (XML | Word | Printable)

Key: CORE-5216
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Dmitry Yemanov
Reporter: Boltik Evgeny
Votes: 0
Watchers: 1
Operations

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

Provide location context (line/column numbers) for runtime errors raised inside EXECUTE BLOCK

Created: 28/Apr/16 11:33 AM   Updated: 22/Sep/16 06:42 AM
Component/s: Engine
Affects Version/s: None
Fix Version/s: 2.5.6, 3.0.1, 4.0 Alpha 1

QA Status: Done with caveats
Test Details: Implemented only for 3.0 and above; 2.5.x does not show all of expected lines.


 Description  « Hide
set term ^;

select cast('' as timestamp) from rdb$database
^
-- ERROR:
-- Statement failed, SQLSTATE = 22018
-- conversion error from string ""


recreate procedure qwe123
  returns(res timestamp)
as
begin
  res = cast('' as timestamp);
  suspend;
end
^

execute procedure qwe123
^
-- ERROR:
-- Statement failed, SQLSTATE = 22018
-- conversion error from string ""
-- At procedure 'QWE123' line: 5, col: 3

execute block
returns(res timestamp)
as
begin
  res = cast('' as timestamp);
  suspend;
end
^
-- ERROR:
-- Statement failed, SQLSTATE = 22018
-- conversion error from string ""

Something like "At anonymous block line: 5, col: 3" should be reported in this case.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Adriano dos Santos Fernandes added a comment - 28/Apr/16 11:58 AM
It's funny that:

- conversion error from string "" -> string denoted with double quotes is wrong

- At procedure 'QWE123' -> metadata name denoted with single quotes is wrong

Nothing to do with this ticket, but... :D

Dmitry Yemanov added a comment - 28/Apr/16 12:33 PM
It's easy to fix the latter one (single quotes for metadata) but I'm afraid this will break a lot of existing tests for no real value.

Adriano dos Santos Fernandes added a comment - 28/Apr/16 12:42 PM
The later one is bigger than appear, for example, one could not know if 'X.Z' is "X.Z" by the user or Z from package X.

So a correct fix would remove que quotes from the message and put then in the error arguments:
"X.Z" (standalone procedure)
"X"."Z" (packaged procedure)

Surely it could break applications, but today one depending on how we report is already possibly broken.

Dmitry Yemanov added a comment - 28/Apr/16 12:57 PM
It could be worth backporting to v2.5, but I leave it for another day.

Sean Leyne added a comment - 28/Apr/16 03:02 PM
Dmitry,

Rather than "At anonymous block line: 5, col: 3" would suggest simply "At block line: 5, col: 3", "anonymous" could confuse users.

Dmitry Yemanov added a comment - 28/Apr/16 03:15 PM
OK, I will adjust the wording a bit later.

Pavel Zotov added a comment - 29/Apr/16 07:34 PM
> Fix Version/s: 2.5.6, 3.0.1, 4.0 Alpha 1

For 2.5.6 one may to find that fix is incompleted.
Consider script (based on test for core-2140):
===
    set echo on;

    set term ^ ;
    execute block
    returns (y int) as
    begin
      for execute statement
          ('select rdb$relation_id from rdb$database where rdb$relation_id = :x') (1)
        with autonomous transaction
        into y
      do suspend;
    end
    ^


    execute block returns (y int) as
    begin
      select rdb$relation_id from rdb$database where rdb$relation_id = :x into y;
    end
    ^

    execute block
    returns (y int) as
    begin
      for execute statement
          ('select rdb$relation_id from rdb$database where rdb$relation_id = :x') (3)
        with autonomous transaction
        into y
      do suspend;
    end
    ^

    execute block returns (y int) as
    begin
      foo = bar;
    end
    ^
===

Save it to file 'c2140.sql' and then:


C:\MIX\firebird\fb25\bin\isql /3255:e25 -z -i c2140.sql 1>c2140-25.log 2>&1
C:\MIX\firebird\fb30\isql.exe /3333:e30 -z -i c2140.sql 1>c2140-30.log 2>&1
fc /n /w c2140-25.log c2140-30.log

Result will be:
===
***** c2140-25.log
   25: -X
   26: -At line 1, column 67
   27: At line 4 in file c2140.sql
***** C2140-30.LOG
   25: -X
   26: -At line 1, column 66
   27: -At block line: 4, col: 7 <<<<<<<<<<<<<<<<<<<<<<<< !!! <<<<<<<<<<<<<<
   28: At line 4 in file c2140.sql
*****

***** c2140-25.log
   39: -X
   40: -At line 3, column 73
   41: At line 16 in file c2140.sql
***** C2140-30.LOG
   40: -X
   41: -At line 3, column 72
   42: At line 16 in file c2140.sql
*****

***** c2140-25.log
   60: -X
   61: -At line 1, column 67
   62: At line 21 in file c2140.sql
***** C2140-30.LOG
   61: -X
   62: -At line 1, column 66
   63: -At block line: 4, col: 7 <<<<<<<<<<<<<<<<<<<<<<<< !!! <<<<<<<<<<<<<<
   64: At line 21 in file c2140.sql
*****
===

So, we can see that
1) columns differ
2) line " -At block line: 4, col: 7 " could be missed in 2.5.6


Checked on:

 ISQL Version: WI-V2.5.6.27004 Firebird 2.5
 Server version:
 WI-V2.5.6.27004 Firebird 2.5
 WI-V2.5.6.27004 Firebird 2.5/tcp (csprog)/P12
 WI-V2.5.6.27004 Firebird 2.5/tcp (csprog)/P12

 ISQL Version: WI-V3.0.0.32499 Firebird 3.0
 Server version:
 WI-V3.0.0.32499 Firebird 3.0
 WI-V3.0.0.32499 Firebird 3.0/tcp (csprog)/P13
 WI-V3.0.0.32499 Firebird 3.0/tcp (csprog)/P13