Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 38EB09FC092 for ; Fri, 20 Jul 2007 11:14:43 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 65566-10 for ; Fri, 20 Jul 2007 11:14:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 920DC9FA2E6 for ; Fri, 20 Jul 2007 11:14:39 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id l6KEEHXN053632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Jul 2007 08:14:19 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.14.1/8.14.1) with ESMTP id l6KEEGGp092913; Fri, 20 Jul 2007 08:14:16 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.14.1/8.14.1/Submit) id l6KEEGVT092908; Fri, 20 Jul 2007 08:14:16 -0600 (MDT) (envelope-from mfuhr) Date: Fri, 20 Jul 2007 08:14:15 -0600 From: Michael Fuhr To: "Abraham, Danny" Cc: pgsql-admin@postgresql.org Subject: Re: Is there a way to run CREATE TABLESPACE within a stored procedure? Message-ID: <20070720141415.GB85514@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/228 X-Sequence-Number: 26209 On Thu, Jul 19, 2007 at 02:53:50PM +0300, Abraham, Danny wrote: > Fails on: Cannot run inside a transaction block. PostgreSQL functions run in the context of a transaction so they can't execute statements that aren't allowed inside a transaction block. A workaround is to have the function connect to the database via contrib/dblink (or dbi-link, or some such mechanism) and execute the statements over that connection. Caveat: if the function's transaction rolls back then statements already committed over the connection won't be rolled back. -- Michael Fuhr