forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd5b90cd
committed
Fix bogus handling of XQuery regex option flags.
The SQL spec defers to XQuery to define what the option flags arefor LIKE_REGEX patterns. XQuery says that:* 's' allows the dot character to match newlines, which by default it will not;* 'm' allows ^ and $ to match at newlines, not only at the start/end of the whole string.Thus, these are *not* inverses as they are for the similarly-namedPOSIX options, and neither one corresponds to the POSIX 'n' option.Fortunately, Spencer's library does expose these two behaviors asseparately twiddlable flags, so we just have to fix the mapping fromJSP flag bits to REG flag bits. I also chose to rename the symbolfor 's' to DOTALL, to make it clearer that it's not the inverseof MLINE.Also, XQuery says that if the 'q' flag "is used together with the m, s,or x flag, that flag has no effect". I read this as saying that 'q'overrides the other flags; whoever wrote our code seems to have readit backwards.Lastly, while XQuery's 'x' flag is related to what Spencer's codedoes for REG_EXPANDED, it's not the same or a subset. It seems bestto treat XQuery's 'x' as unimplemented for now. Maybe later we canexpand our regex code to offer 'x'-style parsing as a separate option.While at it, refactor the jsonpath code so that (a) there's onlyone copy of the flag transformation logic not two, and (b) theprocessing of flags is independent of the order in which the flagsare written.We need some documentation updates to go with this, but I'lltackle that separately.Back-patch to v12 where this code originated.Discussion:https://postgr.es/m/CAPpHfdvDci4iqNF9fhRkTqhe-5_8HmzeLt56drH%2B_Rv2rNRqfg@mail.gmail.comReference:https://www.w3.org/TR/2017/REC-xpath-functions-31-20170321/#flags1 parenta25221f commitd5b90cd
File tree
7 files changed
+76
-63
lines changed- src
- backend/utils/adt
- include/utils
- test/regress
- expected
- sql
7 files changed
+76
-63
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
557 | 557 |
| |
558 | 558 |
| |
559 | 559 |
| |
560 |
| - | |
| 560 | + | |
561 | 561 |
| |
562 | 562 |
| |
563 | 563 |
| |
|
Lines changed: 1 addition & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1646 | 1646 |
| |
1647 | 1647 |
| |
1648 | 1648 |
| |
1649 |
| - | |
1650 |
| - | |
1651 | 1649 |
| |
1652 | 1650 |
| |
1653 | 1651 |
| |
1654 |
| - | |
1655 |
| - | |
1656 |
| - | |
1657 |
| - | |
1658 |
| - | |
1659 |
| - | |
1660 |
| - | |
1661 |
| - | |
1662 |
| - | |
1663 |
| - | |
1664 |
| - | |
1665 |
| - | |
1666 |
| - | |
1667 |
| - | |
1668 |
| - | |
1669 |
| - | |
1670 |
| - | |
1671 |
| - | |
1672 |
| - | |
1673 |
| - | |
1674 |
| - | |
1675 |
| - | |
1676 |
| - | |
| 1652 | + | |
1677 | 1653 |
| |
1678 | 1654 |
| |
1679 | 1655 |
| |
|
Lines changed: 50 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
481 | 481 |
| |
482 | 482 |
| |
483 | 483 |
| |
484 |
| - | |
| 484 | + | |
485 | 485 |
| |
486 | 486 |
| |
487 | 487 |
| |
488 | 488 |
| |
489 |
| - | |
490 | 489 |
| |
| 490 | + | |
| 491 | + | |
491 | 492 |
| |
492 | 493 |
| |
493 | 494 |
| |
494 | 495 |
| |
495 | 496 |
| |
496 | 497 |
| |
497 |
| - | |
498 | 498 |
| |
499 | 499 |
| |
500 |
| - | |
501 |
| - | |
502 |
| - | |
| 500 | + | |
503 | 501 |
| |
504 | 502 |
| |
505 |
| - | |
506 | 503 |
| |
507 |
| - | |
508 | 504 |
| |
509 | 505 |
| |
510 | 506 |
| |
511 |
| - | |
512 | 507 |
| |
513 | 508 |
| |
514 | 509 |
| |
515 |
| - | |
516 |
| - | |
517 |
| - | |
518 |
| - | |
519 |
| - | |
520 | 510 |
| |
521 | 511 |
| |
522 | 512 |
| |
| |||
528 | 518 |
| |
529 | 519 |
| |
530 | 520 |
| |
| 521 | + | |
| 522 | + | |
| 523 | + | |
531 | 524 |
| |
532 | 525 |
| |
533 | 526 |
| |
| |||
536 | 529 |
| |
537 | 530 |
| |
538 | 531 |
| |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
539 | 575 |
| |
540 | 576 |
| |
541 | 577 |
| |
|
Lines changed: 5 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
91 |
| - | |
92 |
| - | |
93 |
| - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
94 | 94 |
| |
95 | 95 |
| |
96 | 96 |
| |
| |||
245 | 245 |
| |
246 | 246 |
| |
247 | 247 |
| |
| 248 | + | |
| 249 | + | |
248 | 250 |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1592 | 1592 |
| |
1593 | 1593 |
| |
1594 | 1594 |
| |
1595 |
| - | |
| 1595 | + | |
1596 | 1596 |
| |
1597 | 1597 |
| |
1598 | 1598 |
| |
1599 | 1599 |
| |
1600 | 1600 |
| |
1601 | 1601 |
| |
1602 |
| - | |
| 1602 | + | |
1603 | 1603 |
| |
1604 | 1604 |
| |
1605 | 1605 |
| |
1606 | 1606 |
| |
1607 | 1607 |
| |
1608 | 1608 |
| |
1609 | 1609 |
| |
1610 |
| - | |
| 1610 | + | |
1611 | 1611 |
| |
1612 | 1612 |
| |
1613 | 1613 |
| |
1614 | 1614 |
| |
1615 | 1615 |
| |
1616 | 1616 |
| |
1617 | 1617 |
| |
1618 |
| - | |
| 1618 | + | |
1619 | 1619 |
| |
1620 | 1620 |
| |
1621 | 1621 |
| |
1622 | 1622 |
| |
1623 |
| - | |
| 1623 | + | |
| 1624 | + | |
1624 | 1625 |
| |
1625 | 1626 |
| |
1626 | 1627 |
| |
|
Lines changed: 9 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
442 | 442 |
| |
443 | 443 |
| |
444 | 444 |
| |
445 |
| - | |
446 |
| - | |
447 |
| - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
448 | 448 |
| |
449 | 449 |
| |
450 | 450 |
| |
451 |
| - | |
452 |
| - | |
453 |
| - | |
454 |
| - | |
455 |
| - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
456 | 454 |
| |
457 | 455 |
| |
458 | 456 |
| |
| |||
466 | 464 |
| |
467 | 465 |
| |
468 | 466 |
| |
469 |
| - | |
470 |
| - | |
471 |
| - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
472 | 470 |
| |
473 | 471 |
| |
474 | 472 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
335 | 335 |
| |
336 | 336 |
| |
337 | 337 |
| |
338 |
| - | |
339 |
| - | |
340 |
| - | |
341 |
| - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
342 | 342 |
| |
343 | 343 |
| |
344 | 344 |
| |
|
0 commit comments
Comments
(0)