Fix query-based tab completion for multibyte characters.
Fix query-based tab completion for multibyte characters.

The existing code confuses the byte length of the string (which is
relevant when passing it to pg_strncasecmp) with the character length
of the string (which is relevant when it is used with the SQL substring
function).  Separate those two concepts.

Report and patch by Kyotaro Horiguchi, reviewed by Thomas Munro and
reviewed and further revised by me.

50wu/gpdb,50wu/gpdb,lisakowen/gpdb,xinzweb/gpdb,greenplum-db/gpdb,xinzweb/gpdb,xinzweb/gpdb,lisakowen/gpdb,greenplum-db/gpdb,adam8157/gpdb,greenplum-db/gpdb,xinzweb/gpdb,jmcatamney/gpdb,adam8157/gpdb,lisakowen/gpdb,ashwinstar/gpdb,adam8157/gpdb,lisakowen/gpdb,50wu/gpdb,50wu/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,xinzweb/gpdb,greenplum-db/gpdb,adam8157/gpdb,50wu/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,adam8157/gpdb,adam8157/gpdb,xinzweb/gpdb,adam8157/gpdb,adam8157/gpdb,lisakowen/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,lisakowen/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,xinzweb/gpdb,jmcatamney/gpdb,lisakowen/gpdb,ashwinstar/gpdb,50wu/gpdb,50wu/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,xinzweb/gpdb,50wu/gpdb,lisakowen/gpdb,ashwinstar/gpdb