Here is a patch.

I have changed to call pg_exec_query_dest() instead of pg_exec_query().

Thanks.

Hiroshi Inoue
This commit is contained in:
Bruce Momjian 1999-03-16 03:24:18 +00:00
parent 787786085f
commit 434762b559
5 changed files with 34 additions and 34 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.31 1999/03/15 14:07:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.32 1999/03/16 03:24:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -24,13 +24,13 @@
#include "catalog/catname.h"
#include "catalog/pg_database.h"
#include "catalog/pg_shadow.h"
#include "commands/dbcommands.h"
#include "fmgr.h"
#include "miscadmin.h" /* for DataDir */
#include "storage/bufmgr.h"
#include "storage/fd.h"
#include "storage/lmgr.h"
#include "tcop/tcopprot.h"
#include "commands/dbcommands.h"
#include "utils/rel.h"
#include "utils/syscache.h"
@ -42,7 +42,7 @@ static HeapTuple get_pg_dbtup(char *command, char *dbname, Relation dbrel);
static void stop_vacuum(char *dbpath, char *dbname);
void
createdb(char *dbname, char *dbpath, int encoding)
createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
{
Oid db_id;
int4 user_id;
@ -87,11 +87,11 @@ createdb(char *dbname, char *dbpath, int encoding)
"insert into pg_database (datname, datdba, encoding, datpath)"
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, loc);
pg_exec_query(buf);
pg_exec_query_dest(buf, dest, false);
}
void
destroydb(char *dbname)
destroydb(char *dbname, CommandDest dest)
{
int4 user_id;
Oid db_id;
@ -123,7 +123,7 @@ destroydb(char *dbname)
*/
snprintf(buf, 512,
"delete from pg_database where pg_database.oid = \'%d\'::oid", db_id);
pg_exec_query(buf);
pg_exec_query_dest(buf ,dest, false);
/* drop pages for this database that are in the shared buffer cache */
DropBuffers(db_id);

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: user.c,v 1.24 1999/02/13 23:15:11 momjian Exp $
* $Id: user.c,v 1.25 1999/03/16 03:24:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -46,7 +46,7 @@ static void CheckPgUserAclNotNull(void);
*/
static
void
UpdatePgPwdFile(char *sql)
UpdatePgPwdFile(char *sql, CommandDest dest)
{
char *filename,
@ -71,7 +71,7 @@ UpdatePgPwdFile(char *sql)
snprintf(sql, SQL_LENGTH,
"copy %s to '%s' using delimiters %s",
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
pg_exec_query(sql);
pg_exec_query_dest(sql, dest, false);
rename(tempname, filename);
pfree((void *) tempname);
@ -92,7 +92,7 @@ UpdatePgPwdFile(char *sql)
*---------------------------------------------------------------------
*/
void
DefineUser(CreateUserStmt *stmt)
DefineUser(CreateUserStmt *stmt, CommandDest dest)
{
char *pg_shadow,
@ -175,13 +175,13 @@ DefineUser(CreateUserStmt *stmt)
stmt->password ? stmt->password : "''",
stmt->validUntil ? stmt->validUntil : "");
pg_exec_query(sql);
pg_exec_query_dest(sql, dest, false);
/*
* Add the stuff here for groups.
*/
UpdatePgPwdFile(sql);
UpdatePgPwdFile(sql, dest);
/*
* This goes after the UpdatePgPwdFile to be certain that two backends
@ -196,7 +196,7 @@ DefineUser(CreateUserStmt *stmt)
extern void
AlterUser(AlterUserStmt *stmt)
AlterUser(AlterUserStmt *stmt, CommandDest dest)
{
char *pg_shadow,
@ -282,11 +282,11 @@ AlterUser(AlterUserStmt *stmt)
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'", sql, stmt->user);
pg_exec_query(sql);
pg_exec_query_dest(sql, dest, false);
/* do the pg_group stuff here */
UpdatePgPwdFile(sql);
UpdatePgPwdFile(sql, dest);
UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
heap_close(pg_shadow_rel);
@ -297,7 +297,7 @@ AlterUser(AlterUserStmt *stmt)
extern void
RemoveUser(char *user)
RemoveUser(char *user, CommandDest dest)
{
char *pg_shadow;
@ -390,7 +390,7 @@ RemoveUser(char *user)
elog(NOTICE, "Dropping database %s", dbase[ndbase]);
snprintf(sql, SQL_LENGTH, "drop database %s", dbase[ndbase]);
pfree((void *) dbase[ndbase]);
pg_exec_query(sql);
pg_exec_query_dest(sql, dest, false);
}
if (dbase)
pfree((void *) dbase);
@ -418,9 +418,9 @@ RemoveUser(char *user)
*/
snprintf(sql, SQL_LENGTH,
"delete from %s where usename = '%s'", ShadowRelationName, user);
pg_exec_query(sql);
pg_exec_query_dest(sql, dest, false);
UpdatePgPwdFile(sql);
UpdatePgPwdFile(sql, dest);
UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
heap_close(pg_shadow_rel);

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.57 1999/02/25 17:25:47 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.58 1999/03/16 03:24:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -56,9 +56,9 @@
#include "utils/syscache.h"
#endif
void DefineUser(CreateUserStmt *stmt);
void AlterUser(AlterUserStmt *stmt);
void RemoveUser(char *username);
void DefineUser(CreateUserStmt *stmt, CommandDest);
void AlterUser(AlterUserStmt *stmt, CommandDest);
void RemoveUser(char *username, CommandDest);
/* ----------------
* CHECK_IF_ABORTED() is used to avoid doing unnecessary
@ -557,7 +557,7 @@ ProcessUtility(Node *parsetree,
PS_SET_STATUS(commandTag = "CREATEDB");
CHECK_IF_ABORTED();
createdb(stmt->dbname, stmt->dbpath, stmt->encoding);
createdb(stmt->dbname, stmt->dbpath, stmt->encoding, dest);
}
break;
@ -567,7 +567,7 @@ ProcessUtility(Node *parsetree,
PS_SET_STATUS(commandTag = "DESTROYDB");
CHECK_IF_ABORTED();
destroydb(stmt->dbname);
destroydb(stmt->dbname, dest);
}
break;
@ -749,21 +749,21 @@ ProcessUtility(Node *parsetree,
PS_SET_STATUS(commandTag = "CREATE USER");
CHECK_IF_ABORTED();
DefineUser((CreateUserStmt *) parsetree);
DefineUser((CreateUserStmt *) parsetree, dest);
break;
case T_AlterUserStmt:
PS_SET_STATUS(commandTag = "ALTER USER");
CHECK_IF_ABORTED();
AlterUser((AlterUserStmt *) parsetree);
AlterUser((AlterUserStmt *) parsetree, dest);
break;
case T_DropUserStmt:
PS_SET_STATUS(commandTag = "DROP USER");
CHECK_IF_ABORTED();
RemoveUser(((DropUserStmt *) parsetree)->user);
RemoveUser(((DropUserStmt *) parsetree)->user, dest);
break;
case T_LockStmt:

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: dbcommands.h,v 1.7 1999/02/13 23:21:18 momjian Exp $
* $Id: dbcommands.h,v 1.8 1999/03/16 03:24:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -19,7 +19,7 @@
*/
#define SIGKILLDAEMON1 SIGTERM
extern void createdb(char *dbname, char *dbpath, int encoding);
extern void destroydb(char *dbname);
extern void createdb(char *dbname, char *dbpath, int encoding, CommandDest);
extern void destroydb(char *dbname, CommandDest);
#endif /* DBCOMMANDS_H */

View File

@ -10,8 +10,8 @@
#ifndef USER_H
#define USER_H
extern void DefineUser(CreateUserStmt *stmt);
extern void AlterUser(AlterUserStmt *stmt);
extern void RemoveUser(char *user);
extern void DefineUser(CreateUserStmt *stmt, CommandDest);
extern void AlterUser(AlterUserStmt *stmt, CommandDest);
extern void RemoveUser(char *user, CommandDest);
#endif /* USER_H */