forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit589be6f
committed
Fix missed lock acquisition while inlining new-style SQL functions.
When starting to use a query parsetree loaded from the catalogs,we must begin by applying AcquireRewriteLocks(), to obtain the samerelation locks that the parser would have gotten if the query wereentered interactively, and to do some other cleanup such as dealingwith later-dropped columns. New-style SQL functions are just assubject to this rule as other stored parsetrees; however, of theplaces dealing with such functions, only init_sql_fcache had gottenthe memo. In particular, if we successfully inlined a new-styleset-returning SQL function that contained any relation references,we'd either get an assertion failure or attempt to use thoserelation(s) sans locks.I also added AcquireRewriteLocks calls to fmgr_sql_validator andprint_function_sqlbody. Desultory experiments didn't demonstrate anyfailures in those, but I suspect that I just didn't try hard enough.Certainly we don't expect nearby code paths to operate without locks.On the same logic of it-ought-to-have-the-same-effects-as-the-old-code,call pg_rewrite_query() in fmgr_sql_validator, too. It's possiblethat neither code path there needs to bother with rewriting, butdoing the analysis to prove that is beyond my goals for today.Per bug #17161 from Alexander Lakhin.Discussion:https://postgr.es/m/17161-048a1cdff8422800@postgresql.org1 parentbb466c6 commit589be6f
File tree
5 files changed
+64
-20
lines changed- src
- backend
- catalog
- optimizer/util
- utils/adt
- test/regress
- expected
- sql
5 files changed
+64
-20
lines changedLines changed: 21 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
| 38 | + | |
38 | 39 |
| |
39 | 40 |
| |
40 | 41 |
| |
| |||
891 | 892 |
| |
892 | 893 |
| |
893 | 894 |
| |
| 895 | + | |
894 | 896 |
| |
895 | 897 |
| |
896 | 898 |
| |
897 |
| - | |
| 899 | + | |
898 | 900 |
| |
899 |
| - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
900 | 919 |
| |
901 | 920 |
| |
902 | 921 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
| 46 | + | |
46 | 47 |
| |
47 | 48 |
| |
48 | 49 |
| |
| |||
4470 | 4471 |
| |
4471 | 4472 |
| |
4472 | 4473 |
| |
| 4474 | + | |
| 4475 | + | |
| 4476 | + | |
| 4477 | + | |
| 4478 | + | |
| 4479 | + | |
4473 | 4480 |
| |
4474 | 4481 |
| |
4475 | 4482 |
| |
| |||
5022 | 5029 |
| |
5023 | 5030 |
| |
5024 | 5031 |
| |
| 5032 | + | |
| 5033 | + | |
5025 | 5034 |
| |
5026 | 5035 |
| |
5027 | 5036 |
| |
|
Lines changed: 12 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2973 | 2973 |
| |
2974 | 2974 |
| |
2975 | 2975 |
| |
2976 |
| - | |
| 2976 | + | |
2977 | 2977 |
| |
2978 | 2978 |
| |
2979 | 2979 |
| |
| |||
3439 | 3439 |
| |
3440 | 3440 |
| |
3441 | 3441 |
| |
3442 |
| - | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
3443 | 3446 |
| |
3444 | 3447 |
| |
3445 | 3448 |
| |
| |||
3448 | 3451 |
| |
3449 | 3452 |
| |
3450 | 3453 |
| |
3451 |
| - | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
3452 | 3460 |
| |
3453 | 3461 |
| |
3454 | 3462 |
| |
| |||
3467 | 3475 |
| |
3468 | 3476 |
| |
3469 | 3477 |
| |
3470 |
| - | |
| 3478 | + | |
3471 | 3479 |
| |
3472 | 3480 |
| |
3473 | 3481 |
| |
|
Lines changed: 15 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
543 | 543 |
| |
544 | 544 |
| |
545 | 545 |
| |
| 546 | + | |
| 547 | + | |
546 | 548 |
| |
547 | 549 |
| |
548 | 550 |
| |
549 | 551 |
| |
550 |
| - | |
| 552 | + | |
551 | 553 |
| |
552 | 554 |
| |
553 | 555 |
| |
| |||
558 | 560 |
| |
559 | 561 |
| |
560 | 562 |
| |
561 |
| - | |
562 |
| - | |
563 |
| - | |
564 |
| - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
565 | 567 |
| |
566 | 568 |
| |
567 | 569 |
| |
568 | 570 |
| |
569 | 571 |
| |
570 | 572 |
| |
571 |
| - | |
| 573 | + | |
572 | 574 |
| |
573 | 575 |
| |
574 | 576 |
| |
| |||
579 | 581 |
| |
580 | 582 |
| |
581 | 583 |
| |
582 |
| - | |
583 |
| - | |
584 |
| - | |
585 |
| - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
586 | 588 |
| |
587 | 589 |
| |
| 590 | + | |
| 591 | + | |
588 | 592 |
| |
589 | 593 |
| |
590 | 594 |
| |
| |||
643 | 647 |
| |
644 | 648 |
| |
645 | 649 |
| |
646 |
| - | |
| 650 | + | |
647 | 651 |
| |
648 | 652 |
| |
649 | 653 |
| |
| |||
668 | 672 |
| |
669 | 673 |
| |
670 | 674 |
| |
671 |
| - | |
672 | 675 |
| |
673 | 676 |
| |
674 | 677 |
| |
|
Lines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
319 | 319 |
| |
320 | 320 |
| |
321 | 321 |
| |
| 322 | + | |
| 323 | + | |
| 324 | + | |
322 | 325 |
| |
323 | 326 |
| |
324 | 327 |
| |
325 | 328 |
| |
326 |
| - | |
| 329 | + | |
327 | 330 |
| |
328 | 331 |
| |
329 | 332 |
| |
| |||
333 | 336 |
| |
334 | 337 |
| |
335 | 338 |
| |
336 |
| - | |
| 339 | + | |
337 | 340 |
| |
338 | 341 |
| |
339 | 342 |
| |
340 | 343 |
| |
341 | 344 |
| |
| 345 | + | |
| 346 | + | |
342 | 347 |
| |
343 | 348 |
| |
344 | 349 |
| |
|
0 commit comments
Comments
(0)