Skip to content

Commit 7d55ad0

Browse files
committed
sync support \u0000
1 parent e075673 commit 7d55ad0

File tree

2 files changed

+38
-44
lines changed

2 files changed

+38
-44
lines changed

expected/jsquery.out

+32-40
Original file line numberDiff line numberDiff line change
@@ -1035,17 +1035,15 @@ select 'a\r = "\n\""'::jsquery;
10351035
(1 row)
10361036

10371037
select 'a\r = "\u0000"'::jsquery;
1038-
jsquery
1039-
------------------
1040-
"a\r" = "\u0000"
1041-
(1 row)
1042-
1038+
ERROR: unsupported Unicode escape sequence
1039+
LINE 1: select 'a\r = "\u0000"'::jsquery;
1040+
^
1041+
DETAIL: \u0000 cannot be converted to text.
10431042
select 'a\r = \u0000'::jsquery;
1044-
jsquery
1045-
------------------
1046-
"a\r" = "\u0000"
1047-
(1 row)
1048-
1043+
ERROR: unsupported Unicode escape sequence
1044+
LINE 1: select 'a\r = \u0000'::jsquery;
1045+
^
1046+
DETAIL: \u0000 cannot be converted to text.
10491047
select 'a\r = "\abcd"'::jsquery AS err;
10501048
ERROR: bad jsquery representation
10511049
LINE 1: select 'a\r = "\abcd"'::jsquery AS err;
@@ -1058,17 +1056,15 @@ select 'a\r = "\\abcd"'::jsquery;
10581056
(1 row)
10591057

10601058
select 'a\r = "x\u0000"'::jsquery;
1061-
jsquery
1062-
-------------------
1063-
"a\r" = "x\u0000"
1064-
(1 row)
1065-
1059+
ERROR: unsupported Unicode escape sequence
1060+
LINE 1: select 'a\r = "x\u0000"'::jsquery;
1061+
^
1062+
DETAIL: \u0000 cannot be converted to text.
10661063
select 'a\r = x\u0000'::jsquery;
1067-
jsquery
1068-
-------------------
1069-
"a\r" = "x\u0000"
1070-
(1 row)
1071-
1064+
ERROR: unsupported Unicode escape sequence
1065+
LINE 1: select 'a\r = x\u0000'::jsquery;
1066+
^
1067+
DETAIL: \u0000 cannot be converted to text.
10721068
select 'a\r = "x\abcd"'::jsquery AS err;
10731069
ERROR: bad jsquery representation
10741070
LINE 1: select 'a\r = "x\abcd"'::jsquery AS err;
@@ -1081,17 +1077,15 @@ select 'a\r = "x\\abcd"'::jsquery;
10811077
(1 row)
10821078

10831079
select 'a\r = "x\u0000x"'::jsquery;
1084-
jsquery
1085-
--------------------
1086-
"a\r" = "x\u0000x"
1087-
(1 row)
1088-
1080+
ERROR: unsupported Unicode escape sequence
1081+
LINE 1: select 'a\r = "x\u0000x"'::jsquery;
1082+
^
1083+
DETAIL: \u0000 cannot be converted to text.
10891084
select 'a\r = x\u0000x'::jsquery;
1090-
jsquery
1091-
--------------------
1092-
"a\r" = "x\u0000x"
1093-
(1 row)
1094-
1085+
ERROR: unsupported Unicode escape sequence
1086+
LINE 1: select 'a\r = x\u0000x'::jsquery;
1087+
^
1088+
DETAIL: \u0000 cannot be converted to text.
10951089
select 'a\r = "x\abcdx"'::jsquery AS err;
10961090
ERROR: bad jsquery representation
10971091
LINE 1: select 'a\r = "x\abcdx"'::jsquery AS err;
@@ -1104,17 +1098,15 @@ select 'a\r = "x\\abcdx"'::jsquery;
11041098
(1 row)
11051099

11061100
select 'a\r = "\u0000x"'::jsquery;
1107-
jsquery
1108-
-------------------
1109-
"a\r" = "\u0000x"
1110-
(1 row)
1111-
1101+
ERROR: unsupported Unicode escape sequence
1102+
LINE 1: select 'a\r = "\u0000x"'::jsquery;
1103+
^
1104+
DETAIL: \u0000 cannot be converted to text.
11121105
select 'a\r = \u0000x'::jsquery;
1113-
jsquery
1114-
-------------------
1115-
"a\r" = "\u0000x"
1116-
(1 row)
1117-
1106+
ERROR: unsupported Unicode escape sequence
1107+
LINE 1: select 'a\r = \u0000x'::jsquery;
1108+
^
1109+
DETAIL: \u0000 cannot be converted to text.
11181110
select 'a\r = "\abcdx"'::jsquery AS err;
11191111
ERROR: bad jsquery representation
11201112
LINE 1: select 'a\r = "\abcdx"'::jsquery AS err;

jsquery_scan.l

+6-4
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,16 @@ parseUnicode(char *s, int l)
458458
* For UTF8, replace the escape sequence by the actual
459459
* utf8 character in lex->strval. Do this also for other
460460
* encodings if the escape designates an ASCII character,
461-
* otherwise raise an error. We don't ever unescape a
462-
* \u0000, since that would result in an impermissible nul
463-
* byte.
461+
* otherwise raise an error.
464462
*/
465463

466464
if (ch == 0)
467465
{
468-
addstring(false, "\\u0000", 6);
466+
/* We can't allow this, since our TEXT type doesn't */
467+
ereport(ERROR,
468+
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
469+
errmsg("unsupported Unicode escape sequence"),
470+
errdetail("\\u0000 cannot be converted to text.")));
469471
}
470472
else if (GetDatabaseEncoding() == PG_UTF8)
471473
{

0 commit comments

Comments
 (0)