forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1c90345
committed
Fix conversion of JSON strings to JSON output columns in json_to_record().
json_to_record(), when an output column is declared as type json or jsonb,should emit the corresponding field of the input JSON object. But it gotthis slightly wrong when the field is just a string literal: it failed toescape the contents of the string. That typically resulted in syntaxerrors if the string contained any double quotes or backslashes.jsonb_to_record() handles such cases correctly, but I added correspondingtest cases for it too, to prevent future backsliding.Improve the documentation, as it provided only a very hand-wavydescription of the conversion rules used by these functions.Per bug report from Robert Vollmert. Back-patch to v10 where theerror was introduced (by commitcf35346).Note that PG 9.4 - 9.6 also get this case wrong, but differently so:they feed the de-escaped contents of the string literal to json[b]_in.That behavior is less obviously wrong, so possibly it's being depended onin the field, so I won't risk trying to make the older branches behavelike the newer ones.Discussion:https://postgr.es/m/D6921B37-BD8E-4664-8D5F-DB3525765DCD@vllmrt.net1 parentc015560 commit1c90345
6 files changed
+167
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12006 | 12006 | | |
12007 | 12007 | | |
12008 | 12008 | | |
12009 | | - | |
12010 | | - | |
12011 | | - | |
12012 | | - | |
12013 | | - | |
12014 | | - | |
12015 | | - | |
12016 | | - | |
12017 | | - | |
12018 | | - | |
12019 | | - | |
12020 | | - | |
12021 | | - | |
12022 | | - | |
| 12009 | + | |
| 12010 | + | |
| 12011 | + | |
| 12012 | + | |
| 12013 | + | |
| 12014 | + | |
| 12015 | + | |
| 12016 | + | |
| 12017 | + | |
| 12018 | + | |
| 12019 | + | |
| 12020 | + | |
| 12021 | + | |
| 12022 | + | |
| 12023 | + | |
| 12024 | + | |
| 12025 | + | |
| 12026 | + | |
| 12027 | + | |
| 12028 | + | |
| 12029 | + | |
| 12030 | + | |
| 12031 | + | |
| 12032 | + | |
| 12033 | + | |
| 12034 | + | |
| 12035 | + | |
| 12036 | + | |
| 12037 | + | |
| 12038 | + | |
| 12039 | + | |
| 12040 | + | |
| 12041 | + | |
| 12042 | + | |
| 12043 | + | |
| 12044 | + | |
| 12045 | + | |
| 12046 | + | |
| 12047 | + | |
| 12048 | + | |
| 12049 | + | |
| 12050 | + | |
| 12051 | + | |
| 12052 | + | |
| 12053 | + | |
| 12054 | + | |
| 12055 | + | |
| 12056 | + | |
| 12057 | + | |
| 12058 | + | |
| 12059 | + | |
| 12060 | + | |
| 12061 | + | |
| 12062 | + | |
| 12063 | + | |
12023 | 12064 | | |
12024 | | - | |
12025 | | - | |
12026 | | - | |
12027 | | - | |
12028 | | - | |
12029 | | - | |
12030 | | - | |
12031 | | - | |
| 12065 | + | |
| 12066 | + | |
| 12067 | + | |
| 12068 | + | |
| 12069 | + | |
| 12070 | + | |
| 12071 | + | |
| 12072 | + | |
| 12073 | + | |
| 12074 | + | |
12032 | 12075 | | |
12033 | 12076 | | |
12034 | 12077 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2803 | 2803 | | |
2804 | 2804 | | |
2805 | 2805 | | |
2806 | | - | |
2807 | | - | |
2808 | | - | |
2809 | | - | |
2810 | | - | |
2811 | | - | |
2812 | | - | |
2813 | | - | |
2814 | | - | |
2815 | | - | |
2816 | | - | |
2817 | | - | |
2818 | | - | |
2819 | | - | |
2820 | | - | |
2821 | | - | |
2822 | | - | |
2823 | | - | |
2824 | | - | |
2825 | | - | |
| 2806 | + | |
2826 | 2807 | | |
2827 | 2808 | | |
2828 | 2809 | | |
2829 | 2810 | | |
2830 | 2811 | | |
2831 | 2812 | | |
2832 | 2813 | | |
2833 | | - | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
2834 | 2829 | | |
2835 | 2830 | | |
2836 | 2831 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2276 | 2276 | | |
2277 | 2277 | | |
2278 | 2278 | | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
2279 | 2315 | | |
2280 | 2316 | | |
2281 | 2317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2652 | 2652 | | |
2653 | 2653 | | |
2654 | 2654 | | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
2655 | 2691 | | |
2656 | 2692 | | |
2657 | 2693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
745 | 752 | | |
746 | 753 | | |
747 | 754 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
712 | 719 | | |
713 | 720 | | |
714 | 721 | | |
| |||
0 commit comments
Comments
(0)