Skip to content
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

Exception with parameter issues not invalid value but its complementation to 65536 (when numeric overflow occurs) [CORE5353] #5626

Open
firebird-automations opened this issue Sep 22, 2016 · 0 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Consider script:

recreate exception foo 'Invalid value detected: @1';
set list on;
set echo on;

set term ^;
execute block as
declare x smallint; -- 'x' is NOT initialized
begin
x = 33000; -- make 'x' too big to fit in smallint via direct assignment
when any do
begin
exception foo using(:x);
end
end
^

execute block as
declare x smallint = 33; -- 'x' is initialized
begin
x = 33000; -- make 'x' too big to fit in smallint via direct assignment
when any do
begin
exception foo using(:x);
end
end
^

execute block as
declare x smallint = 33; -- 'x' is initialized
begin
x = x * 1000; -- make 'x' too big to fit in smallint via arithmetic expression
when any do
begin
exception foo using(:x);
end
end
^
set term ;^

select 33000 - 65536 from rdb$database;

It's STDERR will be:

Statement failed, SQLSTATE = HY000
exception 46
-FOO
-Invalid value detected: *** null ***
-At block line: 7, col: 13

Statement failed, SQLSTATE = HY000
exception 46
-FOO
-Invalid value detected: -32536
-At block line: 7, col: 13

Statement failed, SQLSTATE = HY000
exception 46
-FOO
-Invalid value detected: -32536
-At block line: 7, col: 13

First exception text (with "-Invalid value detected: *** null ***") can be easy explained: statement did not change variable content which was null at the beginning.
Second and third messages produces NOT invalid value but its complementation to 65536 with minus sign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant