forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit63ca863
committed
Fix quoted-substring handling in format parsing for to_char/to_number/etc.
This code evidently intended to treat backslash as an escape characterwithin double-quoted substrings, but it was sufficiently confused thatcases like ..."foo\\"... did not work right: the second backslashmanaged to quote the double-quote after it, despite being quoted itself.Rewrite to get that right, while preserving the existing behavioroutside double-quoted substrings, which is that backslash isn't specialexcept in the combination \".Comparing to Oracle, it seems that their version of to_char() fortimestamps allows literal alphanumerics only within double quotes, whilenon-alphanumerics are allowed outside quotes; backslashes aren't specialanywhere; there is no way at all to emit a literal double quote.(Bizarrely, their to_char() for numbers is different; it doesn't allowliteral text at all AFAICT.) The fact that they don't treat backslashas special justifies our existing behavior for backslash outside doublequotes. I considered making backslash inside double quotes act the sameway (ie, special only if before "), which in a green field would be amore consistent behavior. But that would likely break more existing SQLcode than what this patch does.Add some test cases illustrating this behavior. (Only the last newcase actually changes behavior in this commit.)Little of this behavior was documented, either, so fix that.Discussion:https://postgr.es/m/3626.1510949486@sss.pgh.pa.us1 parent9288d62 commit63ca863
File tree
4 files changed
+104
-44
lines changed- doc/src/sgml
- src
- backend/utils/adt
- test/regress
- expected
- sql
4 files changed
+104
-44
lines changedLines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6196 | 6196 |
| |
6197 | 6197 |
| |
6198 | 6198 |
| |
| 6199 | + | |
| 6200 | + | |
| 6201 | + | |
| 6202 | + | |
| 6203 | + | |
6199 | 6204 |
| |
6200 | 6205 |
| |
6201 | 6206 |
| |
|
Lines changed: 26 additions & 44 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1227 | 1227 |
| |
1228 | 1228 |
| |
1229 | 1229 |
| |
1230 |
| - | |
1231 | 1230 |
| |
1232 |
| - | |
1233 |
| - | |
1234 |
| - | |
1235 | 1231 |
| |
1236 | 1232 |
| |
1237 | 1233 |
| |
| |||
1241 | 1237 |
| |
1242 | 1238 |
| |
1243 | 1239 |
| |
1244 |
| - | |
| 1240 | + | |
| 1241 | + | |
1245 | 1242 |
| |
1246 | 1243 |
| |
1247 | 1244 |
| |
1248 | 1245 |
| |
1249 |
| - | |
| 1246 | + | |
| 1247 | + | |
1250 | 1248 |
| |
1251 | 1249 |
| |
1252 | 1250 |
| |
| |||
1259 | 1257 |
| |
1260 | 1258 |
| |
1261 | 1259 |
| |
1262 |
| - | |
1263 |
| - | |
| 1260 | + | |
1264 | 1261 |
| |
1265 | 1262 |
| |
1266 | 1263 |
| |
| |||
1273 | 1270 |
| |
1274 | 1271 |
| |
1275 | 1272 |
| |
1276 |
| - | |
| 1273 | + | |
| 1274 | + | |
1277 | 1275 |
| |
1278 |
| - | |
| 1276 | + | |
1279 | 1277 |
| |
1280 | 1278 |
| |
1281 | 1279 |
| |
| 1280 | + | |
| 1281 | + | |
1282 | 1282 |
| |
1283 | 1283 |
| |
1284 | 1284 |
| |
1285 | 1285 |
| |
1286 |
| - | |
| 1286 | + | |
1287 | 1287 |
| |
1288 |
| - | |
| 1288 | + | |
1289 | 1289 |
| |
1290 |
| - | |
1291 |
| - | |
1292 | 1290 |
| |
1293 | 1291 |
| |
1294 |
| - | |
| 1292 | + | |
1295 | 1293 |
| |
1296 | 1294 |
| |
1297 | 1295 |
| |
1298 | 1296 |
| |
1299 |
| - | |
1300 |
| - | |
1301 |
| - | |
1302 |
| - | |
1303 |
| - | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
1304 | 1300 |
| |
1305 | 1301 |
| |
1306 | 1302 |
| |
1307 | 1303 |
| |
1308 |
| - | |
1309 |
| - | |
| 1304 | + | |
1310 | 1305 |
| |
1311 |
| - | |
1312 |
| - | |
1313 |
| - | |
1314 | 1306 |
| |
1315 |
| - | |
1316 |
| - | |
1317 |
| - | |
1318 |
| - | |
1319 |
| - | |
1320 |
| - | |
| 1307 | + | |
1321 | 1308 |
| |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
1322 | 1315 |
| |
1323 | 1316 |
| |
1324 | 1317 |
| |
1325 |
| - | |
1326 |
| - | |
| 1318 | + | |
| 1319 | + | |
1327 | 1320 |
| |
1328 | 1321 |
| |
1329 | 1322 |
| |
1330 |
| - | |
1331 |
| - | |
1332 |
| - | |
1333 |
| - | |
1334 |
| - | |
1335 |
| - | |
1336 |
| - | |
1337 |
| - | |
1338 |
| - | |
1339 |
| - | |
1340 |
| - | |
1341 | 1323 |
| |
1342 | 1324 |
| |
1343 | 1325 |
| |
|
Lines changed: 61 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1217 | 1217 |
| |
1218 | 1218 |
| |
1219 | 1219 |
| |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1220 | 1281 |
| |
1221 | 1282 |
| |
1222 | 1283 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
786 | 786 |
| |
787 | 787 |
| |
788 | 788 |
| |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
789 | 801 |
| |
790 | 802 |
| |
791 | 803 |
| |
|
0 commit comments
Comments
(0)