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 1tyPyS-006RRC-5a for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Mar 2025 06:47:20 +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 1tyPyQ-0064wh-Es for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Mar 2025 06:47:18 +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 1tyPyQ-0064wY-4T for pgsql-hackers@lists.postgresql.org; Sat, 29 Mar 2025 06:47:18 +0000 Received: from mail-ua1-x932.google.com ([2607:f8b0:4864:20::932]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tyPyN-001qp6-39 for pgsql-hackers@postgresql.org; Sat, 29 Mar 2025 06:47:17 +0000 Received: by mail-ua1-x932.google.com with SMTP id a1e0cc1a2514c-86feb848764so1302778241.0 for ; Fri, 28 Mar 2025 23:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743230834; x=1743835634; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xVPHgRP9oKlhXBV0OfGXS2c5yvBr8cTcZSxye5KO2GE=; b=cbdOZoVyo4arhIVRzMa2OXL8NZRs83DaRar/fABlY3cow2ANmbNNVZIW4eZNPJH5a0 NByQXo0n12hNPO7gNpZpIyuanLRnu9F2wmP8vidb297/gAGgE6y9pKpxyzrlYadSoNqb 89ZEXbTlsIjbWGE1vOqvGQbCNZuZJN9MnIasteMjjPnpBx+2k2E2FrWvlfxZoyqDo7Ba k8Bd0oH+rHTaxCknnu/Wp+iizny4KZwCO4aIm8Phb3z+nnN/wgaZN9iBYqTo1x/T8VEV u2jX2NJkol9ERlUFOA4Rb/xWUSZljk1x2bsLWWmPMQHz86UG+jGSeOxSbxizZxHAnJft 1a2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743230834; x=1743835634; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xVPHgRP9oKlhXBV0OfGXS2c5yvBr8cTcZSxye5KO2GE=; b=nQl1+O9hDOwhT2vqyI/1+2RTGX/2UmQKuZ0H2TTl/CAlRc04IdKahHuhTJ2+oa+goS ZYZnInzYNPrrE2m8FbhhX1H5ySc+9Z/+bQgvB7IIaFn04HfjDmcmZr14DvzUTUKJ/qPV GlqFOgct19WZpWmwPj90YSJtj5Ir9L/F8P5KXPrTIJahdvAXFe5Ul1S0Yml3ILFQBev0 txU1fSAMGFMmJfsoUaYrm2t4KJxff16LtApn86GdDuTJyufvKoyiTkrVc3eId8iPO8RM IweE7Q6zORFnbrdML2AMjktBC3Qt/am8IVN3auuLabAn37sJ/+6FYYMrceJVTUOJPsyF ylXg== X-Gm-Message-State: AOJu0Yw+7EmVL1M9Ovg08QeR+slXoVFccMOPWKYsK9gQSsoXg/0BRn+p Fe2CqsGsHVzidUpsTTKpAXRDfWRikUdYv+MViWu1ZFpB7TT2ZBfdyzNskcNYjDf+U5D1NOuILNk iLA02ob41YhE4o+MCmwRaVZgVnPU= X-Gm-Gg: ASbGncteydbjqVz74nNs2tGpNoDqowGwT3FPeJUjZpvXjyj41CofMoVWY6nINqFJLK7 9+6GC7HVHSAN86AP9cgd5NfpA9j57Vzoo+8KT025sHi0z8vnPg7vCGEeMH+7tDB/d9xAu6TdxzS MwfiS0f6QM+vpKbO+bmHusnWAbpQbxSA4dckvhq6Z6mh5+ie8ioGVsAg== X-Google-Smtp-Source: AGHT+IFPeBw3i4JGCYQ54ZxWhv0Nk4nkItpawzeO8U/M12cNNI1lqc4e5n4AFz5XsAjdcb5Hf/0Ep75mOPUTLcTiwCs= X-Received: by 2002:a05:6102:d8f:b0:4c5:5aba:94bb with SMTP id ada2fe7eead31-4c6d37fede6mr1799207137.3.1743230833761; Fri, 28 Mar 2025 23:47:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: jian he Date: Sat, 29 Mar 2025 14:46:37 +0800 X-Gm-Features: AQ5f1JodznHzgO8SL6YFtF7MCuhhYZvWYeYbRDWVx8TDksSJgYEnUEYjkXUsE9w Message-ID: Subject: Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query). To: Kirill Reshke Cc: PostgreSQL-development , Tom Lane , Michael Paquier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 27, 2025 at 3:04=E2=80=AFAM Kirill Reshke wrote: > > > > hi. > > patch attached. > > also cc to Tom, > > since at that time, you are against the idea of ``COPY matview TO``. > > Hi! With this patch it is possible to COPY matview TO, but not regular > view, which is surprising. Let's fix that? create view v1 as select 1; copy v1 to stdout; if you specifying table name, not query, then { cstate =3D BeginCopyTo(pstate, rel, query, relid, stmt->filename, stmt->is_program, NULL, stmt->attlist, stmt->options); *processed =3D DoCopyTo(cstate); /* copy from database to file * } will use {table_beginscan, table_scan_getnextslot, table_endscan} to output the data. but views don't have storage, table_beginscan mechanism won't work. so i don't think this is possible for view.