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 1wGdT7-006QV7-39 for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Apr 2026 13:54:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wGdS7-00983s-2W for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Apr 2026 13:53:47 +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 1wGdS7-00983i-1M for pgsql-hackers@lists.postgresql.org; Sat, 25 Apr 2026 13:53:47 +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 1wGdS5-00000002zdu-1Jda for pgsql-hackers@postgresql.org; Sat, 25 Apr 2026 13:53:47 +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=1777125225; x=1808661225; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=KnXoEN+qqP2/vgQgXkqizO6KRrM2lrD5iIQT339OTKU=; b=S7eQQu1jo22U8UG/15c+c18gQ9Hj90iHvlCqUND8o55DdHcj77+9Wkh6 6zTwwCWgNWs94XLBAv2rM9oQBiA+9YFNTUiRplpqMHZqNBs/uXDehOUzy RtRmEPNqaZQxjHfzNkzyFUmEsrRTjg765B6p55d9ode5N9VFXKN5RmwBQ zFQTVwoONaBOCsaI9LWHqoXQsd8IUURqNtMicee0Lsf+glxwV3pIk2U4Z LvNn1LySv7Dusm2MOoeztk83N4z7p2mx6kS7WQ3YGCECH0ZQRh2Kag01V 2w2WpTpmkRXJc7WH5+lTzuF5ruSX0eqbsmXYOjO0350uofOIbCaAEHGdK g==; X-CSE-ConnectionGUID: 7Bglt4bUTVSk/KuOKt7S+A== X-CSE-MsgGUID: 4dFMM2wVQWWP4lRHw2rg2A== X-IronPort-AV: E=Sophos;i="6.23,198,1770591600"; d="scan'208";a="392099808" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY2.UNI-MUENSTER.DE with ESMTP; 25 Apr 2026 15:53:44 +0200 Received: from [192.168.178.40] (dynamic-002-243-176-041.2.243.pool.telefonica.de [2.243.176.41]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 6FC7320ADF00; Sat, 25 Apr 2026 15:53:42 +0200 (CEST) Message-ID: <800c75af-9bd0-48ac-b4bf-54cadf2bc723@uni-muenster.de> Date: Sat, 25 Apr 2026 15:53:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix bug with accessing to temporary tables of other sessions From: Jim Jones To: "David G. Johnston" Cc: Michael Paquier , Alexander Korotkov , Soumya S Murali , Daniil Davydov <3danissimo@gmail.com>, Tom Lane , Stepan Neretin , PostgreSQL Hackers , Mohamed Ali , Nazneen Jafri , Shawn McCoy References: <402bbc8d-728b-4467-8024-31c2bc101ead@uni-muenster.de> <98c1c0d9-7962-4669-90f2-deb28a665a55@uni-muenster.de> <9be9ee9b-b816-4ff9-a929-d830e21b94fc@uni-muenster.de> Content-Language: de-DE, en-GB In-Reply-To: <9be9ee9b-b816-4ff9-a929-d830e21b94fc@uni-muenster.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 25/04/2026 01:01, Jim Jones wrote: > Until PG16 an error message was raised: > > psql (16.13 (Debian 16.13-1.pgdg13+1)) > Type "help" for help. > > postgres=# \d pg_temp*.* > Table "pg_temp_3.t" > Column | Type | Collation | Nullable | Default > -----------------+---------+-----------+----------+--------- > generate_series | integer | | | > > postgres=# SELECT * FROM pg_temp_3.t; > ERROR: cannot access temporary tables of other sessions The PG16 test above was against a non-empty TEMPORARY TABLE. If the table is empty, the same behaviour from PG17 and PG18 can be observed: psql (16.13 (Debian 16.13-1.pgdg13+1)) Type "help" for help. postgres=# \d pg_temp*.* Table "pg_temp_4.t" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- id | integer | | | postgres=# SELECT * FROM pg_temp_4.t; id ---- (0 rows) The same applies for PG14 and PG15 psql (14.22 (Debian 14.22-1.pgdg13+1)) Type "help" for help. postgres=# \d pg_temp*.* Table "pg_temp_3.t" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- id | integer | | | postgres=# SELECT * FROM pg_temp_3.t; id ---- (0 rows) psql (15.17 (Debian 15.17-1.pgdg13+1)) Type "help" for help. postgres=# \d pg_temp*.* Table "pg_temp_3.t" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- id | integer | | | postgres=# SELECT * FROM pg_temp_3.t; id ---- (0 rows) Since the table is indeed empty, the result is actually correct. But I'd argue that we should raise an ERROR even if the table is empty. IMHO, getting an error message or a "0 rows" result depending on the table row count isn't ideal. After populating the TEMPORARY TABLE the expected error message appears: ERROR: cannot access temporary tables of other sessions Best, Jim