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 1wKwD1-001PqY-35 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 May 2026 10:44:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wKwCz-003QoC-2h for pgsql-hackers@arkaria.postgresql.org; Thu, 07 May 2026 10:43:57 +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 1wKwCz-003Qo3-1l for pgsql-hackers@lists.postgresql.org; Thu, 07 May 2026 10:43:57 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wKwCx-00000000zF2-24EH for pgsql-hackers@postgresql.org; Thu, 07 May 2026 10:43:57 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-6948e6bc30cso198941eaf.0 for ; Thu, 07 May 2026 03:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778150634; cv=none; d=google.com; s=arc-20240605; b=Qzm3n0M57iesqIdhFhrbUtAz8f/zGsNYBFAECTj1pmatOVXHri9VtVMiGCuhgcY/Dq Ununqb/3TCus6qpJwyPEwQneBJBXCJ8ENODDU0zsgBh3wdEdeOm/fO1hrhb5gHGaq0Pd h663ldSQJKpApDk4iR5SolxeRICMMZ70Eq2aE9YEY2ka5g0QRK3QLHRUepGINKyLwFq2 Vh4XD+WADIymmotnQ4DTDRZJ2Pge+c3KTzgqY1EoFd0mWc9pEGIumWCNCnQmwEmPQ091 O7b5+cpHN95pb/BJOcQRfIkIY+vwf2DCn64DlF4TW0LOY3f+LzumBSqW2pdw7ss0LqeA iShA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BiKH23ifTmTB4klP/uZxkkIuthnEzlpEut3zB9esYpw=; fh=e+A7JTnQbZZ9dblG7T9yr1q26UuEeZuia3TmB7TBwvw=; b=fctGbwCoGXvneo43Jq1Tl0v8DSQblf6li0RV9rorSvmVsk5kRLcVABQi/09T5VeDFc VghrZ+JgrSkoQ6+yd470eZzj6eZiCSBblbgv2U0c8QJJHhjLggxI+ebD8o/NwAuoV6uT o4hwT3czQY41560EAjV7s9ci5KS5GyL+lZhwmLsUG62zTV+KZ/Kfh6IN9m2MartDnrKf fKOY7K8Tv7FVVl48rf1N8+Ee14XEM4KBhqLZH2Ll9YxpR63/oji3OLuOPvOTf/nLH6sx U/doC400P9a8WFRK60uqTooWhfDVzCjMgjQI7n2gYuygxUyrnOApWGG1VdlzgUVCYUCm NOfg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778150634; x=1778755434; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BiKH23ifTmTB4klP/uZxkkIuthnEzlpEut3zB9esYpw=; b=gXm0pdtTo44mWxj2fv0lhKybWSZifVavkZR28ToXWBuMTAHgSpCEtioUpE7yJ5qz1c 22Ze9oG6f/luZw237zZK3OPyGbB3aGkcJy+7f/QmAJS4jexceUPCUgVeaZWRNrguQgwK +z98mx0VZXxjg+IBo+Smy6V1ANKCUejEyHCfAD5B+25K82rd3SrIFUjyFJEdQWd8Z9dh hid+hSAPp2W2Mu4eYAkVS5J/JcE18kN2P51EosuUdVXb9UmolIYpvvdz5ZrPVX4JF6Xr gPYd2SyrvPyL9AnqI7SQqkt5p+DnR64oyzATyFOeZK+SBoE9mrSiaAsXfmQTqhFCqloR IHyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778150634; x=1778755434; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BiKH23ifTmTB4klP/uZxkkIuthnEzlpEut3zB9esYpw=; b=eObPKdL9ks7NBkpciV+jinrmzmKPO1n2Vx/4XQxiLzurNa1Vk2ySIDuxI7gKc4IpdH Rv+Ym7rHIRzuY/uOm9Fnuuxj6MEcx0uyUrp3/tj7js5yumsuiYUGalqcWNwvK3AxjMTX mGDyj/XdvnlLBz+el3EzAl95TFpW636VEAY8vHq20Ql2++8FVtSFooymMSrJH4XWaBKL pLGyPchaCyLqtRFkxwshLYKOEKNk4gaphdHtXZCy7Af+MAMj/H/ScRKqpucTgL7G0Xqa WKZFZuP74tJIbPFiCF+NwXtWfFpNszMIi75t0Ucl3AYkkkWhtdsIVsjuwexLTaCOSxpM i5NA== X-Forwarded-Encrypted: i=1; AFNElJ92rfenJvN3wg5cBxdPV6/2wxnSoDPQlEnV/lUa9wqhep+XpTR09bpL/LjUYhIjRjSfsqhSpe3ud+QQuMeO@postgresql.org X-Gm-Message-State: AOJu0YxD+5urorUsOXIVxDuyctul53Cdl6ikwn6Rx9a7kdaH3g3+bPyk aGSwPHmUejPPebuLpVc0woynCcVTTn4lxYvGWFmwpb6rGVBq0TvDykNVPOqXiIgUGm7IMOn7q0s HH+kb+dmLlHQMLI3b6Kge5I4P6OitO7U= X-Gm-Gg: AeBDieulR+pcfPn2qzr4p1mtigctDHGpu0VwMNUHwcHsRq3I39qKCxvxYl1PW5MR1D1 RmhfqLpMKU3Ey2m2iIagEMSno8L2AEyT6cuCZwENqcpEcOXX/cGHD9N1FbQgeHz9EBU3xsMM2Tu wQFJnzPFJ9vy9veEQS9/KfRgSUNhJB6JGa5H182UqPeGlAoZXQIuPp+22u76IdJDhLLBclcWnSX Umk1y4JNoP9Xonvz3CA2ZPD7xkp1Cb3K4XCYyh+exSlly9fzAgfoJHBm0LV/lhvTV0yohampD6P gUDoaTj9aiaggs2h3cLB6yevCbgcKfG6ms4inxs3dFI1f2kiKZSHx7YXj/VvkR6CaIumlu+2/8j TxEpY+MmW1v4iTbtMdw== X-Received: by 2002:a05:6820:180e:b0:696:155e:cd49 with SMTP id 006d021491bc7-69998d61d09mr3835612eaf.54.1778150633569; Thu, 07 May 2026 03:43:53 -0700 (PDT) MIME-Version: 1.0 References: <239d181d-1415-49ee-ad57-b307f1a7ba66@uni-muenster.de> <0e666e40-d003-4c92-95cf-1a33a647401f@uni-muenster.de> <3aad711d-1eea-4989-b9e7-261eeffa5f5b@uni-muenster.de> In-Reply-To: <3aad711d-1eea-4989-b9e7-261eeffa5f5b@uni-muenster.de> From: Alexander Korotkov Date: Thu, 7 May 2026 13:43:40 +0300 X-Gm-Features: AVHnY4K2jnymPQ3XfM_nvy8OB1MUvjtjSHUeFU6Qan9-nKxrQtqrNf8paXTbcts Message-ID: Subject: Re: Fix bug with accessing to temporary tables of other sessions To: Jim Jones Cc: Daniil Davydov <3danissimo@gmail.com>, Michael Paquier , Soumya S Murali , Tom Lane , Stepan Neretin , PostgreSQL Hackers , Mohamed Ali , Nazneen Jafri , Shawn McCoy Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, May 7, 2026 at 11:43=E2=80=AFAM Jim Jones wrote: > On 07/05/2026 10:04, Alexander Korotkov wrote: > > Thus, I don't see the reason why this shouldn't be committed and > > backpatched to PG17 (first release containing b7b0f3f27241). > > Quick question: should we work on a separate patch for PG14-PG16? In > these versions, the error message is raised depending on the temporary > table's tuple count, as demonstrated in [1]: > > =3D=3D session 1 =3D=3D > > psql (14.20 (Debian 14.20-1.pgdg13+1)) > Type "help" for help. > > postgres=3D# CREATE TEMPORARY TABLE t (id int); > CREATE TABLE > postgres=3D# \d pg_temp*.* > Table "pg_temp_3.t" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > id | integer | | | > > =3D=3D session 2 =3D=3D > > psql (14.20 (Debian 14.20-1.pgdg13+1)) > Type "help" for help. > > postgres=3D# SELECT * FROM pg_temp_3.t; > id > ---- > (0 rows) > > =3D=3D session 1 =3D=3D > > postgres=3D# INSERT INTO t VALUES (42); > INSERT 0 1 > > =3D=3D session 2 =3D=3D > > postgres=3D# SELECT * FROM pg_temp_3.t; > ERROR: cannot access temporary tables of other sessions Thank you for your question. Yes, PostgreSQL 14-16 first does RelationGetNumberOfBlocks(), then scans the relation through the buffer manager. If RelationGetNumberOfBlocks() returns 0, then no buffers accessed and no error thrown. So, it could scan empty tables because it doesn't requires accessing local buffers of other sessions. I would investigate this further. If this doesn't have negative side effects (like execution of other commands that couldn't be performed correctly), I would avoid backpatching to these versions. ------ Regards, Alexander Korotkov Supabase