Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPAZ5-00025O-J4 for pgsql-general@arkaria.postgresql.org; Sun, 04 Oct 2020 20:25:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kPAZ2-0004mI-Gj for pgsql-general@arkaria.postgresql.org; Sun, 04 Oct 2020 20:25:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPAZ1-0004lm-BM for pgsql-general@lists.postgresql.org; Sun, 04 Oct 2020 20:25:00 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPAYx-0004tM-T2 for pgsql-general@lists.postgresql.org; Sun, 04 Oct 2020 20:24:58 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id B85268A2; Sun, 4 Oct 2020 16:24:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 04 Oct 2020 16:24:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=w gjB59RnI02S6vI98DCcbcMKSXqTtVgTlrDCl7WjBYg=; b=jpUO+X561/L97KrVt xQ9fB4m++9710vWSiu7wMUEpiTcD3PWyAIhmdDkgGYtNOUnVbS7eLdQfggM5cIur o0nR3xKiLCBXYbSYaZlDovk1XvsmcEsrM75CiAFNyJ/Z2TW4y2t5riAQsvZ0NdI/ dXZikfP3GnNEJUvRiCZuqALJ+f5vVSOI0mx6W+kJOyHIEJU9HVCk5hAwSeSvDin0 rWHBA/lTcFHxODOIrd9woe9Tlt00cWKbSPho+32A4L8DjWtcZm1BStGaLsLV0tFC nzPeATrkZs1OtKNWEpAUb6p7BmcOzyEXJmjRyuUehUkjAGpzP/oZqCFnIAMxkFXI DJmtQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=wgjB59RnI02S6vI98DCcbcMKSXqTtVgTlrDCl7WjB Yg=; b=BD+BuMrrntVMehd3rynSq5D0GBvqnKDC+xAOCVBtzUjwnSFJiBRsSPNkf xqOz3LSM3i6ymAyz2Vx9KMgTP2MVvH6LDiX5TmmFPyy3+5dS2N4OugiLWkhD5TtQ njcne4zj/1ZkqcVAh1xp56+bvR22LIMxv6qR8zsTsExaSZbZhn/L4zTY5XzvrX7o aA7L6kH0QChZ2DQ+gz6RpN/E8m4LrjsZ9I0aDipG1VOypfq9HrTBFgRELu0w6yzy IwBDBTMe/2Q3nUiu9mbiWBu0FTDvCDLr3789MZEizBiXnZplqyabiROxdA2ix0hC J2CuaxryBgYxYYTnWiHdSICCatDJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgedtgdduheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeetjedvteffjeeuvdelieeffeehuedthffgvdfhhffh kedvudevgedvjedufefgveenucfkphepjeehrddujedvrdehrddvfedunecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 98D7D3064610; Sun, 4 Oct 2020 16:24:50 -0400 (EDT) Subject: Re: Can't query system tables during transaction To: Igor Korot , "pgsql-generallists.postgresql.org" References: From: Adrian Klaver Message-ID: <2c36acfd-d3c4-8929-5343-ddc07093adc6@aklaver.com> Date: Sun, 4 Oct 2020 13:24:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/4/20 1:14 PM, Igor Korot wrote: > Hi, ALL, > I'm trying to execute following: > > SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace > AND c.relname = 'foo' AND n.nspname = public; > > inside the transaction. > > I'm getting the following error: > > ERROR: current transaction is aborted, commands ignored until end of > transaction block No it means another statement before this one threw an error and the transaction needs to be rolled back. Something like this: track_stocks(5442)=> begin ; BEGIN track_stocks(5442)=> SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace AND c.relname = 'stock-info' AND n.nspname = public; ERROR: column "public" does not exist LINE 2: AND c.relname = 'stock-info' AND n.nspname = public; ^ track_stocks(5442)=> SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace AND c.relname = 'stock-info' AND n.nspname = 'public'; ERROR: current transaction is aborted, commands ignored until end of transaction block track_stocks(5442)=> rollback ; ROLLBACK And now the correct query(Note the quoted schema name): track_stocks(5442)=> begin ; BEGIN track_stocks(5442)=> SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace AND c.relname = 'stock-info' AND n.nspname = 'public'; ?column? ---------- (0 rows) > > Does this mean I can't query system tables during the transaction? > What is the problem here if it's not and how do I find out the reason? > And if it is - how to work around it? > > I can probably commit it and start a new transaction, but I fear I will > have the same issue there... > > Thank you. > > If it matters - I'm working with C++ and libpq. > > -- Adrian Klaver adrian.klaver@aklaver.com