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

Commitf8d0a82

Browse files
committed
Avoid an Assert failure if OuterUserId hasn't been set yet during
AbortTransaction. This can happen if a backend's InitPostgres transactionfails (eg, because the given username is invalid). Per Alvaro.
1 parent63f850c commitf8d0a82

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.212 2005/08/08 19:17:22 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.213 2005/08/17 22:14:33 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1877,16 +1877,16 @@ AbortTransaction(void)
18771877

18781878
/*
18791879
* Reset user id which might have been changed transiently. We cannot
1880-
* use s->currentUser,but must get the session outer-level userid from
1881-
* miscinit.c.
1880+
* use s->currentUser,since it may not be set yet; instead rely on
1881+
*internal state ofmiscinit.c.
18821882
*
18831883
* (Note: it is not necessary to restore session authorization here
18841884
* because that can only be changed via GUC, and GUC will take care of
18851885
* rolling it back if need be.However, an error within a SECURITY
18861886
* DEFINER function could send control here with the wrong current
18871887
* userid.)
18881888
*/
1889-
SetUserId(GetOuterUserId());
1889+
AtAbort_UserId();
18901890

18911891
/*
18921892
* do abort processing

‎src/backend/utils/init/miscinit.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.148 2005/07/31 17:19:19 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.149 2005/08/17 22:14:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -286,7 +286,7 @@ make_absolute_path(const char *path)
286286
* OuterUserId is the current user ID in effect at the "outer level" (outside
287287
* any transaction or function). This is initially the same as SessionUserId,
288288
* but can be changed by SET ROLE to any role that SessionUserId is a
289-
* member of. We store this mainly so thatAbortTransaction knows what to
289+
* member of. We store this mainly so thatAtAbort_UserId knows what to
290290
* reset CurrentUserId to.
291291
*
292292
* CurrentUserId is the current effective user ID; this is the one to use
@@ -496,6 +496,21 @@ InitializeSessionUserIdStandalone(void)
496496
}
497497

498498

499+
/*
500+
* Reset effective userid during AbortTransaction
501+
*
502+
* This is essentially SetUserId(GetOuterUserId()), but without the Asserts.
503+
* The reason is that if a backend's InitPostgres transaction fails (eg,
504+
* because an invalid user name was given), we have to be able to get through
505+
* AbortTransaction without asserting.
506+
*/
507+
void
508+
AtAbort_UserId(void)
509+
{
510+
CurrentUserId=OuterUserId;
511+
}
512+
513+
499514
/*
500515
* Change session auth ID while running
501516
*

‎src/include/miscadmin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.178 2005/07/25 22:12:34 tgl Exp $
16+
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.179 2005/08/17 22:14:34 tgl Exp $
1717
*
1818
* NOTES
1919
* some of the information in this file should be moved to other files.
@@ -235,6 +235,7 @@ extern Oid GetOuterUserId(void);
235235
externOidGetSessionUserId(void);
236236
externvoidInitializeSessionUserId(constchar*rolename);
237237
externvoidInitializeSessionUserIdStandalone(void);
238+
externvoidAtAbort_UserId(void);
238239
externvoidSetSessionAuthorization(Oiduserid,boolis_superuser);
239240
externOidGetCurrentRoleId(void);
240241
externvoidSetCurrentRoleId(Oidroleid,boolis_superuser);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp