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 1tr1Q0-00DbmZ-JM for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Mar 2025 21:09:12 +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 1tr1P0-008zzA-Ik for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Mar 2025 21:08:10 +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.94.2) (envelope-from ) id 1tr1P0-008zz2-8j for pgsql-hackers@lists.postgresql.org; Sat, 08 Mar 2025 21:08:10 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tr1Ow-001k5d-2U for pgsql-hackers@postgresql.org; Sat, 08 Mar 2025 21:08:09 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4750ab6a09bso31371241cf.0 for ; Sat, 08 Mar 2025 13:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741468086; x=1742072886; 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=pSfQqEFYc8mURnemrBtjaCgVFoBccGwx5XHMk+wDK0A=; b=Wf6Q0uBnVGXv4Vr4AGFJEG+la9LYy3wVijgr5CVokbBPQ9IkTS06RvgsO2DpUMxnxO 09lpgS05C37zlG7qEG9nFvi40VkXuamTxAaF6kmr4mAkwZ3QDgq2BRG9x5U9a25UyaS/ U/fCMV1s0qcoTy1dtG1vrML3sOuJGtkkxlS6WaTwYrL3de41VJoIfIaWhRmz+IDdJF0p kRCXRxMtEfgomHOjrLWmGG8r83wgAiBjczD5LQoYmIksQNgjHdxyQwWxXn2ZOUYib9By xPqsTIswgGuZCINYMvk8vJ+Yl0js56rZN16LJ7cwcJWsTas1MuteaIa6RllDzYbUt/5A Hpfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741468086; x=1742072886; 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=pSfQqEFYc8mURnemrBtjaCgVFoBccGwx5XHMk+wDK0A=; b=ja5HxtX6HSx6GnAFAtD84t89zlVoqvdfNu9pYnJJqc924/xwm4lkreo1MI41vQM9fQ z2KbEE+rW8aDAOveXM+uiW8BIvS+whdB8S0dIXV7ghmOgqCGrUSd+UlTL9V6OLDJ6fHs AObLwCoSvDye+I21BR50fP0iUACcwPqsgLFNHwFBKesD/LMjgG4iHslWmPkhS8BoYMpF BgqWs3XLiz+AZ37iUkbHuGafhjbsPucHlqzIdv1URlF1pnYclP5c0wNXfUz5nCsyAhHP AVA/hfe9gKjgLBRHMmlIOReTODpdKY2dX0Xpw1RUyqYUAKL/vRg9BHwFyxCFQEy7g1L8 25fg== X-Forwarded-Encrypted: i=1; AJvYcCVex5zeRillYyUo3HkrRliu+a49EpZcJQbDOPBJS0+AMBxk0z6BpiDDa3uyBA8cfhVXUAbpH8woSPTvKNHe@postgresql.org X-Gm-Message-State: AOJu0YyDAFHXCBCgt/D0ufHocUr2NtcoBdMMMnB3gC3MHV5fVpPJvwnc Uw8rfl6c+JAD67KIshDjsWMajjwgxz32wI+HugKKjXGaIZR/50ru X-Gm-Gg: ASbGncuqMUF4cyZInhWohI0R/53+rtXvT+p14pb82Eh4Lsimv7gQaJLan9kLNZr4uu/ +hOTNUKE5I/ltdmDq30jZkZ48E5/SIyTFD4jOZng/A99P1OwQvcMf1eLDMm2W1XLOyvsyu6sTM3 ke6zQjaYanJ0yl6YYL3+DCjNTXk3YbcIsC7ygxfAVyvv3yruEomd+BMkarBKiKgIWe6rtGKPRE6 3rNXoB0nmtPDZskf4O2VssUWtZd+Zq8dTWOuRzvU7l24oaXlRau6yEkxNEsnDr0GfMb9mGGvTlO o+gOPS7S5eCQF/vdDTbxIEEoNWcvZoy2O9cMdF5Do7WGkf19xYc8hGue/CGGNRsGBESCUapnI5c lZFKV1bIC/AVQxqMrE5ySJdxXHuMgZO7bQcY= X-Google-Smtp-Source: AGHT+IFaBDbh9sX5ODHeneXy6B1uACn9DqNOPcuqUHlxNNgluosZwDKfJglzzxKVNvdtr5Nq7su5iQ== X-Received: by 2002:a05:622a:1986:b0:471:ef27:a314 with SMTP id d75a77b69052e-4761097d5cemr130370751cf.18.1741468085929; Sat, 08 Mar 2025 13:08:05 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4766f2ef8f0sm6815041cf.80.2025.03.08.13.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Mar 2025 13:08:04 -0800 (PST) Date: Sat, 8 Mar 2025 15:08:02 -0600 From: Nathan Bossart To: Ayush Vatsa Cc: Robert Haas , Tom Lane , "David G. Johnston" , PostgreSQL Hackers Subject: Re: Clarification on Role Access Rights to Table Indexes Message-ID: References: <934709.1739829723@sss.pgh.pa.us> <1243984.1739894558@sss.pgh.pa.us> <1246906.1739896202@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Mar 08, 2025 at 08:34:40PM +0530, Ayush Vatsa wrote: >> I'm wondering whether setting missing_ok to true is correct here. IIUC we >> should have an AccessShareLock on the index, but I don't know if that's >> enough protection. > > Since we are already opening the relation with rel = relation_open(relOid, > AccessShareLock);, > if relOid does not exist, it will throw an error. If it does exist, we > acquire an AccessShareLock, > preventing it from being dropped. > > By the time we reach IndexGetRelation(), we can be confident that relOid > exists and is > protected by the lock. Given this, it makes sense to keep missing_ok = false > here. > > Let me know if you agree or if you see any scenario where > missing_ok = true would be preferable-I can update the condition > accordingly. Right, we will have a lock on the index, but my concern is that we won't have a lock on its table. I was specifically concerned that a concurrent DROP TABLE could cause IndexGetRelation() to fail, i.e., emit a gross "cache lookup failed" error. From a quick test and skim of the relevant code, I think your patch is fine, though. IndexGetRelation() retrieves the table OID from pg_index, so the OID should definitely be valid. And IIUC DROP TABLE first acquires a lock on the table and its dependent objects (e.g., indexes) before any actual deletions, so AFAICT there's no problem with using it in pg_class_aclcheck() and get_rel_name(), either. -- nathan