X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 11CA3D1B95D for ; Mon, 17 Nov 2003 07:09:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 04323-05 for ; Mon, 17 Nov 2003 03:09:06 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 4D644D1B53A for ; Mon, 17 Nov 2003 03:09:05 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 728923532D; Sun, 16 Nov 2003 23:09:05 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 710053532C; Sun, 16 Nov 2003 23:09:05 -0800 (PST) Date: Sun, 16 Nov 2003 23:09:05 -0800 (PST) From: Stephan Szabo To: Greg Stark Cc: pgsql-hackers@postgresql.org Subject: Re: start of transaction (was: Re: [PERFORM] Help with In-Reply-To: <87he13a5hy.fsf@stark.dyndns.tv> Message-ID: <20031116230227.H82963@megazone.bigpanda.com> References: <200311141251.38786.mallah@trade-india.com> <1068831807.2540.44.camel@fuji.krosing.net> <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> <87isllbcys.fsf@mailbox.samurai.com> <1068983887.17671.10.camel@fuji.krosing.net> <873ccnc49e.fsf@mailbox.samurai.com> <87he13a5hy.fsf@stark.dyndns.tv> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/859 X-Sequence-Number: 47147 On Sun, 17 Nov 2003, Greg Stark wrote: > Neil Conway writes: > > > What does BEGIN actually do now, from a user's perspective? > > I think you're thinking about this all wrong. BEGIN doesn't "do" anything. > It's not a procedural statement, it's a declaration. It declares that the > block of statements form a transaction so reads should be consistent and > failures should be handled in a particular way to preserve data integrity. > > Given that declaration and the guarantees it requires of the database it's > then up to the database to figure out what constraints that imposes on what > the database can do and still meet the guarantees the BEGIN declaration > requires. The more clever the database is about minimizing those restrictions > the better as it means the database can run more efficiently. > > For what it's worth, this is how Oracle handles things too. On the > command-line issuing a BEGIN following a COMMIT is just noise; you're _always_ > in a transaction. A COMMIT ends the previous the transaction and implicitly > starts the next transaction. But the snapshot isn't frozen until you first > read from a table. The earlier portion of the described behavior is AFAICS not complient to SQL99 at least. COMMIT (without AND CHAIN) terminates a transaction and does not begin a new one. The new transaction does not begin until a transaction initiating command (for example START TRANSACTION, CREATE TABLE, INSERT, ...) is executed. The set of things you can do that aren't initiating is fairly small admittedly, but it's not a null set.