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 1rjof0-0084AK-NF for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Mar 2024 23:02:23 +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 1rjoey-002FiV-Ka for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Mar 2024 23:02:21 +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 1rjoey-002FgL-BX for pgsql-bugs@lists.postgresql.org; Mon, 11 Mar 2024 23:02:20 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjoev-00411B-UG for pgsql-bugs@lists.postgresql.org; Mon, 11 Mar 2024 23:02:20 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4Ttsjh3VXLzyQL; Tue, 12 Mar 2024 01:02:16 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1710198136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=io4VUUPGoejIv2JoH4/tzYgR0NAEhzO5vCXhitgKRUg=; b=SIqG8oNMkc9KzocbOOUSuYOEHwgjf+ttXLM5OsiE4JOnEl2mq2g+fd+g+vkFKnGQtDnmq1 mkgvPSdfiTFJDJE277L51wu58Srro42DQIGb6aOKPZ2T4CJdkKEY0mBEJwwPjxAj5Lxe9j z0H2hs1Lu3mdmtw3NX2NR5jLPLca43o= ARC-Seal: i=1; s=meesny; d=iki.fi; t=1710198136; a=rsa-sha256; cv=none; b=DoElyYS4vXTbXVAO5sWpJ+Vf9ls+Zx/05JMq00JpX7zyr4VhO/IsN0w2NFoQkM5iJvA1ZP 60Cmf54ePTpiQb6GSR0d4Ipol2Gkrqmuqa+YfpeU2XH9TnsPTWh/Mtb9Bj+DB+VR4oDzlA S+DiOL9mCi63Q9JcJiU4MVdHcQ7kAg4= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1710198136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=io4VUUPGoejIv2JoH4/tzYgR0NAEhzO5vCXhitgKRUg=; b=GPwK4T2gdP6zWZMOIAMA6ZsJKIQ/8NHdymPALOk7a4+wFpS0OBYaAw0A1T9XBo/thbnFkj 010EybkSTRHkv+k9OabzRFsEIVExpg9yCKmsqzeFZ3QHyij5b3ew1lOFJGbSdfF2n5tNf/ bvF772ETqDnG17gy/VK856mhJObbDnQ= Message-ID: <36bb333d-13ec-4f8e-af33-48249ca2fe69@iki.fi> Date: Tue, 12 Mar 2024 01:02:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18387: Erroneous permission checks and/or misleading error messages with refresh materialized view Content-Language: en-US To: maxim.boguk@gmail.com, pgsql-bugs@lists.postgresql.org References: <18387-12041858d9efb6f6@postgresql.org> From: Heikki Linnakangas In-Reply-To: <18387-12041858d9efb6f6@postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/03/2024 22:10, PG Bug reporting form wrote: > Reproducer log (starting from interesting part): > test=# REFRESH MATERIALIZED VIEW CONCURRENTLY test_mv; > REFRESH MATERIALIZED VIEW > test=# alter materialized view test_mv owner to test_role; > ALTER MATERIALIZED VIEW > test=# REFRESH MATERIALIZED VIEW CONCURRENTLY test_mv; > ERROR: permission denied for table test > --what??? N1 > > --check that im not hallucinating > test=# select * from test; > val > ----- > 1 > (1 row) So far, this is working correctly. REFRESH MATERIALIZED VIEW runs with the permissions of the materialized view's owner. In this case, the owner is 'test_role', which doesn't have select permission on the table. > test=# revoke temporary on database test from public; > REVOKE > test=# \c test > You are now connected to database "test" as user "postgres". > test=# REFRESH MATERIALIZED VIEW CONCURRENTLY test_mv; > ERROR: permission denied to create temporary tables in database "test" > --what??? N2 That's interesting. REFRESH MATERIALIZED VIEW CONCURRENTLY uses temporary tables internally, which fails if the user doesn't have permissions to create temporary tables. I guess we need to allow creating such internal temporary tables, despite the missing permission. That'll need some careful analysis to make sure we don't accidentally allow creating other temporary tables... -- Heikki Linnakangas Neon (https://neon.tech)