]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Properly update the 'group' flatfile when modifying the user, in case
authorBruce Momjian <bruce@momjian.us>
Wed, 26 Oct 2005 13:43:28 +0000 (13:43 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 26 Oct 2005 13:43:28 +0000 (13:43 +0000)
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

src/backend/commands/user.c

index ff4f33b0739ed1d1e1a6eb8193fb5bf08cd8b9e5..c69956d41c97a8f0b3ac74f90017f6ff4ad7e67f 100644 (file)
@@ -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();
 }