Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A35954892 for ; Fri, 1 Jul 2011 21:23:53 +0000 (UTC) Received: (qmail 7161 invoked by uid 500); 1 Jul 2011 21:23:51 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 6104 invoked by uid 500); 1 Jul 2011 21:23:50 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 6085 invoked by uid 99); 1 Jul 2011 21:23:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2011 21:23:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP,T_RP_MATCHES_RCVD,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2011 21:23:48 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id C645243FF9E for ; Fri, 1 Jul 2011 21:23:28 +0000 (UTC) Date: Fri, 1 Jul 2011 21:23:28 +0000 (UTC) From: "Randall Leeds (JIRA)" To: dev@couchdb.apache.org Message-ID: <591164938.9813.1309555408808.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (COUCHDB-617) Large integers being turned into floats MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COUCHDB-617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Randall Leeds resolved COUCHDB-617. ----------------------------------- Resolution: Fixed I verified that this is no longer occurring at least as of 1.0.1. I didn't check further back. > Large integers being turned into floats > --------------------------------------- > > Key: COUCHDB-617 > URL: https://issues.apache.org/jira/browse/COUCHDB-617 > Project: CouchDB > Issue Type: Bug > Environment: 0.11.0b894112 > Ubuntu Karmic > standard erlang 13.b.1 package > xulrunner 1.9.1.6 > Reporter: Brian Candler > Assignee: Chris Anderson > Attachments: couchdb-test-json.diff > > > 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); }"}' http://127.0.0.1:5984/test_suite_db/_temp_view > {"total_rows":3,"offset":0,"rows":[ > {"id":"bar","key":2000000000,"value":null}, > {"id":"baz","key":2000000000,"value":null}, > {"id":"foo","key":2000000000,"value":null} > ]} > But here's a large integer getting the .0 appended: > $ curl -X POST -d '{"map":"function(doc) { emit(1262958680124,null); }"}' http://127.0.0.1:5984/test_suite_db/_temp_view > {"total_rows":3,"offset":0,"rows":[ > {"id":"bar","key":1262958680124.0,"value":null}, > {"id":"baz","key":1262958680124.0,"value":null}, > {"id":"foo","key":1262958680124.0,"value":null} > ]} > And some values are getting turned into exponential format: > $ curl -X POST -d '{"map":"function(doc) { emit(3000000000,null); }"}' http://127.0.0.1:5984/test_suite_db/_temp_view > {"total_rows":3,"offset":0,"rows":[ > {"id":"bar","key":3.0e+9,"value":null}, > {"id":"baz","key":3.0e+9,"value":null}, > {"id":"foo","key":3.0e+9,"value":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 > ["reset"] > true > ["add_fun","function(doc) { emit(1262958680124,null); }"] > true > ["add_fun","function(doc) { emit(3000000000,null); }"] > true > ["map_doc",{}] > [[[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 1.8.1.16 (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 1.8.1.18 > {"total_rows":1,"offset":0,"rows":[ > {"id":"person","key":3000000000,"value":null} > ]} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira