- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit4b93f57
committed
Make plpgsql use its DTYPE_REC code paths for composite-type variables.
Formerly, DTYPE_REC was used only for variables declared as "record";variables of named composite types used DTYPE_ROW, which is faster forsome purposes but much less flexible. In particular, the ROW code pathsare entirely incapable of dealing with DDL-caused changes to the numberor data types of the columns of a row variable, once a particular plpgsqlfunction has been parsed for the first time in a session. And, since thestored representation of a ROW isn't a tuple, there wasn't any easy wayto deal with variables of domain-over-composite types, since the domainconstraint checking code would expect the value to be checked to be atuple. A lesser, but still real, annoyance is that ROW format cannotrepresent a true NULL composite value, only a row of per-field NULLvalues, which is not exactly the same thing.Hence, switch to using DTYPE_REC for all composite-typed variables,whether "record", named composite type, or domain over named compositetype. DTYPE_ROW remains but is used only for its native purpose, torepresent a fixed-at-compile-time list of variables, for instance thetargets of an INTO clause.To accomplish this without taking significant performance losses, introduceinfrastructure that allows storing composite-type variables as "expandedobjects", similar to the "expanded array" infrastructure introduced incommit1dc5ebc. A composite variable's value is thereby kept (most ofthe time) in the form of separate Datums, so that field accesses andupdates are not much more expensive than they were in the ROW format.This holds the line, more or less, on performance of variables of namedcomposite types in field-access-intensive microbenchmarks, and makesvariables declared "record" perform much better than before in similartests. In addition, the logic involved with enforcing composite-domainconstraints against updates of individual fields is in the expandedrecord infrastructure not plpgsql proper, so that it might be reusablefor other purposes.In further support of this, introduce a typcache feature for assigning aunique-within-process identifier to each distinct tuple descriptor ofinterest; in particular, DDL alterations on composite types result in a newidentifier for that type. This allows very cheap detection of the need torefresh tupdesc-dependent data. This improves on the "tupDescSeqNo" ideaI had in commit687f096: that assigned identifying sequence numbers tosuccessive versions of individual composite types, but the numbers were notunique across different types, nor was there support for assigning numbersto registered record types.In passing, allow plpgsql functions to accept as well as return type"record". There was no good reason for the old restriction, and itwas out of step with most of the other PLs.Tom Lane, reviewed by Pavel StehuleDiscussion:https://postgr.es/m/8962.1514399547@sss.pgh.pa.us1 parent2ac3e6a commit4b93f57
File tree
20 files changed
+4589
-906
lines changed- doc/src/sgml
- src
- backend
- executor
- utils
- adt
- cache
- include/utils
- pl
- plpgsql/src
- expected
- sql
- plpython
- test/regress
- expected
- sql
20 files changed
+4589
-906
lines changedLines changed: 3 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
126 |
| - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
127 | 129 |
| |
128 | 130 |
| |
129 | 131 |
| |
| |||
671 | 673 |
| |
672 | 674 |
| |
673 | 675 |
| |
674 |
| - | |
675 |
| - | |
676 |
| - | |
677 |
| - | |
678 |
| - | |
679 |
| - | |
680 |
| - | |
681 |
| - | |
682 | 676 |
| |
683 | 677 |
| |
684 | 678 |
| |
|
Lines changed: 92 additions & 43 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
| 73 | + | |
73 | 74 |
| |
74 | 75 |
| |
75 | 76 |
| |
| |||
2820 | 2821 |
| |
2821 | 2822 |
| |
2822 | 2823 |
| |
2823 |
| - | |
2824 | 2824 |
| |
2825 |
| - | |
2826 | 2825 |
| |
2827 |
| - | |
2828 |
| - | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
2829 | 2830 |
| |
2830 |
| - | |
2831 |
| - | |
2832 |
| - | |
2833 |
| - | |
| 2831 | + | |
2834 | 2832 |
| |
2835 |
| - | |
2836 |
| - | |
2837 |
| - | |
2838 |
| - | |
2839 |
| - | |
2840 |
| - | |
2841 |
| - | |
2842 |
| - | |
2843 |
| - | |
2844 |
| - | |
2845 |
| - | |
2846 |
| - | |
2847 |
| - | |
2848 |
| - | |
2849 |
| - | |
2850 |
| - | |
2851 |
| - | |
2852 |
| - | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
2853 | 2869 |
| |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
2854 | 2874 |
| |
2855 |
| - | |
2856 |
| - | |
2857 |
| - | |
2858 |
| - | |
2859 |
| - | |
2860 |
| - | |
2861 |
| - | |
2862 |
| - | |
2863 |
| - | |
| 2875 | + | |
| 2876 | + | |
2864 | 2877 |
| |
2865 |
| - | |
2866 |
| - | |
2867 |
| - | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
2868 | 2895 |
| |
2869 |
| - | |
2870 |
| - | |
2871 |
| - | |
2872 |
| - | |
2873 |
| - | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
2874 | 2923 |
| |
2875 | 2924 |
| |
2876 | 2925 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 |
| - | |
| 15 | + | |
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
|
0 commit comments
Comments
(0)