aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-09-23 16:53:28 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2010-09-23 16:53:28 -0400
commit63dcb4526fbad3a7eec6af56652d759eaf0058b1 (patch)
tree352b338494c2995d85f72f4283ca8994e248f5bf
parentcd198f81f31ad169627645a13c201b95ad881867 (diff)
downloadpostgresql-63dcb4526fbad3a7eec6af56652d759eaf0058b1.tar.gz
postgresql-63dcb4526fbad3a7eec6af56652d759eaf0058b1.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.
-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 a0df419aefe..94295616196 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -773,6 +773,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'));