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 1wDFhe-002mTK-1h for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 05:55:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDFhd-0048Wz-2J for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2026 05:55:49 +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 1wDFhd-0048Wr-1D for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2026 05:55:49 +0000 Received: from mail-dl1-x122a.google.com ([2607:f8b0:4864:20::122a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDFha-00000001MCP-43md for pgsql-hackers@postgresql.org; Thu, 16 Apr 2026 05:55:48 +0000 Received: by mail-dl1-x122a.google.com with SMTP id a92af1059eb24-128b9b7e3edso6831458c88.0 for ; Wed, 15 Apr 2026 22:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776318945; cv=none; d=google.com; s=arc-20240605; b=E+qFQsDHIzlBYBBkN4kHDCPXqyTduTTrZpB0Z6u2F0sCSQIhWI/Mt0ARjLPnvL5tTd na4i6cs7xitUmm0hUiXWnPvoQFpPkH9llBfpB1uzuyFr3/WyiIGl4cofb1yC67R+U5lC OTcXr/Obi/xn2NkPZw5WXc/7+E0GJRGLb/JZF5tF6oT3B8qDIkAGidtQXY3VVIgCjLM7 bqkxLNGWRW+1JOfOHuLrJwCjptvva1flWW8VZ58YOlvB9y4I4HqtB1dhh5u0uYUkdRy4 jj1irYTIBoiZDbBIqEt0x2yhTpTlCi8EDkJ3iPusvZhhF0n+/nxfel49AUXdFpGDQF6/ ygrw== 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=i3fbFJldNRjzbBMbAUD3PVN4qI/fecARZIQQvM4SZFs=; fh=Dbh0dJ8Q/6Vtvw3xpeBv3TvLDJTfHXlX7R98aFBIuCQ=; b=ashvArUC4DLCxGpLxQfc2F7XVXvA3mWhs5mhHs0a9r9+aul+yRKeEwqdlx4VqlmV5h A7Nn07+OnscxJ7izFEQuZOfwYoP7kvXry9WD8xGl1kPLs9JcPgVqhy1tmOoi9ZEN1q/7 wavWka/s+NGGpuJ4Pe2QqizJgdCpfgnQ5wAOPVJGxsJHeSL+YvwMGi5XXt+yn0rQzxqK EBht1L6/G+FMtRExkPjgTJwHLvVtKlRqSlCZ8BZSCJuNttxv8m1naeneTNqm9nVzMmp0 i8c8dxDQotMSnjem4+VmvegQwCqfBtoyee3rU6VY/TFi1m0JAoghxN8/yc38mMnoVoiF qxeA==; 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=1776318945; x=1776923745; 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=i3fbFJldNRjzbBMbAUD3PVN4qI/fecARZIQQvM4SZFs=; b=CR1svg8m0+CEujQVkIAB3jtJlHrWsN8jZBSJ+c372KPnSBFJVbu1aD3XFW8oKcgx9o 0m66nj0oqavu1ktezAgfXc5JR53BPFRZW6wikgyFqnIu8WfZawiw7jca+jZxCWHuCLsA nuLFe6H/ipBDQ+hRbgxuwgGnpuohz9AugocEx+T34pHe/Yiym8U/imj7frcLQMBPjWAK +YTNTw+8qJyWTYoDvtmicJX6McgfCfBuCJY0sgbxj8SGZyv6N05TGhmFYLrWjelQJqws 5IGiyIp0R+4vxQEEefNqwHyIGXle+my3dkIL2PBMDBHf1tCjUkcDAtCYD1i8SwPW+JwI aySw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776318945; x=1776923745; 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=i3fbFJldNRjzbBMbAUD3PVN4qI/fecARZIQQvM4SZFs=; b=DCKgiqxBXIRdpTBobUGX9uSj07cVqhdZdyyFSM57dXH0BWs359+PMVilSzzZyzJrw/ rKC2ujqpSYQRJVVkDPLlXaG5JrSlA2Y0c1SroMPtDi/gYI5R1wL8RsDWPWEiYyueAxj4 WgTF44CuGVGVkxOPBBcZnrDM9/C2f4b5G4pXwLvTmG2E7xAhLJt/CIBqn5Xr0NOlpIlU lEEMeItNQWqXwPiXBD4bSBET8CMCjcOIVlMTY/ByHW4OpbjZFetvZJ6UeNJP6PhVsgx/ MGLOXQpnNcND71tIohU7BzcAFCLvqMcvG6w5RZ+tqDDD1jrQcYMSbNOMVvUYovW/Qd62 1VDA== X-Forwarded-Encrypted: i=1; AFNElJ/X2CzvLUINg3DzodsXDcXKAtyUBj7kLfl/X9estTnzQCovqIEdDzpCa7k3t/zell2UYtu2U11ZlatfDMxz@postgresql.org X-Gm-Message-State: AOJu0Yxp91Z5cRlKTFv5cWpPPB3gFgVRAHDG1X17nzhJBONiCxR/ljxV UD1mhup1Fdp30Ko4Fx/5txNfl+m7kxQcX0sVjZ++7RPqHDB9PKO+JpzozLOEspF80iIv2BxHgtY l709UBtR4fIVTzX6brTgjxYEiQ1K4XVc= X-Gm-Gg: AeBDieshqPLGPu99w9pg/hGKJv2GcqWpJK1Uib6RVqGlWdMovidixaW5pQAlZJmJln0 4MjTI6mpTFev4ARW0MjrxDibVJVKMKUXIzvtninK4QuZ7llM0d03+w9MAtG72cl3EBJ+oFNUGXj 6y3NUHj/EIPKLXMnChKjUMWj79ismV6U78R7zZvA1lCvtHRBnyvJCraVBlLGwTeM3TKDwOqIRGQ kPA8CEw/+M6uNaAT+Ju2Phmj3ulLnfIWAFimrvqpbxCRLTX3I24Mhpwx9TewRFNF+dRFZgmOYR6 Bx8AB4rxdwuWz00V5Q== X-Received: by 2002:a05:7022:698a:b0:12a:b3c4:c3b6 with SMTP id a92af1059eb24-12c34ecea10mr14059790c88.21.1776318944528; Wed, 15 Apr 2026 22:55:44 -0700 (PDT) MIME-Version: 1.0 References: <1a32fc83-df78-4774-97dc-2bb06dbb16e9@uni-muenster.de> <3529398.1774273446@sss.pgh.pa.us> <4075754.1774378690@sss.pgh.pa.us> <67637cf8-8cbf-4f86-8775-52aa0329972d@uni-muenster.de> <402bbc8d-728b-4467-8024-31c2bc101ead@uni-muenster.de> <086c2108-0d46-4711-82df-19eb06a55326@uni-muenster.de> In-Reply-To: From: Soumya S Murali Date: Thu, 16 Apr 2026 11:26:09 +0530 X-Gm-Features: AQROBzAi1au-uwXvBe8Uubd2AS7x3gciD9WkL2bCQQNfHXL1KEXMdaF_AuLlTAY Message-ID: Subject: Re: Fix bug with accessing to temporary tables of other sessions To: Daniil Davydov <3danissimo@gmail.com> Cc: Jim Jones , Tom Lane , Stepan Neretin , PostgreSQL Hackers 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 Hi all, Thank you for the clarification and the updated patch. On Fri, Apr 10, 2026 at 8:58=E2=80=AFPM Daniil Davydov <3danissimo@gmail.co= m> wrote: > > Hi, > > On Fri, Apr 10, 2026 at 5:29=E2=80=AFPM Jim Jones wrote: > > > > > BTW, what do you think about making this comment less "concrete"? : > > > # SELECT via index scan from other session. > > > # Sequential scans are blocked at read_stream_begin_relation(); index= scans > > > # bypass that path entirely and reach ReadBufferExtended() in bufmgr.= c > > > # (nbtree's _bt_getbuf calls ReadBuffer directly for individual page = fetches). > > > # enable_seqscan=3Doff forces the planner to use the index. > > > > > > I mean that if the described logic changes, this comment will become = confusing. > > > We can describe the test in general words. For example : > > > # Index scans can use a different code path from the one sequential s= cans are > > > # following. Make sure that we cannot access other sessions' temp tab= les during > > > # index scan either. > > > > +1 > > > > Yeah, it's indeed too verbose. I guess these comments were originally > > just for me so I wouldn't get too confused along the way :) > > OK :) > > > > > I don't have anything else to add at this point. Unless there are any > > objections, I'll mark the CF entry as 'Ready for Committer.' > > > > Great, thank you! > > Please, see an updated set of patches (only perl test has been changed) : > 1) Rephrase the discussed comment. > 2) Use safe_psql whenever possible. > 3) Run pgperltidy. You were right. In my earlier testing I was not using the explicit temporary schema, which resulted in =E2=80=9Crelation does not exist=E2=80= =9D due to namespace resolution. I have now re-tested using the correct temporary schema of the owning session, and I can confirm that the patch behaves as expected. Cross-session access consistently throws: ERROR: cannot access temporary relations of other sessions Verified across multiple execution paths including SELECT, COUNT(*), JOINs, subqueries, and DML operations. Index scan paths (with seqscan disabled) are also correctly blocked with ERROR: cannot access temporary relations of other sessions. Same-session access continues to work as expected. Metadata access (pg_relation_size) behaves correctly and does not expose incorrect data. Cases where =E2=80=9Crelation does not exist=E2=80=9D appears are due to referencing an incorrect temp schema, which is expected. Overall, the patch correctly prevents access across all tested paths. Thank you for pointing this out. Regards, Soumya