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: 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: 2018-12-26 06:07:33
Message-ID: e52059f6-8ef4-ca9d-d14c-1c980df4ddfb@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

On 2018/12/26 14:50, Tatsuro Yamada wrote:
> On 2018/12/26 14:15, Michael Paquier wrote:
>> On Wed, Dec 26, 2018 at 02:05:26PM +0900, Tatsuro Yamada wrote:
>>> Do you mean my "fix_manual_of_alter_index_v2.patch"?
>>
>> Nope.  This patch is only a proposal for the documentation.  The main
>> patch to extend psql completion so as column numbers are suggested
>> fails to apply.
>
> I rebased the WIP patch. :)
>
> * Following query is added to get attribute numbers of index,
>   however its result contains not only expression columns but also other columns.
>
> * I'm not sure what should I use "%d" and first "%s" in the query, so I commented out: /* %d %s */.
>   I know this is ugly.. Do you know how to use?
>
> +#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 "

I modified the patch to remove unusable condition.

========
# 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));

# \d ind_hoge
Index "public.ind_hoge"
Column | Type | Key? | Definition
--------+---------+------+------------
a | integer | yes | a
b | integer | yes | b
c | integer | yes | c
expr | integer | yes | (c * 1)
expr1 | integer | yes | (c * 2)
expr2 | integer | yes | (c * 3)
expr3 | integer | yes | (c * 4)
expr4 | integer | yes | (c * 5)
expr5 | integer | yes | (c * 6)
expr6 | integer | yes | (c * 7)
expr7 | integer | yes | (c * 8)
expr8 | integer | yes | (c * 9)
btree, for table "public.hoge"

# alter index ind_hoge alter column <tab!>
1 10 11 12 2 3 4 5 6 7 8 9

# alter index ind_hoge alter column 1 <tab!>
1 10 11 12

# alter index ind_hoge alter column 10 <tab!>
alter index ind_hoge alter COLUMN 10 SET STATISTICS
========

Thanks,
Tatsuro Yamada

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-12-26 06:24:01 Re: Don't wake up to check trigger file if none is configured
Previous Message Pavel Stehule 2018-12-26 06:02:04 Re: plpgsql plugin - stmt_beg/end is not called for top level block of statements