/* Add the stuff here for groups.
*/
+ UpdatePgPwdFile(sql);
+
+ /* This goes after the UpdatePgPwdFile to be certain that two backends to not
+ * attempt to write to the pg_pwd file at the same time.
+ */
RelationUnsetLockForWrite(pg_user_rel);
heap_close(pg_user_rel);
- UpdatePgPwdFile(sql);
-
if (IsTransactionBlock() && !inblock)
EndTransactionBlock();
}
*/
pg_user_rel = heap_openr(UserRelationName);
pg_user_dsc = RelationGetTupleDescriptor(pg_user_rel);
+ /* Secure a write lock on pg_user so we can be sure that when the dump of
+ * the pg_pwd file is done, there is not another backend doing the same.
+ */
+ RelationSetLockForWrite(pg_user_rel);
scan = heap_beginscan(pg_user_rel, false, false, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer))) {
}
}
heap_endscan(scan);
- heap_close(pg_user_rel);
if (!exists) {
+ RelationUnsetLockForWrite(pg_user_rel);
+ heap_close(pg_user_rel);
UserAbortTransactionBlock();
elog(WARN, "alterUser: user \"%s\" does not exist", stmt->user);
return;
UpdatePgPwdFile(sql);
+ RelationUnsetLockForWrite(pg_user_rel);
+ heap_close(pg_user_rel);
+
if (IsTransactionBlock() && !inblock)
EndTransactionBlock();
}
extern void RemoveUser(char* user) {
char* pg_user;
- Relation pg_rel;
+ Relation pg_user_rel,
+ pg_rel;
TupleDesc pg_dsc;
HeapScanDesc scan;
HeapTuple tuple;
/* Perform a scan of the pg_user relation to find the usesysid of the user to
* be deleted. If it is not found, then return a warning message.
*/
- pg_rel = heap_openr(UserRelationName);
- pg_dsc = RelationGetTupleDescriptor(pg_rel);
+ pg_user_rel = heap_openr(UserRelationName);
+ pg_dsc = RelationGetTupleDescriptor(pg_user_rel);
+ /* Secure a write lock on pg_user so we can be sure that when the dump of
+ * the pg_pwd file is done, there is not another backend doing the same.
+ */
+ RelationSetLockForWrite(pg_user_rel);
- scan = heap_beginscan(pg_rel, false, false, 0, NULL);
+ scan = heap_beginscan(pg_user_rel, false, false, 0, NULL);
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer))) {
datum = heap_getattr(tuple, buffer, Anum_pg_user_usename, pg_dsc, &n);
ReleaseBuffer(buffer);
}
heap_endscan(scan);
- heap_close(pg_rel);
if (usesysid == -1) {
+ RelationUnsetLockForWrite(pg_user_rel);
+ heap_close(pg_user_rel);
UserAbortTransactionBlock();
elog(WARN, "removeUser: user \"%s\" does not exist", user);
return;
UpdatePgPwdFile(sql);
+ RelationUnsetLockForWrite(pg_user_rel);
+ heap_close(pg_user_rel);
+
if (IsTransactionBlock() && !inblock)
EndTransactionBlock();
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.10 1997/12/06 22:56:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.11 1997/12/12 16:26:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
be_portalpush(entry);
/* ----------------
- * pg_eval_dest will put the query results in a portal which will
+ * pg_exec_query_dest will put the query results in a portal which will
* end up on the top of the portal stack.
* ----------------
*/
- pg_eval_dest(query, (char **) NULL, (Oid *) NULL, 0, Local);
+ pg_exec_query_dest(query, (char **) NULL, (Oid *) NULL, 0, Local);
/* ----------------
* pop the portal off the portal stack and return the