mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
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
This commit is contained in:
parent
8f03406ee9
commit
c3d56155d4
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user