Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aVIWr-0006yE-GD for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2016 12:45:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aVIWr-0005Xb-1L for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2016 12:45:25 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1aVIVY-0003yW-3D for pgsql-hackers@postgresql.org; Mon, 15 Feb 2016 12:44:04 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aVIVU-00034h-P8 for pgsql-hackers@postgresql.org; Mon, 15 Feb 2016 12:44:03 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 5554621C63A8; Mon, 15 Feb 2016 15:43:59 +0300 (MSK) Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U_2Roxou5SUi; Mon, 15 Feb 2016 15:43:57 +0300 (MSK) Received: from [192.168.27.188] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id AB39121C5C38; Mon, 15 Feb 2016 15:43:57 +0300 (MSK) Subject: Re: IF (NOT) EXISTS in psql-completion To: Kyotaro HORIGUCHI , pgsql-hackers@postgresql.org References: <20160205.170901.60679714.horiguchi.kyotaro@lab.ntt.co.jp> From: Artur Zakirov Message-ID: <56C1C80D.7020101@postgrespro.ru> Date: Mon, 15 Feb 2016 15:43:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160205.170901.60679714.horiguchi.kyotaro@lab.ntt.co.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 05.02.2016 11:09, Kyotaro HORIGUCHI wrote: > Hello, > > I considered how to make tab-completion robust for syntactical > noises, in other words, optional words in syntax. Typically "IF > (NOT) EXISTS", UNIQUE and TEMPORARY are words that don't affect > further completion. However, the current delimit-matching > mechanism is not so capable (or is complexty-prone) to live with > such noises. I have proposed to use regular expressions or > simplified one for the robustness but it was too complex to be > applied. > > This is another answer for the problem. Removal of such words > on-the-fly makes further matching more robust. > > Next, currently some CREATE xxx subsyntaxes of CREATE SCHEMA are > matched using TailMatching but it makes difficult the > options-removal operations, which needs forward matching. > > So I introduced two things to resolve them by this patch. > I did some tests with your patch. But I am not confident in tab-complete.c. And I have some notes: 1 - I execute git apply command and get the following warning: ../0001-Suggest-IF-NOT-EXISTS-for-tab-completion-of-psql.patch:302: trailing whitespace. /* warning: 1 line adds whitespace errors. This is because of superfluous whitespace I think. 2 - In psql I write "create table if" and press . psql adds the following: create table IF NOT EXISTS I think psql should continue with lower case if user wrote query with loser case text: create table if not exists 3 - Same with "IF EXISTS". If a write "alter view if" and press psql writes: alter view IF EXISTS -- Artur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers