Thread

Commits

  1. psql: Improve tab completion for COPY command.

  2. Allow "COPY table TO" command to copy rows from materialized views.

  1. tab complete for COPY populated materialized view TO

    jian he <jian.universality@gmail.com> — 2025-04-09T08:23:06Z

    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
    
  2. Re: tab complete for COPY populated materialized view TO

    Kirill Reshke <reshkekirill@gmail.com> — 2025-04-09T09:25:54Z

    On Wed, 9 Apr 2025 at 13:23, jian he <jian.universality@gmail.com> 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 <tab> suggests
    partitioned relation both with and without this patch. Maybe that's
    not a big problem, if [0] will be pushed.
    
    
    [0] https://www.postgresql.org/message-id/CACJufxHjBPrsbNZAp-DCmwvOE_Gkogb%2Brhfqqe1%3DS5cOHR-V7Q%40mail.gmail.com
    
    -- 
    Best regards,
    Kirill Reshke
    
    
    
    
  3. Re: tab complete for COPY populated materialized view TO

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2025-04-09T09:45:08Z

    
    On 2025/04/09 18:25, Kirill Reshke wrote:
    > On Wed, 9 Apr 2025 at 13:23, jian he <jian.universality@gmail.com> 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 <tab> 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 we aim to support tab-completion for all valid targets of both COPY TO
    and COPY FROM, shouldn't foreign tables also be included? And what about
    views with INSTEAD OF INSERT triggers - though maybe that's overkill?
    
    Regards,
    
    -- 
    Fujii Masao
    Advanced Computing Technology Center
    Research and Development Headquarters
    NTT DATA CORPORATION
    
    
    
    
    
  4. Re: tab complete for COPY populated materialized view TO

    Kirill Reshke <reshkekirill@gmail.com> — 2025-04-09T10:24:00Z

    On Wed, 9 Apr 2025 at 14:45, Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
    >
    >
    >
    > On 2025/04/09 18:25, Kirill Reshke wrote:
    > > On Wed, 9 Apr 2025 at 13:23, jian he <jian.universality@gmail.com> 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 <tab> 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.
    
    -- 
    Best regards,
    Kirill Reshke
    
    
    
    
  5. Re: tab complete for COPY populated materialized view TO

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2025-04-10T15:07:11Z

    
    On 2025/04/09 19:24, Kirill Reshke wrote:
    > On Wed, 9 Apr 2025 at 14:45, Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
    >>
    >>
    >>
    >> On 2025/04/09 18:25, Kirill Reshke wrote:
    >>> On Wed, 9 Apr 2025 at 13:23, jian he <jian.universality@gmail.com> 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 <tab> 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,
    
    -- 
    Fujii Masao
    Advanced Computing Technology Center
    Research and Development Headquarters
    NTT DATA CORPORATION
    
  6. Re: tab complete for COPY populated materialized view TO

    Kirill Reshke <reshkekirill@gmail.com> — 2025-04-10T19:19:59Z

    On Thu, 10 Apr 2025 at 20:07, Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
    >
    >
    >
    > On 2025/04/09 19:24, Kirill Reshke wrote:
    > > On Wed, 9 Apr 2025 at 14:45, Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
    > >>
    > >>
    > >>
    > >> On 2025/04/09 18:25, Kirill Reshke wrote:
    > >>> On Wed, 9 Apr 2025 at 13:23, jian he <jian.universality@gmail.com> 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 <tab> 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
    
    
    
    
  7. Re: tab complete for COPY populated materialized view TO

    David G. Johnston <david.g.johnston@gmail.com> — 2025-04-10T19:33:56Z

    On Thursday, April 10, 2025, Kirill Reshke <reshkekirill@gmail.com> wrote:
    
    > On Thu, 10 Apr 2025 at 20:07, Fujii Masao <masao.fujii@oss.nttdata.com>
    > wrote:
    > >
    > >
    > >
    > > On 2025/04/09 19:24, Kirill Reshke wrote:
    > > > On Wed, 9 Apr 2025 at 14:45, Fujii Masao <masao.fujii@oss.nttdata.com>
    > wrote:
    > > >>
    > > >>
    > > >>
    > > >> On 2025/04/09 18:25, Kirill Reshke wrote:
    > > >>> On Wed, 9 Apr 2025 at 13:23, jian he <jian.universality@gmail.com>
    > 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 <tab> 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...
    
    
    I concur with the premise of the patch.  Tab-complete is going to happen
    before we know whether to/from is specified so the syntax limits our smarts
    here.
    
    
    > > 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:
    
    
    They are supported for the From variant; valid completions need only
    satisfy one of to/from, not both.
    
    
    >
    > 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
    > ```
    >
    
    I don’t get why this is “funny” or otherwise surprising.
    
    David J.
    
  8. Re: tab complete for COPY populated materialized view TO

    Kirill Reshke <reshkekirill@gmail.com> — 2025-04-10T19:37:56Z

    On Fri, 11 Apr 2025 at 00:33, David G. Johnston
    <david.g.johnston@gmail.com> wrote:
    >
    > They are supported for the From variant; valid completions need only satisfy one of to/from, not both.
    >
    
    Thank you. If so, then WFM, and I don't have any more objections.
    
    -- 
    Best regards,
    Kirill Reshke
    
    
    
    
  9. Re: tab complete for COPY populated materialized view TO

    Fujii Masao <masao.fujii@oss.nttdata.com> — 2025-06-30T09:39:09Z

    
    On 2025/04/11 4:37, Kirill Reshke wrote:
    > On Fri, 11 Apr 2025 at 00:33, David G. Johnston
    > <david.g.johnston@gmail.com> wrote:
    >>
    >> They are supported for the From variant; valid completions need only satisfy one of to/from, not both.
    >>
    > 
    > Thank you. If so, then WFM, and I don't have any more objections.
    
    I've pushed the patch. Thanks!
    
    Regards,
    
    -- 
    Fujii Masao
    NTT DATA Japan Corporation