On 27 Mar 2012, at 3:42am, "Jay A. Kreibich" <j...@kreibi.ch> wrote:

> On Tue, Mar 27, 2012 at 03:30:03AM +0100, Simon Slavin scratched on the wall:
>> 
>> On 27 Mar 2012, at 3:12am, Jay A. Kreibich <j...@kreibi.ch> wrote:
>> 
>>> On Sun, Mar 25, 2012 at 05:48:01AM +0100, Simon Slavin scratched on the 
>>> wall:
>>> 
>>>> Can those values be passed from a 'double' C variable ?  I believe so.
>>>> So I see no reason why SQLite shouldn't be storing them.
>>> 
>>> If, in the sense of "can I arrange the bits that way", then yes.
>>> However, in the sense of "is this a valid floating point number?" the
>>> answer is no.
>> 
>> Okay.  That's the heart of the matter: what do we mean by "REAL" in the
>> documentation.  The word "REAL" right next to "IEEE" makes me think it 
>> handles NaN, +Inf and -Inf.  But it's not explicitly stated.  So fair
>> point: if you don't claim to handle NaN then you don't have to.
> 
>  Not do drag things out,

On /this/ list ?

> but how would you "handle" a NaN?  If someone
>  writes a signaling-NaN into the database, the DB will start to throw
>  floating point exceptions, terminating the host process, with almost
>  any calculation.  Is that really something anyone would consider
>  "correct" behavior?  Sounds more like a great attack vector to me.

Okay, you inspired me to look up what special values exist in IEEE.  I didn't 
remember many of them.  According to Wikipedia you get no more than the 
following

+0, -0
Subnormal numbers
+Infinity, -Infinity
Quiet and signaling NaN

I think it might be reasonable to handle a signaling NaN at bind time -- to 
reject it before it even gets stored.  Make up a new SQLITE_ result code which 
means 'attempt to bind unhandled value' which you could use for this and 
perhaps other things, like an attempt to bind a BLOB or zeroblob with negative 
length (unless there's already a result code for these, in which case use that 
for signaling NaNs).

I think the OS's (or platform's) library routines can be used to handle 
everything else.  They should give consistent results over all platforms.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to