Fix detection of unfinished Unicode surrogate pair at end of string.
Fix detection of unfinished Unicode surrogate pair at end of string.

The U&'...' and U&"..." syntaxes silently discarded a surrogate pair
start (that is, a code between U+D800 and U+DBFF) if it occurred at
the very end of the string.  This seems like an obvious oversight,
since we throw an error for every other invalid combination of surrogate
characters, including the very same situation in E'...' syntax.

This has been wrong since the pair processing was added (in 9.0),
so back-patch to all supported branches.

Discussion: 7820975f304a43ac4d62d3eb628d6faa23090ecb@sss.pgh.pa.us

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