- Notifications
You must be signed in to change notification settings - Fork5.2k
Commitef5e60a
committed
Fix internal error from CollateExpr in SQL/JSON DEFAULT expressions
SQL/JSON functions such as JSON_VALUE could fail with "unrecognizednode type" errors when a DEFAULT clause contained an explicit COLLATEexpression. That happened because assign_collations_walker() couldinvoke exprSetCollation() on a JsonBehavior expression whose DEFAULTstill contained a CollateExpr, which exprSetCollation() does nothandle.For example: SELECT JSON_VALUE('{"a":1}', '$.c' RETURNING text DEFAULT 'A' COLLATE "C" ON EMPTY);Fix by validating in transformJsonBehavior() that the DEFAULTexpression's collation matches the enclosing JSON expression’scollation. In exprSetCollation(), replace the recursive call on theJsonBehavior expression with an assertion that its collation alreadymatches the target, since the parser now enforces that condition.Reported-by: Jian He <jian.universality@gmail.com>Author: Jian He <jian.universality@gmail.com>Reviewed-by: Amit Langote <amitlangote09@gmail.com>Discussion:https://postgr.es/m/CACJufxHVwYYSyiVQ6o+PsRX6zQ7rAFinh_fv1kCfTsT1xG4Zeg@mail.gmail.comBackpatch-through: 171 parenta5a68dd commitef5e60a
File tree
4 files changed
+113
-14
lines changed- src
- backend
- nodes
- parser
- test/regress
- expected
- sql
4 files changed
+113
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1274 | 1274 | | |
1275 | 1275 | | |
1276 | 1276 | | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
| 1277 | + | |
| 1278 | + | |
1283 | 1279 | | |
1284 | 1280 | | |
1285 | 1281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
4529 | 4530 | | |
4530 | 4531 | | |
4531 | 4532 | | |
| 4533 | + | |
4532 | 4534 | | |
4533 | 4535 | | |
4534 | 4536 | | |
4535 | 4537 | | |
4536 | 4538 | | |
4537 | 4539 | | |
4538 | | - | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
4539 | 4543 | | |
4540 | 4544 | | |
4541 | 4545 | | |
| |||
4550 | 4554 | | |
4551 | 4555 | | |
4552 | 4556 | | |
| 4557 | + | |
| 4558 | + | |
4553 | 4559 | | |
4554 | 4560 | | |
4555 | 4561 | | |
| |||
4566 | 4572 | | |
4567 | 4573 | | |
4568 | 4574 | | |
4569 | | - | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
4570 | 4578 | | |
4571 | 4579 | | |
4572 | 4580 | | |
4573 | | - | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
4574 | 4584 | | |
4575 | 4585 | | |
4576 | 4586 | | |
| |||
4582 | 4592 | | |
4583 | 4593 | | |
4584 | 4594 | | |
| 4595 | + | |
4585 | 4596 | | |
4586 | 4597 | | |
4587 | 4598 | | |
| |||
4607 | 4618 | | |
4608 | 4619 | | |
4609 | 4620 | | |
4610 | | - | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
4611 | 4624 | | |
4612 | 4625 | | |
4613 | 4626 | | |
4614 | | - | |
| 4627 | + | |
| 4628 | + | |
| 4629 | + | |
4615 | 4630 | | |
4616 | 4631 | | |
4617 | 4632 | | |
| |||
4622 | 4637 | | |
4623 | 4638 | | |
4624 | 4639 | | |
| 4640 | + | |
4625 | 4641 | | |
4626 | 4642 | | |
4627 | 4643 | | |
4628 | 4644 | | |
4629 | 4645 | | |
4630 | 4646 | | |
4631 | 4647 | | |
4632 | | - | |
| 4648 | + | |
| 4649 | + | |
| 4650 | + | |
4633 | 4651 | | |
4634 | 4652 | | |
4635 | 4653 | | |
| |||
4705 | 4723 | | |
4706 | 4724 | | |
4707 | 4725 | | |
4708 | | - | |
| 4726 | + | |
| 4727 | + | |
4709 | 4728 | | |
4710 | 4729 | | |
4711 | 4730 | | |
| |||
4720 | 4739 | | |
4721 | 4740 | | |
4722 | 4741 | | |
| 4742 | + | |
| 4743 | + | |
| 4744 | + | |
4723 | 4745 | | |
| 4746 | + | |
4724 | 4747 | | |
4725 | 4748 | | |
4726 | 4749 | | |
| |||
4736 | 4759 | | |
4737 | 4760 | | |
4738 | 4761 | | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
| 4767 | + | |
| 4768 | + | |
| 4769 | + | |
| 4770 | + | |
| 4771 | + | |
| 4772 | + | |
| 4773 | + | |
| 4774 | + | |
| 4775 | + | |
| 4776 | + | |
| 4777 | + | |
| 4778 | + | |
| 4779 | + | |
4739 | 4780 | | |
4740 | 4781 | | |
4741 | 4782 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2694 | 2694 | | |
2695 | 2695 | | |
2696 | 2696 | | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
2697 | 2746 | | |
2698 | 2747 | | |
2699 | 2748 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1000 | 1013 | | |
1001 | 1014 | | |
1002 | 1015 | | |
| |||
0 commit comments
Comments
(0)