Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gU3Jj-0001Ca-Cq for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Dec 2018 05:32:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gU3Jf-0004iY-Sh for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Dec 2018 05:32:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gU3Jf-0004hr-Lw for pgsql-hackers@lists.postgresql.org; Tue, 04 Dec 2018 05:32:15 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gU3JV-000846-VJ for pgsql-hackers@lists.postgresql.org; Tue, 04 Dec 2018 05:32:13 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id wB45W2EO006812 for ; Tue, 4 Dec 2018 14:32:02 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id A6AFBEA7D55; Tue, 4 Dec 2018 14:32:02 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 9217CEA704A; Tue, 4 Dec 2018 14:32:02 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.68]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 8DFCA400C26; Tue, 4 Dec 2018 14:32:02 +0900 (JST) Subject: Re: Tab completion for ALTER INDEX|TABLE ALTER COLUMN SET STATISTICS References: <20181128.131428.84607836.horiguchi.kyotaro@lab.ntt.co.jp> <54bd214b-d0d3-8654-e71f-45e7b4f979f0@lab.ntt.co.jp> <20181130.154654.56222303.horiguchi.kyotaro@lab.ntt.co.jp> From: Tatsuro Yamada Message-ID: Date: Tue, 4 Dec 2018 14:31:51 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181130.154654.56222303.horiguchi.kyotaro@lab.ntt.co.jp> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Kyotaro HORIGUCHI Cc: pgsql-hackers@lists.postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > At Wed, 28 Nov 2018 14:41:40 +0900, Tatsuro Yamada wrote in <54bd214b-d0d3-8654->>>> >>>> * tab_completion_alter_index_set_statistics.patch >>>> ======= >>>> There are two problems. You can use these DDL before testing. >>>> #create table hoge (a integer, b integer); >>>> #create index ind_hoge on hoge (a, (a + b), (a * b)); >>>> >>>> 1) Can't get column names >>>> >>>> # alter index ind_hoge alter column ... but can't >>>> # complete. >>> Currently the only continueable rule to the rule is SET >>> STATISTICS so we usually expect the number of an expression >>> column there. Even though we actually name every expression >>> column in an index, users hardly see the names. The names are in >>> the index column number order in your example, but what if the >>> name of the first column were 'foo'? >>> =# alter index ind_hoge2 alter column >>> expr expr1 foo >>> We could still *guess* what is expr or exrp1 but I don't think it >>> helps much. (Note: foo is not usable in this context as it's a >>> non-expression column.) >> >> Thanks for your comment. >> We can get column name by using "\d index_name" like this: >> >> # \d ind_hoge >> Index "public.ind_hoge" >> Column | Type | Key? | Definition >> --------+---------+------+------------ >> a | integer | yes | a >> expr | integer | yes | (a + b) >> expr1 | integer | yes | (a * b) >> btree, for table "public.hoge" >> >> So, I suppose that it's easy to understand what column is an >> expression column. > > Yeah, actually we can find them there, but I don't think it's > popular. I suppose that most of people are unconcious of the > names since they didn't named them. Moreover what makes me > uneasy with this is that it doesn't suggest attribute numbers, > which are firstly expected there. But anyway it is impossible > with readline since suggestions are sorted as strings. ("1", > "11", "12", "2" order, I don't think indexes often have that many > columns, though.) Okay, I understand. - For now, there is no column_number column on "\d index_name" result. So, if tab-completion suggested column_numbers, user can't match these easily. - Suggested column_name and column_number are sorted as a string by readline. These are an unnatural. But this is another topic on this thread. Example: # alter index ind_hoge alter column c expr expr1 expr10 expr11 expr2 expr3 expr4 expr5 expr6 expr7 expr8 expr9 >> Of course, user will get syntax error if user chose "a" column like a >> "foo" which is >> non-expression column as you mentioned. >> Probably, I will be able to fix the patch to get only expression >> columns from the index. >> Should I do that? > > Nope. That's just too-much. We are already showing unusable > suggestions in other places, for example, exiting tables for > CREATE TABLE. (It is useful for me as it suggests what should be > placed there.) I see. >> I prefer to use column name instead column number because >> there is no column number on \d index_name and \d+ index_name. > > Some people prefer names even if they are implicitly > given. Others (including myself) prefer numbers. So, we should better to vote to decide implementation of the tab-completion. Which is better to use either column_names or column_numbers? I'd like to hear opinions from others. :) >>>> 2) I expected column names for column numbers after "SET STATISTICS", >>>> but >>>> tab-completion gave schema names >>>> >>>> # alter index ind_hoge alter column expr SET STATISTICS >>>> information_schema. pg_catalog. pg_temp_1. pg_toast. >>>> pg_toast_temp_1. public. >>> This is the result of STATISTICS completion. SET >>> STATISTICS always doesn't take statistics name so this is safe. >> >> :) > > So I think it is reasonable. Thanks. Regards, Tatsuro Yamada