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 1sriyi-0041Zi-NC for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Sep 2024 19:07:41 +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 1sriyg-00Bvig-Aj for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Sep 2024 19:07:39 +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 1sriyf-00BviS-Qi for pgsql-bugs@lists.postgresql.org; Fri, 20 Sep 2024 19:07:39 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sriyd-000EZY-0U for pgsql-bugs@lists.postgresql.org; Fri, 20 Sep 2024 19:07:38 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-7db90a28cf6so1276494a12.0 for ; Fri, 20 Sep 2024 12:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1726859254; x=1727464054; darn=lists.postgresql.org; h=user-agent: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=0i7MjZMCbPp6d3w1XAEuiyKwJ2kTlnOdhjX08mLk0Rg=; b=LTc/Vdvkl3cEorEw1+QO7ha70CVZVQuqRUn3iJxxERNvk/ypgJ3X08GMKtiXtwnoLL 6BzTEnZY691BEt0dbd8vtlZP2Hh6/iEQn7sSL1gMtIqSBxg013oyeIaih2w4ktvY/kPf cLDAAbzcX5mtT5B/4uvmlmDHvAtovvjCZujHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726859254; x=1727464054; h=user-agent: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=0i7MjZMCbPp6d3w1XAEuiyKwJ2kTlnOdhjX08mLk0Rg=; b=MMyWje403Gu+NnSu/SNavLQMwblMU8VNKSDb+x6yryCqH97mkNPPdvRJycykVUjtbV q/Xwne1SMmPgheBSRlDwgGkEkVSgrCHUQ9RbtQlXrFT1BLTZTSni2XRdB0AKHoyA+bGZ fOy76UuzPcZRvsBtYMtotBGKnwzgqLwrdnSrefjI4v+2TSyLwtNfPjETbAqjX+pBk1dp 5i3g1meKpnPBoaZMPZ763BVZqwXyfdj6xQ4FEB/VXREYa/ukueTELmb4J3HoMgY513Uw /WpF4VN7MhIBuQ7qy2mIeB+CYZs/im35YXyVgGmUWMdnOTkIdj/hUxp2mAveFkRg1P6Y 5GHg== X-Gm-Message-State: AOJu0YwKSNQAodRBNVAIxxi6Imx7J2WxId94iVHBv9EWq79JJ5/XrAdO smnbYX6lXIc09AL53nHSN7mSRXkKBn0NFmzYRr7lB3vguidTPhZ66utjRhbu/A== X-Google-Smtp-Source: AGHT+IEfbtMEIbav/DJPhK7cP+XA+bMZBt7Ss5pM0AdmhkXHP10z8bfMrD5+DSoMWQyO8SlMSkvtyw== X-Received: by 2002:a17:90b:2751:b0:2dd:4f70:1654 with SMTP id 98e67ed59e1d1-2dd7ece315amr6636345a91.2.1726859254163; Fri, 20 Sep 2024 12:07:34 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd6ef93531sm4487070a91.48.2024.09.20.12.07.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Sep 2024 12:07:33 -0700 (PDT) Date: Fri, 20 Sep 2024 12:07:31 -0700 From: Noah Misch To: vaibhave postgres , nathandbossart@gmail.com Cc: pgsql-bugs@lists.postgresql.org, vsekar@microsoft.com Subject: Re: vacuumdb: permission denied for schema "pg_temp_7" Message-ID: <20240920190731.37.nmisch@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Jul 06, 2024 at 05:19:39PM +0530, vaibhave postgres wrote: > Repo steps > > 1. Create a temporary table > > sample => CREATE TEMPORARY TABLE temp_employees ( > > id SERIAL PRIMARY KEY, > > name VARCHAR(100), > > position VARCHAR(50), > > salary NUMERIC(10, 2) > > ); > > CREATE TABLE > > sample => \dt pg_temp_*.* > > List of relations > > Schema | Name | Type | Owner > > -----------+----------------+-------+---------- > > pg_temp_7 | temp_employees | table | vaibhave > > (1 row) > > > 2. Run vacuumdb > > vacuumdb: vacuuming database "sample" > > vacuumdb: error: processing of database " sample " failed: ERROR: > > permission denied for schema pg_temp_7 > > > Temporary tables can only be accessed within the session which created > them. They should be skipped during vacuumdb. This happens when a non-superuser runs vacuumdb while a different user has a temp table. This isn't specific to temp tables; it arises for any schema on which the vacuumdb user lacks USAGE privilege. v12 introduced this regression. I suspect it started when commit e0c2933 "Use catalog query to discover tables to process in vacuumdb" switched vacuumdb from a simple "VACUUM;" command to per-table commands. Non-superuser vacuumdb must be rare indeed for this to go unnoticed long enough to leave all supported branches affected. > Suggested Patch is attached > From ca78eb35b59cc398a37d36c27373dd64eb3a8f77 Mon Sep 17 00:00:00 2001 > From: VaibhaveS > Date: Sat, 6 Jul 2024 17:15:33 +0530 > Subject: [PATCH] Skip temporary tables in vacuumdb. > > --- > src/bin/scripts/vacuumdb.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c > index 7138c6e97e..3dbda53b72 100644 > --- a/src/bin/scripts/vacuumdb.c > +++ b/src/bin/scripts/vacuumdb.c > @@ -733,6 +733,11 @@ vacuum_one_database(ConnParams *cparams, > has_where = true; > } > > + /* > + * Exclude temporary tables > + */ > + appendPQExpBufferStr(&catalog_query, " AND c.relpersistence <> 't'"); That helps, but we'd probably want to do something more general about vacuumdb and schema USAGE permission. Thanks for the report.