forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf8d9a9f
committed
Ignore not-yet-defined Portals in pg_cursors view.
pg_cursor() supposed that any Portal it finds in the hash table musthave sourceText set up, but there's an edge case where that is not so.A newly-created Portal has sourceText = NULL, and that doesn't changeuntil PortalDefineQuery is called. In SPI_cursor_open_internal,we perform GetCachedPlan between CreatePortal and PortalDefineQuery,and it's possible for user-defined code to execute during thatplanning and cause a fetch from the pg_cursors view, resulting in anull-pointer-dereference crash. (It looks like the same could happenin exec_bind_message, but I've not tried to provoke a failure there.)I considered trying to fix this by setting sourceText sooner, butthere may be instances of this same calling pattern in extensions,and we couldn't be sure they'd get the memo promptly. It seemsbetter to redefine pg_cursor as not showing Portals that havenot yet had PortalDefineQuery called on them, which we can do byjust skipping them if sourceText is still NULL.(Beforea1c6923, pg_cursor would instead return a row with NULLin the statement column. We could revert to that behavior but itdoesn't really seem like a better definition, especially since ourdocumentation doesn't suggest that the column could be NULL.)Per report from PetSerAl. Back-patch to all supported branches.Discussion:https://postgr.es/m/CAKygsHTBXLXjwV43kpZa+Cs+XTiaeeJiZdL4cPBm9f4MTdw7wg@mail.gmail.com1 parent70fea39 commitf8d9a9f
1 file changed
+3
-0
lines changedLines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1150 | 1150 |
| |
1151 | 1151 |
| |
1152 | 1152 |
| |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
1153 | 1156 |
| |
1154 | 1157 |
| |
1155 | 1158 |
| |
|
0 commit comments
Comments
(0)