aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/miscinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-08-17 22:14:34 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-08-17 22:14:34 +0000
commitf8d0a82bf9501e1c5efe40e0f55d0c063858f7b4 (patch)
tree4321c1bfc1db0765273c00ba8ef3531f6ab512c7 /src/backend/utils/init/miscinit.c
parent63f850cd4dd3894cf9990f899f2792fae77fdfb8 (diff)
downloadpostgresql-f8d0a82bf9501e1c5efe40e0f55d0c063858f7b4.tar.gz
postgresql-f8d0a82bf9501e1c5efe40e0f55d0c063858f7b4.zip
Avoid an Assert failure if OuterUserId hasn't been set yet during
AbortTransaction. This can happen if a backend's InitPostgres transaction fails (eg, because the given username is invalid). Per Alvaro.
Diffstat (limited to 'src/backend/utils/init/miscinit.c')
-rw-r--r--src/backend/utils/init/miscinit.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index f6c50438e03..148e2609734 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.148 2005/07/31 17:19:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.149 2005/08/17 22:14:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -286,7 +286,7 @@ make_absolute_path(const char *path)
* OuterUserId is the current user ID in effect at the "outer level" (outside
* any transaction or function). This is initially the same as SessionUserId,
* but can be changed by SET ROLE to any role that SessionUserId is a
- * member of. We store this mainly so that AbortTransaction knows what to
+ * member of. We store this mainly so that AtAbort_UserId knows what to
* reset CurrentUserId to.
*
* CurrentUserId is the current effective user ID; this is the one to use
@@ -497,6 +497,21 @@ InitializeSessionUserIdStandalone(void)
/*
+ * Reset effective userid during AbortTransaction
+ *
+ * This is essentially SetUserId(GetOuterUserId()), but without the Asserts.
+ * The reason is that if a backend's InitPostgres transaction fails (eg,
+ * because an invalid user name was given), we have to be able to get through
+ * AbortTransaction without asserting.
+ */
+void
+AtAbort_UserId(void)
+{
+ CurrentUserId = OuterUserId;
+}
+
+
+/*
* Change session auth ID while running
*
* Only a superuser may set auth ID to something other than himself. Note