couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Candler (JIRA)" <>
Subject [jira] Created: (COUCHDB-617) View server turning integers into floats
Date Fri, 08 Jan 2010 14:30:54 GMT
View server turning integers into floats

                 Key: COUCHDB-617
             Project: CouchDB
          Issue Type: Bug
         Environment: 0.11.0b894112
Ubuntu Karmic
standard erlang 13.b.1 package

            Reporter: Brian Candler

Somewhere between the view server and the client, large integer values are having .0 appended
to make them look like floats.

This is OK:

$ curl -X POST -d '{"map":"function(doc) { emit(2000000000,null); }"}'

But here's a large integer getting the .0 appended:

$ curl -X POST -d '{"map":"function(doc) { emit(1262958680124,null); }"}'

And some values are getting turned into exponential format:

$ curl -X POST -d '{"map":"function(doc) { emit(3000000000,null); }"}'

It appears to affect integers larger than 2^31, but these are still much smaller than the
2^48 mantissa of IEEE double precision (which Javascript uses). Hence they should be accurately
represented as integers, not floats.

If I run the view server by itself from the command line, all works properly:

$ bin/couchjs share/server/main.js 
["add_fun","function(doc) { emit(1262958680124,null); }"]
["add_fun","function(doc) { emit(3000000000,null); }"]
[[[1262958680124,null]], [[3000000000,null]]]

Therefore it looks like the problem is in the Erlang JSON deserialisation side. i.e. it's
not keeping these values as large integers, when it could be.

NOTE: I have another machine, running a similar recent couchdb trunk (0.11.0b894828) plus
Ubuntu Karmic Server Edition built against libmozjs (not xulrunner). This exhibits
the same behaviour as above.

But the problem *doesn't* appear on another, older CouchDB installation I have. This is 0.11.0a813819
running under Ubuntu Hardy, with erlang 12.b.5 and libmozjs


This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message