Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6Bvi-00HXLH-VN for pgsql-novice@arkaria.postgresql.org; Thu, 23 Nov 2023 15:47:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r6Bvh-001nqq-Dz for pgsql-novice@arkaria.postgresql.org; Thu, 23 Nov 2023 15:47:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6Bvh-001nqc-5g for pgsql-novice@lists.postgresql.org; Thu, 23 Nov 2023 15:47:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6Bve-007004-L3 for pgsql-novice@lists.postgresql.org; Thu, 23 Nov 2023 15:47:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3ANFljc92658682; Thu, 23 Nov 2023 10:47:45 -0500 From: Tom Lane To: mahendrakar s cc: pgsql-novice Subject: Re: Run a transaction block through SPI_execute In-reply-to: References: Comments: In-reply-to mahendrakar s message dated "Thu, 23 Nov 2023 18:33:32 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2658680.1700754465.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 23 Nov 2023 10:47:45 -0500 Message-ID: <2658681.1700754465@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk mahendrakar s writes: > When I try to run a transaction block (similar) to below through SPI_exe= cute: > BEGIN; set transaction read write; ....; COMMIT > I get an error: SPI_ERROR_TRANSACTION. > I see that SPI interface does not support transaction manipulation comma= nds. Yup; you can't execute begin/commit that way. > Transaction management support only SPI_commit/SPI_rollback. > I'm more interested in setting `set transaction read write;` through > SPI interface. You could look at how plpgsql handles it. I think though that as long as you do BEGIN and COMMIT in the approved way, you can feed the SET through SPI_execute or one of its siblings. regards, tom lane