git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: fe30e7e) | patch
Allow Unicode escapes in any server encoding, not only UTF-8.
Fri, 6 Mar 2020 19:17:43 +0000 (14:17 -0500)
Fri, 6 Mar 2020 19:17:43 +0000 (14:17 -0500)
commit a6525588b7c21fd8539e9a43ec9c5c245ed1cc91
Allow Unicode escapes in any server encoding, not only UTF-8.

SQL includes provisions for numeric Unicode escapes in string
literals and identifiers. Previously we only accepted those
if they represented ASCII characters or the server encoding
was UTF-8, making the conversion to internal form trivial.
This patch adjusts things so that we'll call the appropriate
encoding conversion function in less-trivial cases, allowing
the escape sequence to be accepted so long as it corresponds
to some character available in the server encoding.

This also applies to processing of Unicode escapes in JSONB.
However, the old restriction still applies to client-side
JSON processing, since that hasn't got access to the server's
encoding conversion infrastructure.

This patch includes some lexer infrastructure that simplifies
throwing errors with error cursors pointing into the middle of
a string (or other complex token). For the moment I only used
it for errors relating to Unicode escapes, but we might later
expand the usage to some other cases.

Patch by me, reviewed by John Naylor.

Discussion: https://postgr.es/m/2393.1578958316@sss.pgh.pa.us
20 files changed:
doc/src/sgml/json.sgml diff | blob | blame | history
doc/src/sgml/syntax.sgml diff | blob | blame | history
src/backend/parser/parser.c diff | blob | blame | history
src/backend/parser/scan.l diff | blob | blame | history
src/backend/utils/adt/jsonpath_scan.l diff | blob | blame | history
src/backend/utils/adt/xml.c diff | blob | blame | history
src/backend/utils/mb/mbutils.c diff | blob | blame | history
src/common/jsonapi.c diff | blob | blame | history
src/include/mb/pg_wchar.h diff | blob | blame | history
src/include/parser/scanner.h diff | blob | blame | history
src/test/regress/expected/json_encoding.out diff | blob | blame | history
src/test/regress/expected/json_encoding_1.out diff | blob | blame | history
src/test/regress/expected/json_encoding_2.out [new file with mode: 0644] blob
src/test/regress/expected/jsonpath_encoding.out diff | blob | blame | history
src/test/regress/expected/jsonpath_encoding_1.out diff | blob | blame | history
src/test/regress/expected/jsonpath_encoding_2.out [new file with mode: 0644] blob
src/test/regress/expected/strings.out diff | blob | blame | history
src/test/regress/sql/json_encoding.sql diff | blob | blame | history
src/test/regress/sql/jsonpath_encoding.sql diff | blob | blame | history
src/test/regress/sql/strings.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /