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.96) (envelope-from ) id 1wAQLL-002N2e-1r for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 10:41:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAQLJ-006afg-1k for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2026 10:41:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAQLJ-006afX-0M for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2026 10:41:05 +0000 Received: from udcm-wwu2.uni-muenster.de ([128.176.118.28]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAQLH-00000001HUq-27BF for pgsql-hackers@postgresql.org; Wed, 08 Apr 2026 10:41:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-muenster.de; i=@uni-muenster.de; q=dns/txt; s=uniout; t=1775644863; x=1807180863; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=EHhXfk7OFLxPFdDNdYSfCz4iru61TSsLYq2GbAw0SjM=; b=LiKqmdySU9ybP0wwdYjzP6m7UqH01A+rHaqPaRWQG06TxelzI/GKbjAf t/97DRUvc14YhUWgDyvGkv5RfVr8eEXT2yTmj4ToFxZMSIOcrnwMlWM9g +lLTrYDYLr0I9xkGZsUjgMxb9I6oi+fYnoDMIFHfpMNuljrzs3GmSuB3k tVoX9T87Og7p2kEMkVoMTrh0EZVXUK4Vv6JViDkj+7UISqIAJNMtk7wS2 3JUP06ChhgZEh+h/PLdE1thrTQL8MSwbuhRv4TTXcaCUA5NKYx+onhMGd +qL1zlLVJO7BRIXFA7y/Odl6MsbTblseQExzX+UY7Rr8L8mEM/K4g4Vzs Q==; X-CSE-ConnectionGUID: 3DA4S2NATg295jcjkaoacw== X-CSE-MsgGUID: aSBp3TA2QOq2lo4C0OJOpw== X-IronPort-AV: E=Sophos;i="6.23,167,1770591600"; d="scan'208";a="390011295" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY2.UNI-MUENSTER.DE with ESMTP; 08 Apr 2026 12:41:02 +0200 Received: from [192.168.178.27] (dynamic-093-133-216-166.93.133.pool.telefonica.de [93.133.216.166]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 80E3D20ADF02; Wed, 8 Apr 2026 12:41:01 +0200 (CEST) Message-ID: <67637cf8-8cbf-4f86-8775-52aa0329972d@uni-muenster.de> Date: Wed, 8 Apr 2026 12:41:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix bug with accessing to temporary tables of other sessions To: Soumya S Murali , Daniil Davydov <3danissimo@gmail.com> Cc: Tom Lane , Stepan Neretin , PostgreSQL Hackers References: <2f3fa419-9000-4e2a-b070-6e35d5de0e4c@uni-muenster.de> <751a6cb8-cac8-46c4-8c64-9e23f663e926@uni-muenster.de> <1a32fc83-df78-4774-97dc-2bb06dbb16e9@uni-muenster.de> <3529398.1774273446@sss.pgh.pa.us> <4075754.1774378690@sss.pgh.pa.us> Content-Language: de-DE, en-GB From: Jim Jones In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi On 08/04/2026 11:17, Soumya S Murali wrote: > I worked on the issue of accessing temporary tables belonging to other > sessions and tried implementing the fix at the buffer manager level, > as suggested. I added checks in ReadBuffer_common() and > PrefetchBuffer() to reject access when a relation is temporary > (relpersistence = TEMP) but does not use local buffers > (!RelationUsesLocalBuffers) so that it ensures only heap page access > is blocked, while catalog lookups and other metadata operations > continue to work as before. While testing, I observed that in many > cases the query does not reach the buffer manager because name > resolution fails earlier with “relation does not exist”. However, the > added checks ensure that even if execution reaches the buffer layer, > access to other sessions’ temporary tables is safely rejected. The > change is minimal, and did not modify parser/ACL behavior and all > regression tests got passed successfully too. > Kindly review the attached patch herewith. Please let me know if this > approach aligns with expectations or if further adjustments are > needed. A few comments: == PrefetchBuffer == The condition nested inside the if (RelationUsesLocalBuffers(reln)) tests the opposite of the main if !RelationUsesLocalBuffers(reln): if (RelationUsesLocalBuffers(reln)) { /* ACCESS DENIED CHECK */ if (reln != NULL && reln->rd_rel != NULL && reln->rd_rel->relpersistence == RELPERSISTENCE_TEMP && !RelationUsesLocalBuffers(reln)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot access temporary tables of other sessions"))); } ... } So it'll be always false, making the ereport unreachable. == ReadBufferExtended == These conditions cancel each other out: if (reln->rd_rel->relpersistence == RELPERSISTENCE_TEMP && !RelationUsesLocalBuffers(reln)) RelationUsesLocalBuffers(reln) expands to ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP), making the error message unreachable. Perhaps you meant RELATION_IS_OTHER_TEMP? == ReadBuffer_common == Same as in ReadBufferExtended and PrefetchBuffer. == tests == You excluded the tests from the patch. == patch version == You forgot to add the patch version. Best, Jim