Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akqLk-0000Uu-Sl for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2016 09:54:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1akqLk-000386-FQ for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2016 09:54:12 +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_2) (envelope-from ) id 1akqLj-00037p-D8 for pgsql-hackers@postgresql.org; Tue, 29 Mar 2016 09:54:11 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akqLc-0006u6-5b for pgsql-hackers@postgresql.org; Tue, 29 Mar 2016 09:54:11 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 3013C21C757C; Tue, 29 Mar 2016 12:54:02 +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 2LG43p4rineT; Tue, 29 Mar 2016 12:54:00 +0300 (MSK) Received: from [192.168.27.188] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 4E18321C754F; Tue, 29 Mar 2016 12:54:00 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1459245240; bh=fvw3RGSJrc9m7oW/MSRQM9zINb6Z7H2Fyb4/6yqw60c=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=BMdGDHJnkp024+aV66Th+zDfjv3guCCGMGOkSU2/PVQsHn5CaNvVEkiiT46PXdoZ4 zTxUop9wXLasr8Hv4nxy+ve0FO2uJK9B6zdGiQ9HwJkSRmRL5xHwkn+pd8KwLQ5LQL d1RHau3jk9WSP5VHX/RinAPipgNARysYyGfqmBKw= Subject: Re: IF (NOT) EXISTS in psql-completion To: Pavel Stehule , Kyotaro HORIGUCHI References: <56F17977.8040503@pgmasters.net> <20160329.154307.130628969.horiguchi.kyotaro@lab.ntt.co.jp> Cc: David Steele , Peter Eisentraut , PostgreSQL Hackers From: Artur Zakirov Message-ID: <56FA50B9.7000107@postgrespro.ru> Date: Tue, 29 Mar 2016 12:54:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------010007080802060100050904" X-Pg-Spam-Score: -3.0 (---) 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 This is a multi-part message in MIME format. --------------010007080802060100050904 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 29.03.2016 10:59, Pavel Stehule wrote: > Hi > > 2016-03-29 8:43 GMT+02:00 Kyotaro HORIGUCHI > >: > > Thank you Pavel, David. > > Thank you for pointing syntaxes to be addressed. Most of the are > addressed in the attached patch. > > > At Tue, 22 Mar 2016 12:57:27 -0400, David Steele > > wrote in > <56F17977.8040503@pgmasters.net > > > Hi Kyotaro, > > > > On 3/18/16 3:22 AM, Pavel Stehule wrote: > > > > > I am looking this patch. It looks well, but this feature doesn't > > > respect upper or lower chars. It enforce upper chars. This is not > > > consistent with any other autocomplete. > > As mentioned before, upper-lower problem is an existing > issue. The case of the words in a query result list cannot be > edited since it may contain words that should not be changed, > such as relation names. So we can address it only before issueing > a query but I haven't found simple way to do it. > > > This is unpleasant. I am sorry. I had very uncomfortable feeling from > this behave. I am thinking so it should be solvable - you have to > convert only keyword IF EXISTS or IF NOT EXISTS. Maybe there are not > trivial solution, but this should be fixed. > Hello, Can we do something like in the patch? This patch should be applied after the patch "0001-Suggest-IF-NOT-EXISTS-for-tab-completion-of-psql_v3.patch". -- Artur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company --------------010007080802060100050904 Content-Type: text/x-patch; name="tab-complete.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tab-complete.patch" diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 73c5601..ed4ff09 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -153,6 +153,7 @@ do { \ do { \ completion_squery = &(query); \ completion_charp = addon; \ + completion_case_sensitive = false; \ matches = completion_matches(text, complete_from_schema_query); \ } while (0) @@ -3754,7 +3755,17 @@ _complete_from_query(int is_schema_query, const char *text, int state) while (list_index < PQntuples(result) && (item = PQgetvalue(result, list_index++, 0))) if (pg_strncasecmp(text, item, byte_length) == 0) - return pg_strdup(item); + { + if (completion_case_sensitive) + return pg_strdup(item); + else + + /* + * If case insensitive matching was requested initially, + * adjust the case according to setting. + */ + return pg_strdup_keyword_case(item, text); + } } /* If nothing matches, free the db structure and return null */ --------------010007080802060100050904 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------010007080802060100050904--