forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6f34fcb
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 parent9f05c44 commit6f34fcb
6 files changed
+167
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13050 | 13050 | | |
13051 | 13051 | | |
13052 | 13052 | | |
13053 | | - | |
13054 | | - | |
13055 | | - | |
13056 | | - | |
13057 | | - | |
13058 | | - | |
13059 | | - | |
13060 | | - | |
13061 | | - | |
13062 | | - | |
13063 | | - | |
13064 | | - | |
13065 | | - | |
13066 | | - | |
13067 | | - | |
13068 | | - | |
13069 | | - | |
13070 | | - | |
13071 | | - | |
13072 | | - | |
13073 | | - | |
13074 | | - | |
| 13053 | + | |
| 13054 | + | |
| 13055 | + | |
| 13056 | + | |
| 13057 | + | |
| 13058 | + | |
| 13059 | + | |
| 13060 | + | |
| 13061 | + | |
| 13062 | + | |
| 13063 | + | |
| 13064 | + | |
| 13065 | + | |
| 13066 | + | |
| 13067 | + | |
| 13068 | + | |
| 13069 | + | |
| 13070 | + | |
| 13071 | + | |
| 13072 | + | |
| 13073 | + | |
| 13074 | + | |
| 13075 | + | |
| 13076 | + | |
| 13077 | + | |
| 13078 | + | |
| 13079 | + | |
| 13080 | + | |
| 13081 | + | |
| 13082 | + | |
| 13083 | + | |
| 13084 | + | |
| 13085 | + | |
| 13086 | + | |
| 13087 | + | |
| 13088 | + | |
| 13089 | + | |
| 13090 | + | |
| 13091 | + | |
| 13092 | + | |
| 13093 | + | |
| 13094 | + | |
| 13095 | + | |
| 13096 | + | |
| 13097 | + | |
| 13098 | + | |
| 13099 | + | |
| 13100 | + | |
| 13101 | + | |
| 13102 | + | |
| 13103 | + | |
| 13104 | + | |
| 13105 | + | |
| 13106 | + | |
| 13107 | + | |
13075 | 13108 | | |
13076 | | - | |
| 13109 | + | |
| 13110 | + | |
| 13111 | + | |
| 13112 | + | |
| 13113 | + | |
| 13114 | + | |
| 13115 | + | |
| 13116 | + | |
| 13117 | + | |
| 13118 | + | |
13077 | 13119 | | |
13078 | 13120 | | |
13079 | 13121 | | |
| |||
| 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)