Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j4eR8-0007UG-Iz for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Feb 2020 05:31:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j4eR6-0002r1-MV for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Feb 2020 05:31:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j4eR6-0002qu-Dx for pgsql-bugs@lists.postgresql.org; Thu, 20 Feb 2020 05:31:44 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j4eR4-0005aW-8N for pgsql-bugs@lists.postgresql.org; Thu, 20 Feb 2020 05:31:44 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C144B21C7A; Thu, 20 Feb 2020 00:31:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 20 Feb 2020 00:31:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=8yD1QNzE/fHwpRwLJeI1njYvy6e P0lmxQg89cyGmLBg=; b=a5hkr4OhA4czhFkDLvKv7y/AS6hS8janUe3UDGB/O+8 AiJ6r6DxTS+vS4uGLJuE7z5D/Sgt8CyeS6c/LsvqAxPOQ814BfiI21M4cxVnjgLp tmrUIXUGuZONWYRpg7dlPmca822NIGzioCxcD+nqkA1ijL8548fHWwWw86FLdwyD L8WGsSbvSUd3YW1/2lXC4qVtO/7uv/8rm3HpTlaXc+VNxis467pP6J5D5JmdM4Nk PypJdBIMv6sxlWS9uHdiJz6mDUV7RdYIIXn8aBI2a5zGrF7J74FvqC2SPa2IDrOo JQvPkjwm3Aui1Hgdija1LonPdKZKDZ3N0pitl4U/Fgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm2; bh=8yD1QN zE/fHwpRwLJeI1njYvy6eP0lmxQg89cyGmLBg=; b=SiWTcVQFaRCxVsuVJixQPt WC6yJRzC8PqqJdD6dzPhXIGhbS8+cv2ZcYiOhtZRjgpl0Jn0yYYIQ9eSDJH11bjs S0Uvv2ZAFCvQweWH5aQ/KHlLatdRjrts4+Ivc1wMUZechmF5zwq3nYRBTH+ERU5D p3utoD+tsJRQ9ZYwrfRAvopu+gNw4gDY1TS23B9EifnKu0pAblvugdU76EHN3urk 6z9yANPgWQxTeLiTxfyT/E3dKwZM0wBffnJ6QNEvGtPxBDT7PnRt1NivbcSaWKT/ Jx4jjd7YQxVdCe2j6nGc1xlHD4VigRvHRRXJHpWbg8CgGpbxfVHEpMX3+xlgEE/A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkedugdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecukfhppeduudekrddvge durddvgeekrddvuddtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: from paquier.xyz (mp76f1f8d2.ap.nuro.jp [118.241.248.210]) by mail.messagingengine.com (Postfix) with ESMTPA id F0F01328005A; Thu, 20 Feb 2020 00:31:38 -0500 (EST) Date: Thu, 20 Feb 2020 14:31:31 +0900 From: Michael Paquier To: rekgrpth@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not! Message-ID: <20200220053131.GJ2288@paquier.xyz> References: <16268-3d91474b3e57a5bf@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oplxJGu+Ee5xywIT" Content-Disposition: inline In-Reply-To: <16268-3d91474b3e57a5bf@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --oplxJGu+Ee5xywIT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 20, 2020 at 05:06:24AM +0000, PG Bug reporting form wrote: > const char *data =3D SPI_getvalue(SPI_tuptable->vals[row], > SPI_tuptable->tupdesc, SPI_fnumber(SPI_tuptable->tupdesc, "data")); >=20 > raise TRAP: FailedAssertion("!(IsTransactionState())", File: "catcache.c", > Line: 1213) Catalog cache lookups have to happen in the context of a transaction, this is what this assertion failure means, so your code is doing something incorrect. We have such examples of short-term transactions opened in the PostgreSQL code for some cache lookups. IdentifySystem() in walsender.c looking for the database name is one such example (see StartTransactionCommand and CommitTransactionCommand). -- Michael --oplxJGu+Ee5xywIT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl5OGbMACgkQnvQgOdby QH3aBhAAn/uC3/9ru4m5YWplE3rTM0FjdJa+oslfrsxc52lxZZylJMsMpTGV7FSL S/X8BxhrrMm5pOnu5YCQGKQMAEVPYDD4uiHwj9VWuOM6uiZHjAzokmmHkywkx63K A2LFkMjTTAqlDA5B31AK0/FwR4eyDjA3qR1PyHGBMW8h+PKQyXrDpNLrOmD1XWTB ofCq7iVwzIBACOV2vanPVg2Iuetg20eq7GtMHTQPy4ReqNuKKJ1rIn3kuFu3Atos DZHVVaBoZ1u1N+ACX269I6/xY31y/u7S8Vm2bF2fbqKVn9HyZNIulescCRzJ5D8b fvVOOadd/5xVyBBsnqsKwEQW5+jQ1J4ZtG24AmHv+IvxmGSC6gzWai0gnXf3DVKt T2enxxssR9YE1OC/UZLmjwl7eVWYva6s0QVcRKeROOpxISbrs54Jj9iNGUr97ga3 Kx4O54DMSUTWmIRdjvFQkKCaB+w37Co9tBgKF1kB4Tevtq/Re4k2V7yxDidIx1GS 7uPk0H9dtL6fENuaysmyGUg4z4kTpjOzICWceO+d1lSHloU1Gn4H5/PPciAjpLdA ugjMH1tjYsoe6EAzkgJU8WeuHlyVcJEHsVrfh6nrtCtcY0pmmUYKV/XAb+HrtxqD MiksAcuZB3PurOmdjO42Q82ePuFHADNR4a8WSJBFu47tanpg+eQ= =LdhN -----END PGP SIGNATURE----- --oplxJGu+Ee5xywIT--