- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit906b682
committed
Fix re-execution of a failed SQLFunctionCache entry.
If we error out during execution of a SQL-language function, we willoften leave behind non-null pointers in its SQLFunctionCache's cplanand eslist fields. This is problematic if the SQLFunctionCache isre-used, because those pointers will point at resources that werereleased during error cleanup. This problem escaped detection so farbecause ordinarily we won't re-use an FmgrInfo+SQLFunctionCache structafter a query error. However, in the rather improbable case thatsomeone implements an opclass support function in SQL language, therewill be long-lived FmgrInfos for it in the relcache, and then theproblem is reachable after the function throws an error.To fix, add a flag to SQLFunctionCache that tracks whether executionescapes out of fmgr_sql, and clear out the relevant fields duringinit_sql_fcache if so. (This is going to need more thought if we evertry to share FMgrInfos across threads; but it's very far from beingthe only problem such a project will encounter, since many functionsregard fn_extra as being query-local state.)This broke at commit0313c5d; before that we did not try to re-useSQLFunctionCache state across calls. Hence, back-patch to v18.Bug: #19026Reported-by: Alexander Lakhin <exclusion@gmail.com>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/19026-90aed5e71d0c8af3@postgresql.orgBackpatch-through: 181 parentea1c6b0 commit906b682
File tree
3 files changed
+66
-1
lines changed- src
- backend/executor
- test/regress
- expected
- sql
3 files changed
+66
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
559 | 582 | | |
560 | 583 | | |
561 | 584 | | |
| |||
1597 | 1620 | | |
1598 | 1621 | | |
1599 | 1622 | | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
1600 | 1626 | | |
1601 | 1627 | | |
1602 | 1628 | | |
| |||
1853 | 1879 | | |
1854 | 1880 | | |
1855 | 1881 | | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
1856 | 1885 | | |
1857 | 1886 | | |
1858 | 1887 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
736 | 752 | | |
737 | 753 | | |
738 | 754 | | |
| |||
773 | 789 | | |
774 | 790 | | |
775 | 791 | | |
776 | | - | |
| 792 | + | |
777 | 793 | | |
778 | 794 | | |
779 | 795 | | |
| |||
808 | 824 | | |
809 | 825 | | |
810 | 826 | | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
811 | 830 | | |
812 | 831 | | |
813 | 832 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
435 | 452 | | |
436 | 453 | | |
437 | 454 | | |
| |||
0 commit comments
Comments
(0)