aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-09-23 16:53:42 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2010-09-23 16:53:42 -0400
commit511449d40fd48ba97556a03c272fd66b9c2c3f9c (patch)
tree9b24512dc350e9781c49ebd34cabffe4e25246d6 /src/backend/commands/variable.c
parent4e2e9f27dd1590c8a0fbe2ac9d0ac0a3253f05e6 (diff)
downloadpostgresql-511449d40fd48ba97556a03c272fd66b9c2c3f9c.tar.gz
postgresql-511449d40fd48ba97556a03c272fd66b9c2c3f9c.zip
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.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 4ec57e11d33..206a1d1898a 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -680,6 +680,10 @@ show_session_authorization(void)
Oid savedoid;
char *endptr;
+ /* If session_authorization hasn't been set in this process, return "" */
+ if (value == NULL || value[0] == '\0')
+ return "";
+
Assert(strspn(value, "x") == NAMEDATALEN &&
(value[NAMEDATALEN] == 'T' || value[NAMEDATALEN] == 'F'));