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 1u2xRh-008Jgi-0V for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Apr 2025 19:20:17 +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 1u2xRf-00GZaH-5k for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Apr 2025 19:20:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u2xRe-00GZZZ-Rf for pgsql-hackers@lists.postgresql.org; Thu, 10 Apr 2025 19:20:15 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2xRd-0046vK-0R for pgsql-hackers@postgresql.org; Thu, 10 Apr 2025 19:20:14 +0000 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-30effbfaf4aso11294721fa.3 for ; Thu, 10 Apr 2025 12:20:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744312811; x=1744917611; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iQS3abPN8WtUVytlSc3ASgpasmJaJ/KmzoJgfPWkTdc=; b=Hi0+EC2i1PO74tl7MQxliQwpyxRXFDragEYzIqtCMauVixNUhDcTXdy4IBJb3+olVd 6ntv4SVz7TfIoE7w3cmUhAzP1kaawzh37VdiWqiV+zoLmJgLva4cq/fk9G8MSTsQFlNz VzhxDbsBkcWm0WRlSJdJB7ziUcUL0S50U6l26jPbyp/QLjRQjZCmhmKRkA550p7ckIlZ 68RKokbvSAzRBU5NihxxlSYb/DMI1/4ZBG9xLW9HVGSwShaAe8jChzGFXF/UMs9vestx MvLW2MeJDovQCi5taljVYnDYAOTEx2PpeuX/sa518gtdR3wdlMS3BjwAMd6zXCCcJKkQ kMCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744312811; x=1744917611; h=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=iQS3abPN8WtUVytlSc3ASgpasmJaJ/KmzoJgfPWkTdc=; b=NknphsthFXqDTySbIldLVfVIF4he+OI8fd18k4EIpP2JTuvXgPTVljcgs7uKgWveBM /H1M9qCRZ8MIf4XvPvAq03PoxbnHt1W5BF6GdyIu11oPNaKyT87j4Y696GS3T3DVgTWf vfULUbaIlYLRSVflyqZ6jpXzKma/NIHlxoKIcGJdtejVafkTPOMZKotZGnmYITnzgU81 akQrMmrTQ54lgYd3rK2CxNJ9vZpkRu9tdpNPxj2W+DJZ1ay60iD/5OiB62nXjx0kN6py kPUG0wYn7n8nHUUklu93+oSfmAXtd7ln+L1P+EemuoKfZMQEVvZQPc6TzKaM9AseBapT 1t5A== X-Forwarded-Encrypted: i=1; AJvYcCXLEyyU5QDRtMMMv2c4PeNXm29dkcsu2eaomhhoQ/LVi/7GTvd0T4xf6qLbKxv3OUjq9gFyDOyuWGpMi/DC@postgresql.org X-Gm-Message-State: AOJu0YwK03PWZGvLNp56WPzUtpvqxTl0nNG5IphWtWEUXx3iD0UB4B6B GUXPZXlYiP+7hXxVKCjtXQ0Ppp/U60FcfSfpCj3uQqIjQK5yRfsp/VGJ2/b05O0zgAlV/7jsupt pOaF+AQPwoyvtL1jGKiL5eumAs5k= X-Gm-Gg: ASbGnctcFEHLvg07Q1+lZT389zOaO3NeyPI2USVKyAcedrWdw5CamH+yQBJhYSFK4QW Mjjn6drLxX5fl48iFSegwBuDIeehIGFK+TPRdyGVA353ab+ZdljRVjm6Ovbl326NE5m7dj/l0kg D0iOpGOWCeTyyZ5mtm1jyi2RymwO6/wOabie4K X-Google-Smtp-Source: AGHT+IG3Yt9LLnRQzYicwvpSCXTrsNfat0iq1ArjuoDizII8+cjjeyc8XNLFJiWXqE3Qg8dn+MMyFCbwgbkl+Ld6nK0= X-Received: by 2002:a05:651c:1594:b0:307:e0c3:5293 with SMTP id 38308e7fff4ca-30faccc1710mr17819421fa.36.1744312811170; Thu, 10 Apr 2025 12:20:11 -0700 (PDT) MIME-Version: 1.0 References: <433a4165-7091-4afc-bcb9-1c1f7a5af5e0@oss.nttdata.com> In-Reply-To: From: Kirill Reshke Date: Fri, 11 Apr 2025 00:19:59 +0500 X-Gm-Features: ATxdqUF4qk2Cqm7u16bmhdXP4fqrpTxv5BIBvSoGSiFabImI6ZVuKwxLWQuj21M Message-ID: Subject: Re: tab complete for COPY populated materialized view TO To: Fujii Masao Cc: jian he , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 10 Apr 2025 at 20:07, Fujii Masao wrote: > > > > On 2025/04/09 19:24, Kirill Reshke wrote: > > On Wed, 9 Apr 2025 at 14:45, Fujii Masao wrote: > >> > >> > >> > >> On 2025/04/09 18:25, Kirill Reshke wrote: > >>> On Wed, 9 Apr 2025 at 13:23, jian he wrote: > >>>> > >>>> hi. > >>>> > >>>> we allow the "COPY table TO" command to copy rows from materialized > >>>> views in [1]. > >>>> The attached patch is to add a tab complete for it. > >>>> > >>>> [1] https://git.postgresql.org/cgit/postgresql.git/commit/?id=534874fac0b34535c9a5ab9257d6574f78423578 > >>> > >>> Hi! > >>> Patch works good for me, but I noticed that psql COPY suggests > >>> partitioned relation both with and without this patch. Maybe that's > >>> not a big problem, if [0] will be pushed. > >> > >> Is the partitioned table currently tab-completed for the COPY FROM case? > > > > If I'm not mistaken, yes. I double checked. > > > >> INSTEAD OF INSERT triggers - though maybe that's overkill? > > > > That's wild to me, psql tab completions feature designed to support > > postgresql not fully, but in frequent cases. So maybe we should keep > > it stupud. > > I agree that it's reasonable to exclude such rarely used objects from > tab-completion. How about including just tables, partitioned tables, > foreign tables, and materialized views? > I've attached a patch for that. > > Regards, Patch is ok. However... > If we aim to support tab-completion for all valid targets of both COPY TO and COPY FROM, shouldn't foreign tables also be included? Ah.. Sorry I missed this part of your message initially. No, foreign tables are not supported: ``` reshke=# CREATE FOREIGN TABLE ft (i int) server zz OPTIONS ( filename 'zz.csv', format 'csv' ); reshke=# copy ft to stdout; ERROR: cannot copy from foreign table "ft" HINT: Try the COPY (SELECT ...) TO variant. ``` So we will tab complete for cases that yet to be supported (foreign tables and partitioned tables); What's funny is that copying foreign tables using MV works fine ``` reshke=# create materialized view mv as table ft; SELECT 1 reshke=# copy mv to stdout; 228 ``` -- Best regards, Kirill Reshke