Re: Tab completion for ALTER INDEX|TABLE ALTER COLUMN SET STATISTICS

From: Tatsuro Yamada <yamada(dot)tatsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Tab completion for ALTER INDEX|TABLE ALTER COLUMN SET STATISTICS
Date: 2019-01-28 05:18:25
Message-ID: b58a78fa-81ce-186f-f0bc-c1aa93c46cbf@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Peter,

On 2019/01/25 20:09, Peter Eisentraut wrote:
> On 26/12/2018 07:07, Tatsuro Yamada wrote:
>> +#define Query_for_list_of_attribute_numbers \
>> +"SELECT attnum "\
>> +" FROM pg_catalog.pg_attribute a, "\
>> +" pg_catalog.pg_class c "\
>> +" WHERE c.oid = a.attrelid "\
>> +" AND a.attnum > 0 "\
>> +" AND NOT a.attisdropped "\
>> +" /* %d %s */" \
>> +" AND a.attrelid = (select oid from pg_catalog.pg_class where relname = '%s') "\
>> +" AND pg_catalog.pg_table_is_visible(c.oid) "\
>> +"order by a.attnum asc "
>
> This needs a bit of refinement. You need to handle quoted index names
> (see nearby Query_for_list_of_attributes), and you should also complete
> partial numbers (e.g., if I type 1 then complete 10, 11, ... if
> appropriate).

Thanks for the comments.
I modified the patch to handle the both:
- quoted index names
- complete partial numbers

e.g.
-----
# create table hoge (a integer, b integer, c integer);
# create index ind_hoge on hoge(a, b, c, (c*1), (c*2), (c*3), (c*4), (c*5), (c*6), (c*7), (c*8), (c*9));
# create index "ind hoge2" on hoge(c, b, a, (c*1), (c*2), (c*3), (c*4), (c*5), (c*6), (c*7), (c*8), (c*9));

# alter index "ind hoge2" alter column
1 10 11 12 2 3 4 5 6 7 8 9
# alter index "ind hoge2" alter column 1
1 10 11 12

# alter index ind_hoge alter column
1 10 11 12 2 3 4 5 6 7 8 9
# alter index ind_hoge alter column 1
1 10 11 12
-----

Please find attached file. :)

Regards,
Tatsuro Yamada

Attachment Content-Type Size
psql-tab-alter-column-colnumber-wip4.patch text/x-patch 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-01-28 05:28:30 Re: Emacs vs pg_indent's weird indentation for function declarations
Previous Message Andrew Gierth 2019-01-28 04:55:06 Re: pgsql: Avoid creation of the free space map for small heap relations.