X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0A66D529F1 for ; Thu, 7 Jul 2005 19:42:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13286-03 for ; Thu, 7 Jul 2005 22:42:36 +0000 (GMT) Received: from mr2.surnet.cl (smtp2.surnet.cl [216.155.73.163]) by svr1.postgresql.org (Postfix) with ESMTP id 235CF52A00 for ; Thu, 7 Jul 2005 19:42:35 -0300 (ADT) Received: from smtp2.surnet.cl (216.155.73.169) by mr2.surnet.cl (7.0.031.3) id 4259ADFA013D2282; Thu, 7 Jul 2005 18:42:15 -0400 Received: from smtp2.surnet.cl (mr2.surnet.cl []) by mr2.surnet.cl ([216.155.73.169]); Thu, 07 Jul 2005 22:42:15 +0000 Received: from cluster.surnet.cl (216.155.73.164) by smtp2.surnet.cl (7.0.031.3) id 4259ADE300C1A40E; Thu, 7 Jul 2005 18:42:15 -0400 Received: from alvh.no-ip.org (200.85.217.230) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 42B3EF60002C552C; Thu, 7 Jul 2005 18:42:26 -0400 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 53068C2DC70; Thu, 7 Jul 2005 18:42:27 -0400 (CLT) Date: Thu, 7 Jul 2005 18:42:27 -0400 From: Alvaro Herrera To: PFC Cc: Michael Fuhr , lmeadors@apache.org, pgsql-sql@postgresql.org Subject: Re: getting back autonumber just inserted Message-ID: <20050707224227.GB23230@alvh.no-ip.org> References: <42CD6B58.6060508@techevolution.be> <20050707201433.94901.qmail@web41013.mail.yahoo.com> <20050707203715.GA26528@winnie.fuhr.org> <20050707205725.GA28200@winnie.fuhr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.392 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO, RCVD_IN_NJABL_PROXY X-Spam-Level: * X-Archive-Number: 200507/49 X-Sequence-Number: 22027 On Fri, Jul 08, 2005 at 12:26:30AM +0200, PFC wrote: > > >That's a different issue than whether currval() is subject to > >interference from other transactions. And just wait until PostgreSQL > >8.1 comes out and people start using lastval() -- then it could get > >*really* confusing which sequence value you're getting. > > What happens if an INSERT trigger inserts something into another > table which also has a sequence ? Using what, lastval()? The app will get very confused, because it'll get the value from the sequence used in the trigger. Using currval there is no problem, but you already knew that. -- Alvaro Herrera () "Hay quien adquiere la mala costumbre de ser infeliz" (M. A. Evans)