Commit cb00b7fa authored by Bruce Momjian's avatar Bruce Momjian

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
parent 11023eb1
...@@ -204,7 +204,7 @@ MISC ...@@ -204,7 +204,7 @@ MISC
* Do autocommit so always in a transaction block(?) * Do autocommit so always in a transaction block(?)
* Show location of syntax error in query [yacc] * Show location of syntax error in query [yacc]
* Redesign the function call interface to handle NULLs better [function] * Redesign the function call interface to handle NULLs better [function]
* Document/trigger/rule so changes to pg_shadow recreate pg_pwd [pg_shadow] * -Document/trigger/rule so changes to pg_shadow recreate pg_pwd [pg_shadow]
* Missing optimizer selectivities for date, r-tree, etc. [optimizer] * Missing optimizer selectivities for date, r-tree, etc. [optimizer]
* -Overhaul mdmgr/smgr to fix double unlinking and double opens, cleanup * -Overhaul mdmgr/smgr to fix double unlinking and double opens, cleanup
* Overhaul bufmgr/lockmgr/transaction manager * Overhaul bufmgr/lockmgr/transaction manager
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: user.c,v 1.40 1999/11/30 04:29:56 momjian Exp $ * $Id: user.c,v 1.41 1999/12/12 05:57:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -43,8 +43,13 @@ static void CheckPgUserAclNotNull(void); ...@@ -43,8 +43,13 @@ static void CheckPgUserAclNotNull(void);
* pg_shadow is the standard way to do that. * pg_shadow is the standard way to do that.
*--------------------------------------------------------------------- *---------------------------------------------------------------------
*/ */
static void
UpdatePgPwdFile(void) /* This is the old name. Now uses a lower case name to be able to call this
from SQL. */
#define UpdatePgPwdFile() update_pg_pwd()
void
update_pg_pwd()
{ {
char *filename, char *filename,
*tempname; *tempname;
...@@ -71,7 +76,7 @@ UpdatePgPwdFile(void) ...@@ -71,7 +76,7 @@ UpdatePgPwdFile(void)
false, /* from */ false, /* from */
false, /* pipe */ false, /* pipe */
tempname, /* filename */ tempname, /* filename */
CRYPT_PWD_FILE_SEPCHAR, /* delim */ CRYPT_PWD_FILE_SEPSTR, /* delim */
0077); /* fileumask */ 0077); /* fileumask */
/* /*
* And rename the temp file to its final name, deleting the old pg_pwd. * And rename the temp file to its final name, deleting the old pg_pwd.
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.63 1999/12/09 04:36:57 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.64 1999/12/12 05:57:30 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -412,6 +412,10 @@ echo ...@@ -412,6 +412,10 @@ echo
PGSQL_OPT="-o /dev/null -O -F -Q -D$PGDATA" PGSQL_OPT="-o /dev/null -O -F -Q -D$PGDATA"
# Create a trigger so that direct updates to pg_shadow will be written
# to the flat password file pg_pwd
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
# Create the initial pg_pwd (flat-file copy of pg_shadow) # Create the initial pg_pwd (flat-file copy of pg_shadow)
echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" | \ echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" | \
postgres $PGSQL_OPT template1 > /dev/null postgres $PGSQL_OPT template1 > /dev/null
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_proc.h,v 1.108 1999/12/01 18:03:26 momjian Exp $ * $Id: pg_proc.h,v 1.109 1999/12/12 05:57:36 momjian Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * The script catalog/genbki.sh reads this file and generates .bki
...@@ -93,6 +93,8 @@ typedef FormData_pg_proc *Form_pg_proc; ...@@ -93,6 +93,8 @@ typedef FormData_pg_proc *Form_pg_proc;
/* keep the following ordered by OID so that later changes can be made easier */ /* keep the following ordered by OID so that later changes can be made easier */
/* OIDS 1 - 99 */ /* OIDS 1 - 99 */
DATA(insert OID = 12 ( update_pg_pwd PGUID 11 f t f 0 f 0 "" 100 0 0 100 update_pg_pwd - ));
DESCR("update pg_pwd file");
DATA(insert OID = 1242 ( boolin PGUID 11 f t t 1 f 16 "0" 100 0 0 100 boolin - )); DATA(insert OID = 1242 ( boolin PGUID 11 f t t 1 f 16 "0" 100 0 0 100 boolin - ));
DESCR("(internal)"); DESCR("(internal)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment