I don't agree with this ticket getting closed. I raised an objection to
the current solution in the comments that I think needs to be addressed.
The current solution causes a divergence in errors between decimals(p,s)
with p <=18 and 18 < p <=34, which is confusing and leaks implementation
details to the user. In the same situation it should raise the same errors.
Compare
Error: *** IBPP::SQLException ***
Context: Statement::Execute( insert into extdecimal(dec_18_18) values (10) )
Message: isc_dsql_execute2 failed
SQL Message : -802
Arithmetic overflow or division by zero has occurred.
Engine Code : 335544321
Engine Message :
arithmetic exception, numeric overflow, or string truncation
numeric value is out of range
vs
Error: *** IBPP::SQLException ***
Context: Statement::Execute( insert into extdecimal(dec34_34) values (1) )
Message: isc_dsql_execute2 failed
Engine Code : 335545141
Engine Message :
Decimal float invalid operation. An indeterminant error occurred during
an operation.
numeric value is out of range
Mark
On 17-6-2018 08:58, Pavel Zotov (JIRA) wrote:
[
http://tracker.firebirdsql.org/browse/CORE-5726?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pavel Zotov closed CORE-5726.
-----------------------------
Unclear error message when inserting value exceeding max of dec_fixed decimal
-----------------------------------------------------------------------------
Key: CORE-5726
URL: http://tracker.firebirdsql.org/browse/CORE-5726
Project: Firebird Core
Issue Type: Bug
Components: Engine
Affects Versions: 4.0 Alpha 1
Environment: Firebird-4.0.0.864-0_x64 (Windows 10)
Reporter: Mark Rotteveel
Assignee: Alexander Peshkov
Fix For: 4.0 Beta 1
Inserting a value that exceeds the precision of a dec_fixed decimal column
results in an unclear exception message.
Table:
create table extdecimal (
id integer generated always as identity primary key,
dec34_34 decimal(34, 34)
);
Insert:
insert into extdecimal(dec34_34) values (1);
This yields error:
Error: *** IBPP::SQLException ***
Context: Statement::Execute( insert into extdecimal(dec34_34) values (1) )
Message: isc_dsql_execute2 failed
SQL Message : -901
Unsuccessful execution caused by system error that does not preclude successful
execution of subsequent statements
Engine Code : 335545141
Engine Message :
Decimal float invalid operation. An indeterminant error occurred during an
operation.
Instead it should raise error 335544321 (arithmetic exception, numeric
overflow, or string truncation) + error 335544916 (numeric value is out of
range), as 1 doesn't fit in a decimal(34, 34). For comparison, a decimal(18,18)
will accept 1-9 (as it is actually precision 19 with some caveats), but raise
335544321 + 335544916 when inserting 10 or higher.
--
Mark Rotteveel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel