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

Add expression index name to exception message if computation failed [CORE5606] #5872

Closed
firebird-automations opened this issue Sep 6, 2017 · 12 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @livius2

Will be good to see in which expression index exception was raised and at last that exception was raised by calculated index at all.

e.g.

CREATE TABLE TEST
(
ID INTEGER,
WARTOSC NUMERIC(16,2)
);
CREATE INDEX IXAE_TEST__CALC ON TEST COMPUTED BY((ID+WARTOSC)/0);

INSERT INTO TEST (ID,WARTOSC) VALUES ('4','6.50');
we got exception:
SQL Message : -802
Arithmetic overflow or division by zero has occurred.

Engine Code : 335544321
Engine Message :
arithmetic exception, numeric overflow, or string truncation
Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.

and we do not know that this error occured inside expression index at all and do not know in which one.

Commits: 7226b54 f924ded

@firebird-automations
Copy link
Collaborator Author

Modified by: @livius2

Component: Engine [ 10000 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 Beta 1 [ 10750 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

It seems that not all build-in functions are covered (among them which can be used in expression index).

Consider following script:

set list on;
recreate table test(
id int
,x int
,y int
,r double precision
,s char(12) default 'DB_NAME'
);
commit;
create index test_eval1 on test computed by ( x/id );
create index test_eval2 on test computed by ( log10(r-15) );
create index test_eval3 on test computed by ( rdb$get_context('SYSTEM', s) );
create index test_eval4 on test computed by ( mod(x , (y-x) ) );
create index test_eval5 on test computed by ( substring(s from x for id+y) );

commit;

set count on;
set echo on;

insert into test(id, x) values(0, 1);

insert into test(id, r) values(1, 12);

insert into test(id, s) values(2, 'ENGINE_VERSION');

insert into test(id, x, y) values(3, 10, 10);

insert into test(id, x, y, s) values( 4, 3, -7, 'qwerty' );

set echo off;

select id, s from test;

Now run it with filtering only STDERR and 'test_eval' prefix from it:

C:\MIX\firebird\fb40\isql /:e40 -i c5606.sql 2>&1 | findstr /i /c:test_eval

None rows will be added into table: every declared expressions will get actual arguments that break evaluating process (runtime errors will be in every of them).
Output will contain only one row:

Expression evaluation error for index "TEST_EVAL1" on table "TEST"

Where are messages about indices TEST_EVAL2 ... TEST_EVAL5 ?

PS. WI-T4.0.0.743

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Deferred

Test Details: See note 12/Sep/17 10:51 AM

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Fixed.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

Unfort., in the build WI-T4.0.0.744 (13-sep-2017) output contains only common text of exceptions but INDEX names are not mentioned at all.
Even 'TEST_EVAL1' not present in STDERR like it was before.

PS.
I did minor mistake in the script. One need to change (in the table DDL):

,s char(12) default 'DB_NAME'

to:

,s varchar(12) default 'DB_NAME'

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

> Even 'TEST_EVAL1' not present in STDERR like it was before.

I cannot reproduce.

For the "s" case, error happens on the field constraint level, before index update, so it's correct to not have the new message.

SQL> recreate table test(
CON> id int
CON> ,x int
CON> ,y int
CON> ,r double precision
CON> ,s varchar(12) default 'DB_NAME'
CON> );
SQL> commit;
SQL> create index test_eval1 on test computed by ( x/id );
SQL> create index test_eval2 on test computed by ( log10(r-15) );
SQL> create index test_eval3 on test computed by ( rdb$get_context('SYSTEM', s) );
SQL> create index test_eval4 on test computed by ( mod(x , (y-x) ) );
SQL> create index test_eval5 on test computed by ( substring(s from x for id+y) );
SQL>
SQL> commit;
SQL>
SQL> insert into test(id, x) values(0, 1);
Statement failed, SQLSTATE = 22012
Expression evaluation error for index "TEST_EVAL1" on table "TEST"
-arithmetic exception, numeric overflow, or string truncation
-Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.
SQL>
SQL> insert into test(id, r) values(1, 12);
Statement failed, SQLSTATE = 42000
Expression evaluation error for index "TEST_EVAL2" on table "TEST"
-expression evaluation not supported
-Argument for LOG10 must be positive
SQL>
SQL> insert into test(id, s) values(2, 'ENGINE_VERSION');
Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 12, actual 14
SQL>
SQL> insert into test(id, x, y) values(3, 10, 10);
Statement failed, SQLSTATE = 22012
Expression evaluation error for index "TEST_EVAL4" on table "TEST"
-arithmetic exception, numeric overflow, or string truncation
-Integer divide by zero. The code attempted to divide an integer value by an integer divisor of zero.
SQL>
SQL> insert into test(id, x, y, s) values( 4, 3, -7, 'qwerty' );
Statement failed, SQLSTATE = 22011
Expression evaluation error for index "TEST_EVAL5" on table "TEST"
-Invalid length parameter -3 to SUBSTRING. Negative integers are not allowed.
SQL>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: Deferred => Done successfully

Test Details: See note 12/Sep/17 10:51 AM =>

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

Sorry, me wrong: i used old client library. On build 744 all works fine.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @livius2

Thank you for adding this :)
Tested and work ok.

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

2 participants