aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-10-26 13:43:28 +0000
committerBruce Momjian <bruce@momjian.us>2005-10-26 13:43:28 +0000
commitc3d56155d4a8f6c94d19a5caa91f355cd41eace1 (patch)
treee8f75cbdb6359209dcfa362bb5c285bba1db64b0 /src
parent8f03406ee91406262beb90ce516718e7b860e8d7 (diff)
downloadpostgresql-c3d56155d4a8f6c94d19a5caa91f355cd41eace1.tar.gz
postgresql-c3d56155d4a8f6c94d19a5caa91f355cd41eace1.zip
Properly update the 'group' flatfile when modifying the user, in case
they were added to a group. Also fix visibility of our own changes when creating the group file. This fixes: test=> CREATE GROUP g1; CREATE GROUP test=> CREATE USER u1 IN GROUP g1; CREATE USER test=> \! cat /u/pg/data/global/pg_group "g1" "u1" test=> CREATE USER u2 IN GROUP g1; CREATE USER test=> \! cat /u/pg/data/global/pg_group "g1" "u1" "u2" test=> ALTER USER u2 RENAME TO u3; ALTER USER test=> \! cat /u/pg/data/global/pg_group "g1" "u1" "u3" [ this code does not exist in CVS head.] Per report from Dennis Vshivkov
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/user.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index ff4f33b0739..c69956d41c9 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.147 2004/12/31 21:59:42 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.147.4.1 2005/10/26 13:43:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,11 +174,10 @@ write_group_file(Relation grel)
errmsg("could not write to temporary file \"%s\": %m", tempname)));
/*
- * Read pg_group and write the file. Note we use SnapshotSelf to
- * ensure we see all effects of current transaction. (Perhaps could
- * do a CommandCounterIncrement beforehand, instead?)
+ * Read pg_group and write the file
*/
- scan = heap_beginscan(grel, SnapshotSelf, 0, NULL);
+ CommandCounterIncrement(); /* see our current changes */
+ scan = heap_beginscan(grel, SnapshotNow, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Datum datum,
@@ -321,11 +320,10 @@ write_user_file(Relation urel)
errmsg("could not write to temporary file \"%s\": %m", tempname)));
/*
- * Read pg_shadow and write the file. Note we use SnapshotSelf to
- * ensure we see all effects of current transaction. (Perhaps could
- * do a CommandCounterIncrement beforehand, instead?)
+ * Read pg_shadow and write the file
*/
- scan = heap_beginscan(urel, SnapshotSelf, 0, NULL);
+ CommandCounterIncrement(); /* see our current changes */
+ scan = heap_beginscan(urel, SnapshotNow, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Datum datum;
@@ -781,6 +779,7 @@ CreateUser(CreateUserStmt *stmt)
* Set flag to update flat password file at commit.
*/
user_file_update_needed();
+ group_file_update_needed();
}
@@ -1200,6 +1199,7 @@ DropUser(DropUserStmt *stmt)
* Set flag to update flat password file at commit.
*/
user_file_update_needed();
+ group_file_update_needed();
}
@@ -1286,6 +1286,7 @@ RenameUser(const char *oldname, const char *newname)
heap_close(rel, NoLock);
user_file_update_needed();
+ group_file_update_needed();
}