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

Commit cb00b7f

Browse files
committed
I'm in TODO mood today ...
* Document/trigger/rule so changes to pg_shadow recreate pg_pwd I did it with a trigger and it seems to work like a charm. The function that already updates the file for create and alter user has been made a built-in "SQL" function and a trigger is created at initdb time. Comments around the pg_pwd updating function seem to be worried about this routine being called concurrently, but I really don't see a reason to worry about this. Verify for yourself. I guess we never had a system trigger before, so treat this with care, and feel free to adjust the nomenclature as well. -- Peter Eisentraut Sernanders väg 10:115
1 parent 11023eb commit cb00b7f

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

doc/TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ MISC
204204
* Do autocommit so always in a transaction block(?)
205205
* Show location of syntax error in query [yacc]
206206
* Redesign the function call interface to handle NULLs better [function]
207-
* Document/trigger/rule so changes to pg_shadow recreate pg_pwd [pg_shadow]
207+
* -Document/trigger/rule so changes to pg_shadow recreate pg_pwd [pg_shadow]
208208
* Missing optimizer selectivities for date, r-tree, etc. [optimizer]
209209
* -Overhaul mdmgr/smgr to fix double unlinking and double opens, cleanup
210210
* Overhaul bufmgr/lockmgr/transaction manager

src/backend/commands/user.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: user.c,v 1.40 1999/11/30 04:29:56 momjian Exp $
8+
* $Id: user.c,v 1.41 1999/12/12 05:57:28 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -43,8 +43,13 @@ static void CheckPgUserAclNotNull(void);
4343
* pg_shadow is the standard way to do that.
4444
*---------------------------------------------------------------------
4545
*/
46-
static void
47-
UpdatePgPwdFile(void)
46+
47+
/* This is the old name. Now uses a lower case name to be able to call this
48+
from SQL. */
49+
#define UpdatePgPwdFile() update_pg_pwd()
50+
51+
void
52+
update_pg_pwd()
4853
{
4954
char *filename,
5055
*tempname;
@@ -71,7 +76,7 @@ UpdatePgPwdFile(void)
7176
false, /* from */
7277
false, /* pipe */
7378
tempname, /* filename */
74-
CRYPT_PWD_FILE_SEPCHAR, /* delim */
79+
CRYPT_PWD_FILE_SEPSTR, /* delim */
7580
0077); /* fileumask */
7681
/*
7782
* And rename the temp file to its final name, deleting the old pg_pwd.

src/bin/initdb/initdb.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
#
2828
# IDENTIFICATION
29-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.63 1999/12/09 04:36:57 momjian Exp $
29+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.64 1999/12/12 05:57:30 momjian Exp $
3030
#
3131
#-------------------------------------------------------------------------
3232

@@ -412,6 +412,10 @@ echo
412412

413413
PGSQL_OPT="-o /dev/null -O -F -Q -D$PGDATA"
414414

415+
# Create a trigger so that direct updates to pg_shadow will be written
416+
# to the flat password file pg_pwd
417+
echo "CREATE TRIGGER pg_sync_pg_pwd AFTER INSERT OR UPDATE OR DELETE ON pg_shadow FOR EACH ROW EXECUTE PROCEDURE update_pg_pwd()" | postgres $PGSQL_OPT template1 > /dev/null
418+
415419
# Create the initial pg_pwd (flat-file copy of pg_shadow)
416420
echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" | \
417421
postgres $PGSQL_OPT template1 > /dev/null

src/include/catalog/pg_proc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_proc.h,v 1.108 1999/12/01 18:03:26 momjian Exp $
9+
* $Id: pg_proc.h,v 1.109 1999/12/12 05:57:36 momjian Exp $
1010
*
1111
* NOTES
1212
* The script catalog/genbki.sh reads this file and generates .bki
@@ -93,6 +93,8 @@ typedef FormData_pg_proc *Form_pg_proc;
9393
/* keep the following ordered by OID so that later changes can be made easier */
9494

9595
/* OIDS 1 - 99 */
96+
DATA(insert OID = 12 ( update_pg_pwd PGUID 11 f t f 0 f 0 "" 100 0 0 100 update_pg_pwd - ));
97+
DESCR("update pg_pwd file");
9698

9799
DATA(insert OID = 1242 ( boolin PGUID 11 f t t 1 f 16 "0" 100 0 0 100 boolin - ));
98100
DESCR("(internal)");

0 commit comments

Comments
 (0)