Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8d9a9f

Browse files
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.com
1 parent70fea39 commitf8d9a9f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎src/backend/utils/mmgr/portalmem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,9 @@ pg_cursor(PG_FUNCTION_ARGS)
11501150
/* report only "visible" entries */
11511151
if (!portal->visible)
11521152
continue;
1153+
/* also ignore it if PortalDefineQuery hasn't been called yet */
1154+
if (!portal->sourceText)
1155+
continue;
11531156

11541157
values[0]=CStringGetTextDatum(portal->name);
11551158
values[1]=CStringGetTextDatum(portal->sourceText);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp