mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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/catname.h"
|
||||||
#include "catalog/pg_database.h"
|
#include "catalog/pg_database.h"
|
||||||
#include "catalog/pg_shadow.h"
|
#include "catalog/pg_shadow.h"
|
||||||
#include "commands/dbcommands.h"
|
|
||||||
#include "fmgr.h"
|
#include "fmgr.h"
|
||||||
#include "miscadmin.h" /* for DataDir */
|
#include "miscadmin.h" /* for DataDir */
|
||||||
#include "storage/bufmgr.h"
|
#include "storage/bufmgr.h"
|
||||||
#include "storage/fd.h"
|
#include "storage/fd.h"
|
||||||
#include "storage/lmgr.h"
|
#include "storage/lmgr.h"
|
||||||
#include "tcop/tcopprot.h"
|
#include "tcop/tcopprot.h"
|
||||||
|
#include "commands/dbcommands.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/syscache.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);
|
static void stop_vacuum(char *dbpath, char *dbname);
|
||||||
|
|
||||||
void
|
void
|
||||||
createdb(char *dbname, char *dbpath, int encoding)
|
createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
|
||||||
{
|
{
|
||||||
Oid db_id;
|
Oid db_id;
|
||||||
int4 user_id;
|
int4 user_id;
|
||||||
@ -87,11 +87,11 @@ createdb(char *dbname, char *dbpath, int encoding)
|
|||||||
"insert into pg_database (datname, datdba, encoding, datpath)"
|
"insert into pg_database (datname, datdba, encoding, datpath)"
|
||||||
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, loc);
|
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, loc);
|
||||||
|
|
||||||
pg_exec_query(buf);
|
pg_exec_query_dest(buf, dest, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
destroydb(char *dbname)
|
destroydb(char *dbname, CommandDest dest)
|
||||||
{
|
{
|
||||||
int4 user_id;
|
int4 user_id;
|
||||||
Oid db_id;
|
Oid db_id;
|
||||||
@ -123,7 +123,7 @@ destroydb(char *dbname)
|
|||||||
*/
|
*/
|
||||||
snprintf(buf, 512,
|
snprintf(buf, 512,
|
||||||
"delete from pg_database where pg_database.oid = \'%d\'::oid", db_id);
|
"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 */
|
/* drop pages for this database that are in the shared buffer cache */
|
||||||
DropBuffers(db_id);
|
DropBuffers(db_id);
|
||||||
|
@ -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.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
|
static
|
||||||
void
|
void
|
||||||
UpdatePgPwdFile(char *sql)
|
UpdatePgPwdFile(char *sql, CommandDest dest)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *filename,
|
char *filename,
|
||||||
@ -71,7 +71,7 @@ UpdatePgPwdFile(char *sql)
|
|||||||
snprintf(sql, SQL_LENGTH,
|
snprintf(sql, SQL_LENGTH,
|
||||||
"copy %s to '%s' using delimiters %s",
|
"copy %s to '%s' using delimiters %s",
|
||||||
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
||||||
pg_exec_query(sql);
|
pg_exec_query_dest(sql, dest, false);
|
||||||
rename(tempname, filename);
|
rename(tempname, filename);
|
||||||
pfree((void *) tempname);
|
pfree((void *) tempname);
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ UpdatePgPwdFile(char *sql)
|
|||||||
*---------------------------------------------------------------------
|
*---------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DefineUser(CreateUserStmt *stmt)
|
DefineUser(CreateUserStmt *stmt, CommandDest dest)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pg_shadow,
|
char *pg_shadow,
|
||||||
@ -175,13 +175,13 @@ DefineUser(CreateUserStmt *stmt)
|
|||||||
stmt->password ? stmt->password : "''",
|
stmt->password ? stmt->password : "''",
|
||||||
stmt->validUntil ? stmt->validUntil : "");
|
stmt->validUntil ? stmt->validUntil : "");
|
||||||
|
|
||||||
pg_exec_query(sql);
|
pg_exec_query_dest(sql, dest, false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the stuff here for groups.
|
* Add the stuff here for groups.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
UpdatePgPwdFile(sql, dest);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This goes after the UpdatePgPwdFile to be certain that two backends
|
* This goes after the UpdatePgPwdFile to be certain that two backends
|
||||||
@ -196,7 +196,7 @@ DefineUser(CreateUserStmt *stmt)
|
|||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
AlterUser(AlterUserStmt *stmt)
|
AlterUser(AlterUserStmt *stmt, CommandDest dest)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pg_shadow,
|
char *pg_shadow,
|
||||||
@ -282,11 +282,11 @@ AlterUser(AlterUserStmt *stmt)
|
|||||||
|
|
||||||
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'", sql, stmt->user);
|
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 */
|
/* do the pg_group stuff here */
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
UpdatePgPwdFile(sql, dest);
|
||||||
|
|
||||||
UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
|
UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
|
||||||
heap_close(pg_shadow_rel);
|
heap_close(pg_shadow_rel);
|
||||||
@ -297,7 +297,7 @@ AlterUser(AlterUserStmt *stmt)
|
|||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
RemoveUser(char *user)
|
RemoveUser(char *user, CommandDest dest)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pg_shadow;
|
char *pg_shadow;
|
||||||
@ -390,7 +390,7 @@ RemoveUser(char *user)
|
|||||||
elog(NOTICE, "Dropping database %s", dbase[ndbase]);
|
elog(NOTICE, "Dropping database %s", dbase[ndbase]);
|
||||||
snprintf(sql, SQL_LENGTH, "drop database %s", dbase[ndbase]);
|
snprintf(sql, SQL_LENGTH, "drop database %s", dbase[ndbase]);
|
||||||
pfree((void *) dbase[ndbase]);
|
pfree((void *) dbase[ndbase]);
|
||||||
pg_exec_query(sql);
|
pg_exec_query_dest(sql, dest, false);
|
||||||
}
|
}
|
||||||
if (dbase)
|
if (dbase)
|
||||||
pfree((void *) dbase);
|
pfree((void *) dbase);
|
||||||
@ -418,9 +418,9 @@ RemoveUser(char *user)
|
|||||||
*/
|
*/
|
||||||
snprintf(sql, SQL_LENGTH,
|
snprintf(sql, SQL_LENGTH,
|
||||||
"delete from %s where usename = '%s'", ShadowRelationName, user);
|
"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);
|
UnlockRelation(pg_shadow_rel, AccessExclusiveLock);
|
||||||
heap_close(pg_shadow_rel);
|
heap_close(pg_shadow_rel);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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"
|
#include "utils/syscache.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DefineUser(CreateUserStmt *stmt);
|
void DefineUser(CreateUserStmt *stmt, CommandDest);
|
||||||
void AlterUser(AlterUserStmt *stmt);
|
void AlterUser(AlterUserStmt *stmt, CommandDest);
|
||||||
void RemoveUser(char *username);
|
void RemoveUser(char *username, CommandDest);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* CHECK_IF_ABORTED() is used to avoid doing unnecessary
|
* CHECK_IF_ABORTED() is used to avoid doing unnecessary
|
||||||
@ -557,7 +557,7 @@ ProcessUtility(Node *parsetree,
|
|||||||
|
|
||||||
PS_SET_STATUS(commandTag = "CREATEDB");
|
PS_SET_STATUS(commandTag = "CREATEDB");
|
||||||
CHECK_IF_ABORTED();
|
CHECK_IF_ABORTED();
|
||||||
createdb(stmt->dbname, stmt->dbpath, stmt->encoding);
|
createdb(stmt->dbname, stmt->dbpath, stmt->encoding, dest);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ ProcessUtility(Node *parsetree,
|
|||||||
|
|
||||||
PS_SET_STATUS(commandTag = "DESTROYDB");
|
PS_SET_STATUS(commandTag = "DESTROYDB");
|
||||||
CHECK_IF_ABORTED();
|
CHECK_IF_ABORTED();
|
||||||
destroydb(stmt->dbname);
|
destroydb(stmt->dbname, dest);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -749,21 +749,21 @@ ProcessUtility(Node *parsetree,
|
|||||||
PS_SET_STATUS(commandTag = "CREATE USER");
|
PS_SET_STATUS(commandTag = "CREATE USER");
|
||||||
CHECK_IF_ABORTED();
|
CHECK_IF_ABORTED();
|
||||||
|
|
||||||
DefineUser((CreateUserStmt *) parsetree);
|
DefineUser((CreateUserStmt *) parsetree, dest);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_AlterUserStmt:
|
case T_AlterUserStmt:
|
||||||
PS_SET_STATUS(commandTag = "ALTER USER");
|
PS_SET_STATUS(commandTag = "ALTER USER");
|
||||||
CHECK_IF_ABORTED();
|
CHECK_IF_ABORTED();
|
||||||
|
|
||||||
AlterUser((AlterUserStmt *) parsetree);
|
AlterUser((AlterUserStmt *) parsetree, dest);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_DropUserStmt:
|
case T_DropUserStmt:
|
||||||
PS_SET_STATUS(commandTag = "DROP USER");
|
PS_SET_STATUS(commandTag = "DROP USER");
|
||||||
CHECK_IF_ABORTED();
|
CHECK_IF_ABORTED();
|
||||||
|
|
||||||
RemoveUser(((DropUserStmt *) parsetree)->user);
|
RemoveUser(((DropUserStmt *) parsetree)->user, dest);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_LockStmt:
|
case T_LockStmt:
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* 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
|
#define SIGKILLDAEMON1 SIGTERM
|
||||||
|
|
||||||
extern void createdb(char *dbname, char *dbpath, int encoding);
|
extern void createdb(char *dbname, char *dbpath, int encoding, CommandDest);
|
||||||
extern void destroydb(char *dbname);
|
extern void destroydb(char *dbname, CommandDest);
|
||||||
|
|
||||||
#endif /* DBCOMMANDS_H */
|
#endif /* DBCOMMANDS_H */
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
#ifndef USER_H
|
#ifndef USER_H
|
||||||
#define USER_H
|
#define USER_H
|
||||||
|
|
||||||
extern void DefineUser(CreateUserStmt *stmt);
|
extern void DefineUser(CreateUserStmt *stmt, CommandDest);
|
||||||
extern void AlterUser(AlterUserStmt *stmt);
|
extern void AlterUser(AlterUserStmt *stmt, CommandDest);
|
||||||
extern void RemoveUser(char *user);
|
extern void RemoveUser(char *user, CommandDest);
|
||||||
|
|
||||||
#endif /* USER_H */
|
#endif /* USER_H */
|
||||||
|
Reference in New Issue
Block a user