@@ -836,6 +836,7 @@ select '$ ? (@.a < +10.1e+1)'::jsonpath;
836
836
$?(@."a" < 101)
837
837
(1 row)
838
838
839
+ -- numeric literals
839
840
select '0'::jsonpath;
840
841
jsonpath
841
842
----------
@@ -846,6 +847,10 @@ select '00'::jsonpath;
846
847
ERROR: trailing junk after numeric literal at or near "00" of jsonpath input
847
848
LINE 1: select '00'::jsonpath;
848
849
^
850
+ select '0755'::jsonpath;
851
+ ERROR: syntax error at end of jsonpath input
852
+ LINE 1: select '0755'::jsonpath;
853
+ ^
849
854
select '0.0'::jsonpath;
850
855
jsonpath
851
856
----------
@@ -1032,6 +1037,163 @@ select '1?(2>3)'::jsonpath;
1032
1037
(1)?(2 > 3)
1033
1038
(1 row)
1034
1039
1040
+ -- nondecimal
1041
+ select '0b100101'::jsonpath;
1042
+ jsonpath
1043
+ ----------
1044
+ 37
1045
+ (1 row)
1046
+
1047
+ select '0o273'::jsonpath;
1048
+ jsonpath
1049
+ ----------
1050
+ 187
1051
+ (1 row)
1052
+
1053
+ select '0x42F'::jsonpath;
1054
+ jsonpath
1055
+ ----------
1056
+ 1071
1057
+ (1 row)
1058
+
1059
+ -- error cases
1060
+ select '0b'::jsonpath;
1061
+ ERROR: trailing junk after numeric literal at or near "0b" of jsonpath input
1062
+ LINE 1: select '0b'::jsonpath;
1063
+ ^
1064
+ select '1b'::jsonpath;
1065
+ ERROR: trailing junk after numeric literal at or near "1b" of jsonpath input
1066
+ LINE 1: select '1b'::jsonpath;
1067
+ ^
1068
+ select '0b0x'::jsonpath;
1069
+ ERROR: syntax error at end of jsonpath input
1070
+ LINE 1: select '0b0x'::jsonpath;
1071
+ ^
1072
+ select '0o'::jsonpath;
1073
+ ERROR: trailing junk after numeric literal at or near "0o" of jsonpath input
1074
+ LINE 1: select '0o'::jsonpath;
1075
+ ^
1076
+ select '1o'::jsonpath;
1077
+ ERROR: trailing junk after numeric literal at or near "1o" of jsonpath input
1078
+ LINE 1: select '1o'::jsonpath;
1079
+ ^
1080
+ select '0o0x'::jsonpath;
1081
+ ERROR: syntax error at end of jsonpath input
1082
+ LINE 1: select '0o0x'::jsonpath;
1083
+ ^
1084
+ select '0x'::jsonpath;
1085
+ ERROR: trailing junk after numeric literal at or near "0x" of jsonpath input
1086
+ LINE 1: select '0x'::jsonpath;
1087
+ ^
1088
+ select '1x'::jsonpath;
1089
+ ERROR: trailing junk after numeric literal at or near "1x" of jsonpath input
1090
+ LINE 1: select '1x'::jsonpath;
1091
+ ^
1092
+ select '0x0y'::jsonpath;
1093
+ ERROR: syntax error at end of jsonpath input
1094
+ LINE 1: select '0x0y'::jsonpath;
1095
+ ^
1096
+ -- underscores
1097
+ select '1_000_000'::jsonpath;
1098
+ jsonpath
1099
+ ----------
1100
+ 1000000
1101
+ (1 row)
1102
+
1103
+ select '1_2_3'::jsonpath;
1104
+ jsonpath
1105
+ ----------
1106
+ 123
1107
+ (1 row)
1108
+
1109
+ select '0x1EEE_FFFF'::jsonpath;
1110
+ jsonpath
1111
+ -----------
1112
+ 518979583
1113
+ (1 row)
1114
+
1115
+ select '0o2_73'::jsonpath;
1116
+ jsonpath
1117
+ ----------
1118
+ 187
1119
+ (1 row)
1120
+
1121
+ select '0b10_0101'::jsonpath;
1122
+ jsonpath
1123
+ ----------
1124
+ 37
1125
+ (1 row)
1126
+
1127
+ select '1_000.000_005'::jsonpath;
1128
+ jsonpath
1129
+ -------------
1130
+ 1000.000005
1131
+ (1 row)
1132
+
1133
+ select '1_000.'::jsonpath;
1134
+ jsonpath
1135
+ ----------
1136
+ 1000
1137
+ (1 row)
1138
+
1139
+ select '.000_005'::jsonpath;
1140
+ jsonpath
1141
+ ----------
1142
+ 0.000005
1143
+ (1 row)
1144
+
1145
+ select '1_000.5e0_1'::jsonpath;
1146
+ jsonpath
1147
+ ----------
1148
+ 10005
1149
+ (1 row)
1150
+
1151
+ -- error cases
1152
+ select '_100'::jsonpath;
1153
+ ERROR: syntax error at end of jsonpath input
1154
+ LINE 1: select '_100'::jsonpath;
1155
+ ^
1156
+ select '100_'::jsonpath;
1157
+ ERROR: trailing junk after numeric literal at or near "100_" of jsonpath input
1158
+ LINE 1: select '100_'::jsonpath;
1159
+ ^
1160
+ select '100__000'::jsonpath;
1161
+ ERROR: syntax error at end of jsonpath input
1162
+ LINE 1: select '100__000'::jsonpath;
1163
+ ^
1164
+ select '_1_000.5'::jsonpath;
1165
+ ERROR: syntax error at end of jsonpath input
1166
+ LINE 1: select '_1_000.5'::jsonpath;
1167
+ ^
1168
+ select '1_000_.5'::jsonpath;
1169
+ ERROR: trailing junk after numeric literal at or near "1_000_" of jsonpath input
1170
+ LINE 1: select '1_000_.5'::jsonpath;
1171
+ ^
1172
+ select '1_000._5'::jsonpath;
1173
+ ERROR: trailing junk after numeric literal at or near "1_000._" of jsonpath input
1174
+ LINE 1: select '1_000._5'::jsonpath;
1175
+ ^
1176
+ select '1_000.5_'::jsonpath;
1177
+ ERROR: trailing junk after numeric literal at or near "1_000.5_" of jsonpath input
1178
+ LINE 1: select '1_000.5_'::jsonpath;
1179
+ ^
1180
+ select '1_000.5e_1'::jsonpath;
1181
+ ERROR: trailing junk after numeric literal at or near "1_000.5e" of jsonpath input
1182
+ LINE 1: select '1_000.5e_1'::jsonpath;
1183
+ ^
1184
+ -- underscore after prefix not allowed in JavaScript (but allowed in SQL)
1185
+ select '0b_10_0101'::jsonpath;
1186
+ ERROR: syntax error at end of jsonpath input
1187
+ LINE 1: select '0b_10_0101'::jsonpath;
1188
+ ^
1189
+ select '0o_273'::jsonpath;
1190
+ ERROR: syntax error at end of jsonpath input
1191
+ LINE 1: select '0o_273'::jsonpath;
1192
+ ^
1193
+ select '0x_42F'::jsonpath;
1194
+ ERROR: syntax error at end of jsonpath input
1195
+ LINE 1: select '0x_42F'::jsonpath;
1196
+ ^
1035
1197
-- test non-error-throwing API
1036
1198
SELECT str as jsonpath,
1037
1199
pg_input_is_valid(str,'jsonpath') as ok,
0 commit comments