Skip to content

Commit 660fbec

Browse files
committed
Prevent show_session_authorization from crashing when session_authorization
hasn't been set. The only known case where this can happen is when show_session_authorization is invoked in an autovacuum process, which is possible if an index function calls it, as for example in bug #5669 from Andrew Geery. We could perhaps try to return a sensible value, such as the name of the cluster-owning superuser; but that seems like much more trouble than the case is worth, and in any case it could create new possible failure modes. Simply returning an empty string seems like the most appropriate fix. Back-patch to all supported versions, even those before autovacuum, just in case there's another way to provoke this crash.
1 parent ee63981 commit 660fbec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/commands/variable.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,10 @@ show_session_authorization(void)
771771
Oid savedoid;
772772
char *endptr;
773773

774+
/* If session_authorization hasn't been set in this process, return "" */
775+
if (value == NULL || value[0] == '\0')
776+
return "";
777+
774778
Assert(strspn(value, "x") == NAMEDATALEN &&
775779
(value[NAMEDATALEN] == 'T' || value[NAMEDATALEN] == 'F'));
776780

0 commit comments

Comments
 (0)