From user-return-2557-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri Jan 02 15:55:51 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 97665 invoked from network); 2 Jan 2009 15:55:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2009 15:55:50 -0000 Received: (qmail 99444 invoked by uid 500); 2 Jan 2009 15:55:47 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 99407 invoked by uid 500); 2 Jan 2009 15:55:47 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 99395 invoked by uid 99); 2 Jan 2009 15:55:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 07:55:47 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jason@jasondavies.com designates 89.145.97.179 as permitted sender) Received: from [89.145.97.179] (HELO www1.netspade.com) (89.145.97.179) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jan 2009 15:55:37 +0000 Received: from jddavies.gotadsl.co.uk ([82.133.112.184] helo=[10.0.0.14]) by www1.netspade.com with esmtpa (Exim 4.69) (envelope-from ) id 1LImQK-0005GN-Ok for user@couchdb.apache.org; Fri, 02 Jan 2009 15:58:57 +0000 Message-Id: <46D7ECAF-8D5E-46D4-BFD3-302B3CB1DBEC@jasondavies.com> From: Jason Davies To: user@couchdb.apache.org In-Reply-To: <21939021.1440421230910477169.JavaMail.servlet@perfora> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) X-Priority: 3 Date: Fri, 2 Jan 2009 15:55:15 +0000 References: <21939021.1440421230910477169.JavaMail.servlet@perfora> X-Mailer: Apple Mail (2.930.3) X-SA-Exim-Connect-IP: 82.133.112.184 X-SA-Exim-Mail-From: jason@jasondavies.com X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on www1.netspade.com X-Spam-Level: Subject: Re: Does CouchDB check autogenerated document id's? X-SA-Exim-Version: 4.2.1 (built Wed, 25 Jun 2008 17:14:11 +0000) X-SA-Exim-Scanned: Yes (on www1.netspade.com) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 On 2 Jan 2009, at 15:34, A.J. Brown wrote: > I'm writing a proof of concept for our organization to use couchdb > for our content. Part of the task will be generating document Ids > from legacy Ids (autonumber integers). This would be done by > simply doing an md5() hash on the legacy id. > > Since we're storing the same 32char hex string as our user-provided > document ids, When CouchDB generates an Id for a new document, will > it make sure that ID doesn't exist first? I know the chances of > generating the same exact ID are slim to none, but the question > still remains. According to the documentation on the Wiki, POSTing to _uuids retrieves a list of *unused* document IDs, so one would assume that it does check to ensure the ID doesn't exist. However, from reading the code it looks like *no* checks are actually made (either when POSTing to _uuids or when POSTing to save a document with autogenerated ID), but given that the UUID is securely randomly generated the chances of a collision are so slim there is no point worrying about it (see http://en.wikipedia.org/wiki/Universally_Unique_Identifier#Random_UUID_probability_of_duplicates) . If a collision does occur, then I think all that would happen is you would get a document update conflict error, perhaps someone more familiar with the internals can confirm this? Jason -- Jason Davies www.jasondavies.com