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.94.2) (envelope-from ) id 1v6y1a-00CieE-SA for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Oct 2025 21:18:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v6y1Y-008jFB-KI for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Oct 2025 21:18:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v6y1Y-008jF1-1D for pgsql-hackers@lists.postgresql.org; Thu, 09 Oct 2025 21:18:09 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6y1V-000vWe-2y for pgsql-hackers@postgresql.org; Thu, 09 Oct 2025 21:18:08 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-42f94689e73so8260505ab.0 for ; Thu, 09 Oct 2025 14:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760044686; x=1760649486; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8TuIpsx8Sxwy/eeJMxcpr4KT4acgr56K7xVt9hb+Nco=; b=G9DzoE410m9Adcvo2tm2M3LPUuSRar6T6Xjy1HPtAULiG7nJS1/Ms5ovqJfRs3gX/5 TNQ9mRg4cm3MqJJrbd3U01APLV/nEGD+NcuTEldYb8n18tAOhwS2T70w/xHyG3csouPj XHk4Hta5TGlxYGtQWQlzr176hf0t+nqloicwqVSBvPfu72AiQ7S5GwI8B9Tq8ll9Vwlj HlmHQm9LT5RvJBfgsxyGMqDkxV6/yaqlt4naoiLqEMr4AT2x3FwV0jNBHujW2SxhrTuo LOMyi0JEDrGXHRSDJlTf/4PeVaxqRMXRrCtuFeL0XgmLoQSdRUY+z0RbIpN8wHiXDyJ/ rwEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760044686; x=1760649486; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8TuIpsx8Sxwy/eeJMxcpr4KT4acgr56K7xVt9hb+Nco=; b=kqk3RZNnEVgdPiZ/hm0ydtn8cy7TKtEdxuthU2GzzRRKIJxoWtaiRAkrL7wU5rCrRb J8MdnviiS/0aXrRZF6jlbEZlj6YESfZOdgKwJmMZQQUvKYAFGRlAueNo7xvJ+tmrJzdw 0mnWPSGOgtTgr3me7jBUabVw2b/SixeHroXfgGrfH+3K1/NJ6Ntj4caaqjdiFvZ4p0z7 Uv9hB/PNiZ+o0ONROpga1CelDJHojqwIJVmYu9lQMiggzM0XFoU4SlJJIUBMFGTAqiYY CXwiO+FdRuvZ0bkMjXiGApI58+LC3MWpPQMtYGFrEXbq3cP2vf3KbRpF9ArZLiHU9eqb Uo1A== X-Forwarded-Encrypted: i=1; AJvYcCVJ0wNUWZqmbAmzwZHfjd7wbg8G6l1sdtyEF0l8ktMLzAlarRV2uWiP53NXtJfg62DF9kPf11RDhBtwfjTE@postgresql.org X-Gm-Message-State: AOJu0Yz7v10bVJd7zWLKiwhLaVq6S83CT0/G6diktPj91jZFBWduuyEC +x3ax9181phWS1EnuFjEF2y49pgP/nh1rcRhMZXfBh9yWrVWZ9LC3ju+ X-Gm-Gg: ASbGncvx7K904hMRlWhs/GHFAc8RXR5XPsGyJfolKOWKTqLwStomQPueYdaANfXZ/4Z ZopKU0KX3kfUEvYKZLFlsWz+YfhDGBQl0wrMQxn3qt/sRUNX0ecAHCs6k3rELPhrjjXDjCRM5Pb e0/0H1d7YsJ1rUlGNfF3ibvybWLgOrJZ2AOFOKzeqdBpBuTdAbDLTVe5j+6wB1V1Y7UWDwkFIaU IsqcOImOPMiCvmyzPw6jZ/ZgYaF9T8K1AkJ/t6n7zdyFl8U3VumC1Olp8dLF70cQgCTt618gf3c pWpkXr7aL5/yBEg3ofrvWiG5Bdrmt8eUZQ0aSDZ7Q0V0zO+0G1w8Eti+FkyjFnxg85b9i45fsLu Ib/MGlHo6/NTw/C6wLtlRmBiaXVnjkH94JPQi4LEihiF2LBrNOwpannS681PaAjQns0Y1ZK1xYK eyjTvuQ62iJfvdY72ZoTCcvBOak7OQadn9zna2eiVy0SkZpbk= X-Google-Smtp-Source: AGHT+IEX6GKBOm7oWm9Nz7i6sFyEotXELSf7Rt0a3HfVux2ybVhYUUpMiRq8AtlOIcwSGAgRu+3NeA== X-Received: by 2002:a05:6e02:1fca:b0:425:8d9b:c430 with SMTP id e9e14a558f8ab-42f873559d4mr96357425ab.6.1760044686080; Thu, 09 Oct 2025 14:18:06 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-58f729ccf54sm186025173.51.2025.10.09.14.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 14:18:05 -0700 (PDT) Date: Thu, 9 Oct 2025 16:18:03 -0500 From: Nathan Bossart To: Jeff Davis Cc: Tom Lane , Ayush Vatsa , Robert Haas , "David G. Johnston" , PostgreSQL Hackers Subject: Re: Clarification on Role Access Rights to Table Indexes Message-ID: References: <149429.1741472260@sss.pgh.pa.us> <279947.1741535285@sss.pgh.pa.us> <3432170.1758730414@sss.pgh.pa.us> <8af53c6e8992aa706e63aafe60a3bcf100b524d1.camel@j-davis.com> <7b0e2774cdcc8f522ac82f64a8d7266f353a5094.camel@j-davis.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="w7OfHyILDI1ykikj" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --w7OfHyILDI1ykikj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 09, 2025 at 10:39:32AM -0500, Nathan Bossart wrote: > On Wed, Oct 08, 2025 at 08:28:01PM -0700, Jeff Davis wrote: >> Actually, now I'm unsure. v4-0001 is taking a lock on the table before >> checking privileges, whereas v4-0002 is going to some effort to avoid >> that. Is that because the latter is taking a ShareLock? > > I was confused by this, too. We seem to go to great lengths to avoid > taking a lock before checking permissions in RangeVarGetRelidExtended(), > but in pg_prewarm() and this stats code, we are taking the lock first. > pg_prewarm() can't use RangeVarGetRelid because you give it the OID, but > I'm not seeing why stat_utils.c can't use it. We should probably fix this. > I wouldn't be surprised if there are other examples. I spent some time trying to change pg_prewarm() to check permissions before locking and came up with the attached. There are certainly issues with the patch, but this at least demonstrates the complexity required. I'm tempted to say that this is more trouble than it's worth, but it does feel a little weird to leave it as-is. There's a similar pattern in get_rel_from_relname() in dblink.c, which also seems to only be used with an AccessShareLock (like pg_prewarm). My best guess from reading lots of code, commit messages, and old e-mails in the archives is that the original check-privileges-before-locking work was never completed. I'm currently leaning towards continuing with v4 of the patch set. 0001 and 0003 are a little weird in that a concurrent change could lead to a "could not find parent table" ERROR, but IIUC that is an extremely remote possibility. -- nathan --w7OfHyILDI1ykikj Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-pg_prewarm-privilege-test.patch