- Notifications
You must be signed in to change notification settings - Fork5
Commit3f90235
committed
Clean up after insufficiently-researched optimization of tuple conversions.
tupconvert.c's functions formerly considered that an explicit tupleconversion was necessary if the input and output tupdescs containeddifferent type OIDs. The point of that was to make sure that a compositedatum resulting from the conversion would contain the destination rowtypeOID in its composite-datum header. However, commit3838074 entirelymisunderstood what that check was for, thinking that it had something to dowith presence or absence of an OID column within the tuple. Removal of thecheck broke the no-op conversion path in ExecEvalConvertRowtype, asreported by Ashutosh Bapat.It turns out that of the dozen or so call sites for tupconvert.c functions,ExecEvalConvertRowtype is the only one that cares about the composite-datumheader fields in the output tuple. In all the rest, we'd much rather avoidan unnecessary conversion whenever the tuples are physically compatible.Moreover, the comments in tupconvert.c only promise physical compatibilitynot a metadata match. So, let's accept the removal of the guarantee aboutthe output tuple's rowtype marking, recognizing that this is a API changethat could conceivably break third-party callers of tupconvert.c. (So,let's remember to mention it in the v10 release notes.)However, commit3838074 did have a bit of a point here, in that twotuples mustn't be considered physically compatible if one has HEAP_HASOIDset and the other doesn't. (Some of the callers of tupconvert.c might notreally care about that, but we can't assume it in general.) The previouscheck accidentally covered that issue, because no RECORD types ever haveOIDs, while if two tupdescs have the same named composite type OID then,a fortiori, they have the same tdhasoid setting. If we're removing thetype OID match check then we'd better include tdhasoid match as part ofthe physical compatibility check.Without that hack in tupconvert.c, we need ExecEvalConvertRowtype to takeresponsibility for inserting the correct rowtype OID label whenevertupconvert.c decides it need not do anything. This is easily done withheap_copy_tuple_as_datum, which will be considerably faster than a tupledisassembly and reassembly anyway; so from a performance standpoint thischange is a win all around compared to what happened in earlier branches.It just means a couple more lines of code in ExecEvalConvertRowtype.Ashutosh Bapat and Tom LaneDiscussion:https://postgr.es/m/CAFjFpRfvHABV6+oVvGcshF8rHn+1LfRUhj7Jz1CDZ4gPUwehBg@mail.gmail.com1 parentac2b095 commit3f90235
File tree
4 files changed
+48
-22
lines changed- src
- backend
- access/common
- executor
- test/regress
- expected
- sql
4 files changed
+48
-22
lines changedLines changed: 12 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
138 | 138 |
| |
139 | 139 |
| |
140 | 140 |
| |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
145 | 146 |
| |
146 | 147 |
| |
147 |
| - | |
| 148 | + | |
148 | 149 |
| |
149 | 150 |
| |
150 | 151 |
| |
| |||
215 | 216 |
| |
216 | 217 |
| |
217 | 218 |
| |
218 |
| - | |
219 |
| - | |
220 |
| - | |
221 |
| - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
222 | 224 |
| |
223 | 225 |
| |
224 |
| - | |
| 226 | + | |
225 | 227 |
| |
226 | 228 |
| |
227 | 229 |
| |
|
Lines changed: 22 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2840 | 2840 |
| |
2841 | 2841 |
| |
2842 | 2842 |
| |
2843 |
| - | |
2844 |
| - | |
2845 |
| - | |
2846 |
| - | |
2847 |
| - | |
2848 |
| - | |
2849 |
| - | |
2850 |
| - | |
2851 |
| - | |
| 2843 | + | |
2852 | 2844 |
| |
2853 | 2845 |
| |
2854 | 2846 |
| |
2855 |
| - | |
2856 |
| - | |
2857 |
| - | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
2858 | 2868 |
| |
2859 | 2869 |
| |
2860 | 2870 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
657 | 657 |
| |
658 | 658 |
| |
659 | 659 |
| |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
660 | 669 |
| |
661 | 670 |
| |
662 | 671 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
290 | 295 |
| |
291 | 296 |
| |
292 | 297 |
| |
|
0 commit comments
Comments
(0)