X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9D4D0D1BA09 for ; Mon, 23 Feb 2004 01:10:07 +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 12125-03 for ; Sun, 22 Feb 2004 21:10:07 -0400 (AST) Received: from hall.mail.mindspring.net (hall.mail.mindspring.net [207.69.200.60]) by svr1.postgresql.org (Postfix) with ESMTP id 60CCDD1B9C5 for ; Sun, 22 Feb 2004 21:10:03 -0400 (AST) Received: from sdn-ap-007njpennp0060.dialsprint.net ([63.185.192.60] helo=mindspring.com) by hall.mail.mindspring.net with esmtp (Exim 3.33 #1) id 1Av4bk-0001ZN-00; Sun, 22 Feb 2004 20:10:05 -0500 Received: (from lbayuk@localhost) by mindspring.com (8.12.10/8.12.10) id i1N199pP001050; Sun, 22 Feb 2004 20:09:09 -0500 From: L J Bayuk Message-Id: <200402230109.i1N199pP001050@mindspring.com> Subject: Re: create large object by tcl To: hehe88hk@yahoo.com.hk (=?big5?q?Wong=20Eric?=) Date: Sun, 22 Feb 2004 20:09:09 -0500 (EST) Cc: pgsql-interfaces@postgresql.org In-Reply-To: <20040222141220.75395.qmail@web14908.mail.yahoo.com> from "=?big5?q?Wong=20Eric?=" at Feb 22, 2004 10:12:20 PM X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/73 X-Sequence-Number: 4766 > However, I would like to ask why a transaction is > needed for accessing large object? Here's how I understand it. If I get it badly wrong, perhaps someone else will step in and correct me. The PostgreSQL database server creates a context in which to store information it needs to process commands. If you don't start a transaction block with BEGIN, a new context is created for each command, and destroyed after the command is processed. If you use BEGIN to start a transaction block, the context stays around until you use COMMIT or ROLLBACK to end the transaction block. Large object file descriptors, like cursors, are stored in this context. So if you open a large object outside a transaction block, the large object file descriptor you get back is invalid, because the context it was created in was already destroyed.