Re: [sqlite] Divide by 0 not giving error

2014-09-17 Thread Markus Schaber
Hi, Von: Jean-Christophe Deschamps This would means that if ever an SQL statement encounters divide by zero, the application will crash with no way handle the situation gracefully, nor to locate the source of the problem. Seriously, what are you talking about? Why is there no way

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread Markus Schaber
Hi, Dave, Von: Dave Wellman The problem deals with dividing by 0. As far as I can remember, in every programming language that I have ever used and in all databases that I've used, if you try and divide by 0 the process will fail with a 'divide by zero' error. Sqlite doesn't seem to do

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread Jean-Christophe Deschamps
Dear forum, MySQL does it too unless ERROR_FOR_DIVISION_BY_ZERO mode is enabled: http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html SQL Server does it too unless SET ARITHABORT is ON: http://technet.microsoft.com/en-us/library/aa259212(v=sql.80).aspx PostgreSQL doesn't do it,

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread Clemens Ladisch
Jean-Christophe Deschamps wrote: There is another good reason why raising an exception would be a terrible choice. When SQLite is used as a shared library by some scripting language, there is /*no*/ possibility to trap exceptions raised within the library. What the SQL standard calls an

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread Jean-Christophe Deschamps
What the SQL standard calls an exception is not necessarily exactly the same as an exception in other programming languages. Granted. If SQLite were to change the division-by-zero handling, it could be reported exactly like most other errors, by returning SQLITE_ERROR from sqlite3_step().

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread James K. Lowden
On Tue, 16 Sep 2014 01:42:11 +0100 Simon Slavin slav...@bigfraud.org wrote: Whether or not something is an error is a matter of definition. SQLite defines division by zero to be NULL. It's very unusual in that regard. MySQL does it too unless ERROR_FOR_DIVISION_BY_ZERO mode is enabled:

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread James K. Lowden
On Tue, 16 Sep 2014 08:59:31 +0200 Jean-Christophe Deschamps j...@antichoc.net wrote: This would means that if ever an SQL statement encounters divide by zero, the application will crash with no way handle the situation gracefully, nor to locate the source of the problem. Seriously, what

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread Jean-Christophe Deschamps
This would means that if ever an SQL statement encounters divide by zero, the application will crash with no way handle the situation gracefully, nor to locate the source of the problem. Seriously, what are you talking about? Why is there no way to handle the error, gracefully otherwise?

[sqlite] Divide by 0 not giving error

2014-09-15 Thread Dave Wellman
Hi all, I've found that an sql request that I expected to fail, but it didn't. On the face of it that is good news but there is a potential downside. I wonder if my expectation is wrong or if this is a bug which so far hasn't been caught. The problem deals with dividing by 0. As far as I

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread Richard Hipp
On Mon, Sep 15, 2014 at 2:50 PM, Dave Wellman dwell...@ward-analytics.com wrote: The problem deals with dividing by 0. As far as I can remember, in every programming language that I have ever used and in all databases that I've used, if you try and divide by 0 the process will fail with a

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread Simon Slavin
On 15 Sep 2014, at 7:50pm, Dave Wellman dwell...@ward-analytics.com wrote: Should trying to divide by 0 result in an error? No. There's no mechanism for reporting a mathematical error in SQL. You can report malformed commands, references to entities (tables, columns, etc.) which don't

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread Dave Wellman
To: General Discussion of SQLite Database Subject: Re: [sqlite] Divide by 0 not giving error On 15 Sep 2014, at 7:50pm, Dave Wellman dwell...@ward-analytics.com wrote: Should trying to divide by 0 result in an error? No. There's no mechanism for reporting a mathematical error in SQL. You can

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread Simon Slavin
On 15 Sep 2014, at 8:33pm, Dave Wellman dwell...@ward-analytics.com wrote: Simon, I'm really surprised at that. Effectively what this means is that the answer that Sqlite returns may or may not be the correct result. What ? No. It's correct. The answer is not known, and NULL means I don't

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread RSmith
On 2014/09/15 20:50, Dave Wellman wrote: Hi all, I've found that an sql request that I expected to fail, but it didn't. On the face of it that is good news but there is a potential downside. I wonder if my expectation is wrong or if this is a bug which so far hasn't been caught. The

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread RSmith
On 2014/09/15 22:13, Simon Slavin wrote: On 15 Sep 2014, at 8:33pm, Dave Wellman dwell...@ward-analytics.com wrote: Simon, I'm really surprised at that. Effectively what this means is that the answer that Sqlite returns may or may not be the correct result. What ? No. It's correct. The

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread James K. Lowden
On Mon, 15 Sep 2014 21:13:01 +0100 Simon Slavin slav...@bigfraud.org wrote: I suppose we then get into a discussion of what is the 'correct result'. I completely understand that NULL is unknown, but I've always thought that there is a difference between unknown and 'error'. It is not

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread Simon Slavin
On 16 Sep 2014, at 1:23am, James K. Lowden jklow...@schemamania.org wrote: Whether or not something is an error is a matter of definition. SQLite defines division by zero to be NULL. It's very unusual in that regard. MySQL does it too unless ERROR_FOR_DIVISION_BY_ZERO mode is enabled: