Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e16f04c

Browse files
committed
Make CREATE/ALTER/DROP USER/GROUP transaction-safe, or at least pretty
nearly so, by postponing write of flat password file until transaction commit.
1 parent de9d7f4 commit e16f04c

File tree

3 files changed

+163
-77
lines changed

3 files changed

+163
-77
lines changed

src/backend/access/transam/xact.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.132 2002/09/04 20:31:13 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.133 2002/10/21 19:46:45 tgl Exp $
1212
*
1313
* NOTES
1414
* Transaction aborts can now occur two ways:
@@ -167,6 +167,7 @@
167167
#include "catalog/namespace.h"
168168
#include "commands/async.h"
169169
#include "commands/trigger.h"
170+
#include "commands/user.h"
170171
#include "executor/spi.h"
171172
#include "libpq/be-fsstubs.h"
172173
#include "miscadmin.h"
@@ -959,18 +960,25 @@ CommitTransaction(void)
959960
s->state = TRANS_COMMIT;
960961

961962
/*
962-
* do commit processing
963+
* Do pre-commit processing (most of this stuff requires database
964+
* access, and in fact could still cause an error...)
963965
*/
964966

967+
AtEOXact_portals();
968+
965969
/* handle commit for large objects [ PA, 7/17/98 ] */
970+
/* XXX probably this does not belong here */
966971
lo_commit(true);
967972

968-
/* NOTIFY commit must also come before lower-level cleanup */
973+
/* NOTIFY commit must come before lower-level cleanup */
969974
AtCommit_Notify();
970975

971-
AtEOXact_portals();
976+
/* Update the flat password file if we changed pg_shadow or pg_group */
977+
AtEOXact_UpdatePasswordFile(true);
972978

973-
/* Here is where we really truly commit. */
979+
/*
980+
* Here is where we really truly commit.
981+
*/
974982
RecordTransactionCommit();
975983

976984
/*
@@ -1013,7 +1021,6 @@ CommitTransaction(void)
10131021
AtEOXact_CatCache(true);
10141022
AtCommit_Memory();
10151023
AtEOXact_Buffers(true);
1016-
smgrabort();
10171024
AtEOXact_Files();
10181025

10191026
/* Count transaction commit in statistics collector */
@@ -1080,9 +1087,10 @@ AbortTransaction(void)
10801087
* do abort processing
10811088
*/
10821089
DeferredTriggerAbortXact();
1090+
AtEOXact_portals();
10831091
lo_commit(false); /* 'false' means it's abort */
10841092
AtAbort_Notify();
1085-
AtEOXact_portals();
1093+
AtEOXact_UpdatePasswordFile(false);
10861094

10871095
/* Advertise the fact that we aborted in pg_clog. */
10881096
RecordTransactionAbort();
@@ -1114,6 +1122,7 @@ AbortTransaction(void)
11141122
AtEOXact_CatCache(false);
11151123
AtAbort_Memory();
11161124
AtEOXact_Buffers(false);
1125+
smgrabort();
11171126
AtEOXact_Files();
11181127
AtAbort_Locks();
11191128

0 commit comments

Comments
 (0)