- Notifications
You must be signed in to change notification settings - Fork5
Commita102f98
committed
Mark read/write expanded values as read-only in ExecProject().
If a plan node output expression returns an "expanded" datum, and thatoutput column is referenced in more than one place in upper-level plannodes, we need to ensure that what is returned is a read-only referencenot a read/write reference. Otherwise one of the referencing sites couldscribble on or even delete the expanded datum before we have evaluated theothers. Commit1dc5ebc, which introduced this feature, supposedthat it'd be sufficient to make SubqueryScan nodes force their outputcolumns to read-only state. The folly of that was revealed by bug #14174from Andrew Gierth, and really should have been immediately obviousconsidering that the planner will happily optimize SubqueryScan nodesout of the plan without any regard for this issue.The safest fix seems to be to make ExecProject() force its results intoread-only state; that will cover every case where a plan node returnsexpression results. Actually we can delegate this to ExecTargetList()since we can recursively assume that plain Vars will not referenceread-write datums. That should keep the extra overhead down to somethingminimal. We no longer need ExecMakeSlotContentsReadOnly(), which wasintroduced only in support of the idea that just a few plan node typeswould need to do this.In the future it would be nice to have the planner account for this problemand inject force-to-read-only expression evaluation nodes into only theplaces where there's a risk of multiple evaluation. That's not a suitablesolution for 9.5 or even 9.6 at this point, though.Report: <20160603124628.9932.41279@wrigleys.postgresql.org>1 parentec56223 commita102f98
File tree
6 files changed
+89
-58
lines changed- src
- backend/executor
- include/executor
- test/regress
- expected
- sql
6 files changed
+89
-58
lines changedLines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5333 | 5333 |
| |
5334 | 5334 |
| |
5335 | 5335 |
| |
| 5336 | + | |
| 5337 | + | |
| 5338 | + | |
| 5339 | + | |
| 5340 | + | |
| 5341 | + | |
| 5342 | + | |
5336 | 5343 |
| |
5337 | 5344 |
| |
5338 | 5345 |
| |
| 5346 | + | |
5339 | 5347 |
| |
5340 | 5348 |
| |
5341 | 5349 |
| |
5342 | 5350 |
| |
5343 | 5351 |
| |
5344 | 5352 |
| |
| 5353 | + | |
5345 | 5354 |
| |
5346 | 5355 |
| |
5347 | 5356 |
| |
| |||
5367 | 5376 |
| |
5368 | 5377 |
| |
5369 | 5378 |
| |
| 5379 | + | |
| 5380 | + | |
| 5381 | + | |
| 5382 | + | |
5370 | 5383 |
| |
5371 | 5384 |
| |
5372 | 5385 |
| |
| |||
5420 | 5433 |
| |
5421 | 5434 |
| |
5422 | 5435 |
| |
| 5436 | + | |
| 5437 | + | |
| 5438 | + | |
| 5439 | + | |
5423 | 5440 |
| |
5424 | 5441 |
| |
5425 | 5442 |
| |
| |||
5453 | 5470 |
| |
5454 | 5471 |
| |
5455 | 5472 |
| |
| 5473 | + | |
5456 | 5474 |
| |
5457 | 5475 |
| |
5458 | 5476 |
| |
| |||
5578 | 5596 |
| |
5579 | 5597 |
| |
5580 | 5598 |
| |
| 5599 | + | |
5581 | 5600 |
| |
5582 | 5601 |
| |
5583 | 5602 |
| |
|
Lines changed: 0 additions & 47 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
91 |
| - | |
92 | 91 |
| |
93 | 92 |
| |
94 | 93 |
| |
| |||
813 | 812 |
| |
814 | 813 |
| |
815 | 814 |
| |
816 |
| - | |
817 |
| - | |
818 |
| - | |
819 |
| - | |
820 |
| - | |
821 |
| - | |
822 |
| - | |
823 |
| - | |
824 |
| - | |
825 |
| - | |
826 |
| - | |
827 |
| - | |
828 |
| - | |
829 |
| - | |
830 |
| - | |
831 |
| - | |
832 |
| - | |
833 |
| - | |
834 |
| - | |
835 |
| - | |
836 |
| - | |
837 |
| - | |
838 |
| - | |
839 |
| - | |
840 |
| - | |
841 |
| - | |
842 |
| - | |
843 |
| - | |
844 |
| - | |
845 |
| - | |
846 |
| - | |
847 |
| - | |
848 |
| - | |
849 |
| - | |
850 |
| - | |
851 |
| - | |
852 |
| - | |
853 |
| - | |
854 |
| - | |
855 |
| - | |
856 |
| - | |
857 |
| - | |
858 |
| - | |
859 |
| - | |
860 |
| - | |
861 |
| - | |
862 | 815 |
| |
863 | 816 |
| |
864 | 817 |
| |
|
Lines changed: 0 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
59 |
| - | |
60 |
| - | |
61 |
| - | |
62 |
| - | |
63 |
| - | |
64 | 59 |
| |
65 |
| - | |
66 |
| - | |
67 |
| - | |
68 | 60 |
| |
69 | 61 |
| |
70 | 62 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
163 | 163 |
| |
164 | 164 |
| |
165 | 165 |
| |
166 |
| - | |
167 | 166 |
| |
168 | 167 |
| |
169 | 168 |
| |
|
Lines changed: 39 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5304 | 5304 |
| |
5305 | 5305 |
| |
5306 | 5306 |
| |
5307 |
| - | |
| 5307 | + | |
| 5308 | + | |
| 5309 | + | |
| 5310 | + | |
| 5311 | + | |
| 5312 | + | |
| 5313 | + | |
| 5314 | + | |
| 5315 | + | |
| 5316 | + | |
| 5317 | + | |
| 5318 | + | |
| 5319 | + | |
| 5320 | + | |
| 5321 | + | |
| 5322 | + | |
| 5323 | + | |
| 5324 | + | |
| 5325 | + | |
| 5326 | + | |
| 5327 | + | |
| 5328 | + | |
| 5329 | + | |
| 5330 | + | |
| 5331 | + | |
| 5332 | + | |
| 5333 | + | |
| 5334 | + | |
| 5335 | + | |
| 5336 | + | |
| 5337 | + | |
| 5338 | + | |
| 5339 | + | |
| 5340 | + | |
| 5341 | + | |
| 5342 | + | |
| 5343 | + | |
| 5344 | + | |
| 5345 | + | |
5308 | 5346 |
| |
5309 | 5347 |
| |
5310 | 5348 |
| |
|
Lines changed: 31 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4199 | 4199 |
| |
4200 | 4200 |
| |
4201 | 4201 |
| |
4202 |
| - | |
| 4202 | + | |
| 4203 | + | |
| 4204 | + | |
| 4205 | + | |
| 4206 | + | |
| 4207 | + | |
| 4208 | + | |
| 4209 | + | |
| 4210 | + | |
| 4211 | + | |
| 4212 | + | |
| 4213 | + | |
| 4214 | + | |
| 4215 | + | |
| 4216 | + | |
| 4217 | + | |
| 4218 | + | |
| 4219 | + | |
| 4220 | + | |
| 4221 | + | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
| 4231 | + | |
| 4232 | + | |
4203 | 4233 |
| |
4204 | 4234 |
| |
4205 | 4235 |
| |
|
0 commit comments
Comments
(0)