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 1tzH2b-0002f6-Ev for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 15:27:09 +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 1tzH2Z-007ZbV-H1 for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 15:27:07 +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 1tzH2Z-007ZbN-7f for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 15:27:07 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tzH2W-002FZh-0c for pgsql-hackers@postgresql.org; Mon, 31 Mar 2025 15:27:06 +0000 Received: from [192.168.11.3] (p1695135-ipoe.ipoe.ocn.ne.jp [118.0.92.134]) by oss.nttdata.com (Postfix) with ESMTPSA id 872AF6147E; Tue, 1 Apr 2025 00:26:58 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com Message-ID: Date: Tue, 1 Apr 2025 00:26:58 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query). To: Andrew Dunstan , "David G. Johnston" Cc: Kirill Reshke , jian he , PostgreSQL-development , Tom Lane , Michael Paquier References: <442e62f7-ef64-4df1-8453-d682fe9bdaa3@dunslane.net> <425ebe4b-06c5-4212-af68-fd0e5537c250@dunslane.net> Content-Language: en-US From: Fujii Masao In-Reply-To: <425ebe4b-06c5-4212-af68-fd0e5537c250@dunslane.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025/03/30 5:01, Andrew Dunstan wrote: > > On 2025-03-29 Sa 2:58 PM, David G. Johnston wrote: >> On Sat, Mar 29, 2025 at 11:56 AM Andrew Dunstan wrote: >> >> I don't believe that the premise supports the conclusion. >> >> >> Regardless, I do support this patch and probably any similar ones proposed in the future.  Do you have an opinion on that? >> >> > > In principle I think it would be good to have COPY materialized_view TO ... I haven't found any reasons to object to this patch for now, so I have no objections to this change. Regarding the patch, here are some review comments: + errmsg("cannot copy from materialized view when the materialized view is not populated"), How about including the object name for consistency with other error messages in BeginCopyTo(), like this? errmsg("cannot copy from unpopulated materialized view \"%s\"", RelationGetRelationName(rel)), + errhint("Use the REFRESH MATERIALIZED VIEW command populate the materialized view first.")); There seems to be a missing "to" just after "command". Should it be "Use the REFRESH MATERIALIZED VIEW command to populate the materialized view first."? Or we could simplify the hint to match what SELECT on an unpopulated materialized view logs: "Use the REFRESH MATERIALIZED VIEW command.". The copy.sgml documentation should clarify that COPY TO can be used with a materialized view only if it is populated. Wouldn't it be beneficial to add a regression test to check whether COPY matview TO works as expected? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION