Hello, this is the second patch plitted out. This allows multibyte names to be completed in psql.
At Fri, 06 Nov 2015 11:47:17 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi.kyot...@lab.ntt.co.jp> wrote in <20151106.114717.170526268.horiguchi.kyot...@lab.ntt.co.jp> > At Thu, 5 Nov 2015 18:32:59 +0900, Amit Langote > <langote_amit...@lab.ntt.co.jp> wrote in <563b224b.3020...@lab.ntt.co.jp> > > On 2015/11/05 18:10, Kyotaro HORIGUCHI wrote: > > > Hello. I don't know whether this is a bug fix or improvement, > > > > Would it be 50-50? :-) > > Yeah, honestly saying, I doubt that this is valuable but feel > uneasy to see some of the candidates vanish as completon proceeds > for no persuasive reason. The current version of tab-completion failed to complete names with multibyte characters. =# create table いろは (あ int); =# create table いこい (あ int); =# drop table <tab> "いろは" hint_plan. pg_toast. "いこい" information_schema. pg_toast_temp_1. ALL IN TABLESPACE pg_catalog. public. dbms_stats. pg_temp_1. postgres=# alter table "い =# drop table "い<tab> =# drop table "い /* No candidate offered */ This is because _complet_from_query counts the string length in bytes, instead of characters. With this patch the candidates will appear. =# drop table "い<tab> "いこい" "いろは" postgres=# drpo table "い regards, -- Kyotaro Horiguchi NTT Open Source Software Center
>From 6c6871f25eb9f7e5bdcc1005dab4cdd29a15b7d0 Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi <horiguchi.kyot...@lab.ntt.co.jp> Date: Fri, 26 Feb 2016 14:24:42 +0900 Subject: [PATCH] Fix identifier completion with multibyte characters. _copletion_from_query wrongly takes the byte length of the given text instead of character length. This prevents multibyte identifiers from showing as candidates for completion. This patch fixes it. --- src/bin/psql/tab-complete.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 5f27120..952db3a 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3197,8 +3197,8 @@ complete_from_schema_query(const char *text, int state) static char * _complete_from_query(int is_schema_query, const char *text, int state) { - static int list_index, - string_length; + static int list_index; + int string_length = 0; static PGresult *result = NULL; /* @@ -3211,9 +3211,16 @@ _complete_from_query(int is_schema_query, const char *text, int state) char *e_text; char *e_info_charp; char *e_info_charp2; + const char *pstr = text; list_index = 0; - string_length = strlen(text); + + /* count length as a multibyte text */ + while (*pstr) + { + string_length++; + pstr += PQmblen(pstr, pset.encoding); + } /* Free any prior result */ PQclear(result); -- 1.8.3.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers