forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita61b1f7
committed
Rework query relation permission checking
Currently, information about the permissions to be checked on relationsmentioned in a query is stored in their range table entries. So theexecutor must scan the entire range table looking for relations thatneed to have permissions checked. This can make the permission checkingpart of the executor initialization needlessly expensive when manyinheritance children are present in the range range. While thepermissions need not be checked on the individual child relations, theexecutor still must visit every range table entry to filter them out.This commit moves the permission checking information out of the rangetable entries into a new plan node called RTEPermissionInfo. Everytop-level (inheritance "root") RTE_RELATION entry in the range tablegets one and a list of those is maintained alongside the range table.This new list is initialized by the parser when initializing the rangetable. The rewriter can add more entries to it as rules/views areexpanded. Finally, the planner combines the lists of the individualsubqueries into one flat list that is passed to the executor forchecking.To make it quick to find the RTEPermissionInfo entry belonging to agiven relation, RangeTblEntry gets a new Index field 'perminfoindex'that stores the corresponding RTEPermissionInfo's index in the query'slist of the latter.ExecutorCheckPerms_hook has gained another List * argument; thesignature is now:typedef bool (*ExecutorCheckPerms_hook_type) (List *rangeTable, List *rtePermInfos, bool ereport_on_violation);The first argument is no longer used by any in-core uses of the hook,but we leave it in place because there may be other implementations thatdo. Implementations should likely scan the rtePermInfos list todetermine which operations to allow or deny.Author: Amit Langote <amitlangote09@gmail.com>Discussion:https://postgr.es/m/CA+HiwqGjJDmUhDSfv-U2qhKJjt9ST7Xh9JXC_irsAQ1TAUsJYg@mail.gmail.com1 parentb5bbaf0 commita61b1f7
File tree
47 files changed
+953
-533
lines changed- contrib
- postgres_fdw
- sepgsql
- src
- backend
- commands
- executor
- nodes
- optimizer
- plan
- prep
- util
- parser
- replication/logical
- rewrite
- utils
- adt
- cache
- include
- catalog
- commands
- executor
- nodes
- optimizer
- parser
- rewrite
- test
- modules/test_oat_hooks
- regress
- expected
- sql
- tools/pgindent
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
47 files changed
+953
-533
lines changedLines changed: 8 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
| 34 | + | |
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
| |||
657 | 658 |
| |
658 | 659 |
| |
659 | 660 |
| |
660 |
| - | |
661 |
| - | |
| 661 | + | |
| 662 | + | |
662 | 663 |
| |
663 | 664 |
| |
664 | 665 |
| |
| |||
1809 | 1810 |
| |
1810 | 1811 |
| |
1811 | 1812 |
| |
1812 |
| - | |
| 1813 | + | |
| 1814 | + | |
1813 | 1815 |
| |
1814 | 1816 |
| |
1815 | 1817 |
| |
| |||
2650 | 2652 |
| |
2651 | 2653 |
| |
2652 | 2654 |
| |
2653 |
| - | |
| 2655 | + | |
2654 | 2656 |
| |
2655 | 2657 |
| |
2656 | 2658 |
| |
| |||
3975 | 3977 |
| |
3976 | 3978 |
| |
3977 | 3979 |
| |
3978 |
| - | |
3979 |
| - | |
3980 |
| - | |
3981 |
| - | |
3982 |
| - | |
| 3980 | + | |
| 3981 | + | |
3983 | 3982 |
| |
3984 | 3983 |
| |
3985 | 3984 |
| |
|
Lines changed: 19 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
277 | 278 |
| |
278 | 279 |
| |
279 | 280 |
| |
280 |
| - | |
| 281 | + | |
| 282 | + | |
281 | 283 |
| |
282 | 284 |
| |
283 | 285 |
| |
284 |
| - | |
| 286 | + | |
285 | 287 |
| |
286 |
| - | |
| 288 | + | |
287 | 289 |
| |
288 | 290 |
| |
289 | 291 |
| |
290 | 292 |
| |
291 |
| - | |
292 |
| - | |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 | 293 |
| |
298 | 294 |
| |
299 | 295 |
| |
300 |
| - | |
| 296 | + | |
301 | 297 |
| |
302 |
| - | |
| 298 | + | |
303 | 299 |
| |
304 |
| - | |
| 300 | + | |
305 | 301 |
| |
306 |
| - | |
| 302 | + | |
307 | 303 |
| |
308 | 304 |
| |
309 | 305 |
| |
310 | 306 |
| |
311 |
| - | |
| 307 | + | |
312 | 308 |
| |
313 | 309 |
| |
314 | 310 |
| |
| |||
323 | 319 |
| |
324 | 320 |
| |
325 | 321 |
| |
326 |
| - | |
327 |
| - | |
| 322 | + | |
| 323 | + | |
328 | 324 |
| |
329 |
| - | |
| 325 | + | |
330 | 326 |
| |
331 | 327 |
| |
332 | 328 |
| |
| |||
339 | 335 |
| |
340 | 336 |
| |
341 | 337 |
| |
342 |
| - | |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 |
| - | |
347 |
| - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
348 | 344 |
| |
349 | 345 |
| |
350 | 346 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
290 |
| - | |
| 290 | + | |
291 | 291 |
| |
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
295 | 295 |
| |
296 | 296 |
| |
297 |
| - | |
| 297 | + | |
298 | 298 |
| |
299 | 299 |
| |
300 |
| - | |
| 300 | + | |
301 | 301 |
| |
302 | 302 |
| |
303 | 303 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
274 | 274 |
| |
275 | 275 |
| |
276 | 276 |
| |
277 |
| - | |
| 277 | + | |
| 278 | + | |
278 | 279 |
| |
279 | 280 |
| |
280 | 281 |
| |
|
Lines changed: 12 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
109 | 109 |
| |
110 | 110 |
| |
111 | 111 |
| |
112 |
| - | |
| 112 | + | |
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
| |||
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
126 |
| - | |
127 |
| - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
128 | 129 |
| |
129 | 130 |
| |
130 | 131 |
| |
| |||
150 | 151 |
| |
151 | 152 |
| |
152 | 153 |
| |
153 |
| - | |
154 |
| - | |
| 154 | + | |
| 155 | + | |
155 | 156 |
| |
156 |
| - | |
157 |
| - | |
158 |
| - | |
159 |
| - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
160 | 161 |
| |
161 |
| - | |
| 162 | + | |
162 | 163 |
| |
163 | 164 |
| |
164 | 165 |
| |
| |||
174 | 175 |
| |
175 | 176 |
| |
176 | 177 |
| |
177 |
| - | |
| 178 | + | |
178 | 179 |
| |
179 | 180 |
| |
180 | 181 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
761 | 761 |
| |
762 | 762 |
| |
763 | 763 |
| |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
764 | 770 |
| |
765 | 771 |
| |
766 | 772 |
| |
| |||
1525 | 1531 |
| |
1526 | 1532 |
| |
1527 | 1533 |
| |
1528 |
| - | |
| 1534 | + | |
1529 | 1535 |
| |
| 1536 | + | |
1530 | 1537 |
| |
| 1538 | + | |
| 1539 | + | |
1531 | 1540 |
| |
1532 | 1541 |
| |
1533 | 1542 |
| |
|
Lines changed: 29 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
367 | 367 |
| |
368 | 368 |
| |
369 | 369 |
| |
370 |
| - | |
| 370 | + | |
371 | 371 |
| |
372 | 372 |
| |
373 | 373 |
| |
| |||
378 | 378 |
| |
379 | 379 |
| |
380 | 380 |
| |
| 381 | + | |
381 | 382 |
| |
| 383 | + | |
382 | 384 |
| |
383 | 385 |
| |
384 | 386 |
| |
| |||
405 | 407 |
| |
406 | 408 |
| |
407 | 409 |
| |
| 410 | + | |
408 | 411 |
| |
409 | 412 |
| |
410 | 413 |
| |
411 | 414 |
| |
412 | 415 |
| |
413 | 416 |
| |
414 |
| - | |
415 |
| - | |
416 |
| - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
417 | 442 |
| |
418 | 443 |
| |
419 | 444 |
| |
|
0 commit comments
Comments
(0)