Remove GetDatabaseName/Path and use globals. Make consts later.

This commit is contained in:
Bruce Momjian 1998-04-05 21:04:50 +00:00
parent 9e45687df5
commit 4b6fcc4459
6 changed files with 16 additions and 40 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.9 1998/03/30 17:22:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.10 1998/04/05 21:04:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -229,7 +229,7 @@ check_permissions(char *command,
}
/* Check to make sure database is not the currently open database */
if (!strcmp(dbname, GetDatabaseName()))
if (!strcmp(dbname, DatabaseName))
{
elog(ERROR, "%s cannot be executed on an open database", command);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.35 1998/02/26 04:35:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.36 1998/04/05 21:04:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -643,7 +643,7 @@ BufferAlloc(Relation reln,
/* record the database name and relation name for this buffer */
strcpy(buf->sb_relname, reln->rd_rel->relname.data);
strcpy(buf->sb_dbname, GetDatabaseName());
strcpy(buf->sb_dbname, DatabaseName);
INIT_BUFFERTAG(&(buf->tag), reln, blockNum);
if (!BufTableInsert(buf))

View File

@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Id: fd.c,v 1.30 1998/02/26 04:35:29 momjian Exp $
* $Id: fd.c,v 1.31 1998/04/05 21:04:27 momjian Exp $
*
* NOTES:
*
@ -460,8 +460,6 @@ FreeVfd(File file)
* Open specified file name.
* Fill in absolute path fields if necessary.
*
* Modify to use GetDatabasePath() rather than hardcoded paths.
* - thomas 1997-11-02
*/
static char *
filepath(char *filename)
@ -472,9 +470,9 @@ filepath(char *filename)
/* Not an absolute path name? Then fill in with database path... */
if (*filename != SEP_CHAR)
{
len = strlen(GetDatabasePath()) + strlen(filename) + 2;
len = strlen(DatabasePath) + strlen(filename) + 2;
buf = (char *) palloc(len);
sprintf(buf, "%s%c%s", GetDatabasePath(), SEP_CHAR, filename);
sprintf(buf, "%s%c%s", DatabasePath, SEP_CHAR, filename);
}
else
{

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.13 1998/04/05 05:51:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.14 1998/04/05 21:04:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -47,9 +47,7 @@
extern char *getenv(const char *name); /* XXX STDLIB */
/* from globals.c */
extern char *DatabaseName;
extern char *UserName;
extern char *DatabasePath;
#ifdef CYR_RECODE
unsigned char RecodeForwTable[128];
@ -224,27 +222,6 @@ GetProcessingMode()
* ----------------------------------------------------------------
*/
/*
* GetDatabasePath --
* Returns path to database.
*
*/
const char *
GetDatabasePath()
{
return DatabasePath;
}
/*
* GetDatabaseName --
* Returns name of database.
*/
const char *
GetDatabaseName()
{
return DatabaseName;
}
void
SetDatabasePath(char *path)
{

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.26 1998/04/05 05:52:00 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.27 1998/04/05 21:04:43 momjian Exp $
*
* NOTES
* InitPostgres() is the function called from PostgresMain
@ -126,7 +126,7 @@ InitMyDatabaseInfo(char *name)
if (!OidIsValid(MyDatabaseId))
elog(FATAL,
"Database %s does not exist in %s",
GetDatabaseName(),
DatabaseName,
DatabaseRelationName);
path = ExpandDatabasePath(myPath);
@ -203,8 +203,8 @@ VerifyMyDatabase()
int fd;
char errormsg[1000];
name = GetDatabaseName();
myPath = GetDatabasePath();
name = DatabaseName;
myPath = DatabasePath;
if ((fd = open(myPath, O_RDONLY, 0)) == -1)
sprintf(errormsg,

View File

@ -11,7 +11,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: miscadmin.h,v 1.21 1998/04/05 05:52:10 momjian Exp $
* $Id: miscadmin.h,v 1.22 1998/04/05 21:04:50 momjian Exp $
*
* NOTES
* some of the information in this file will be moved to
@ -110,14 +110,15 @@ extern Oid LastOidProcessed; /* for query rewrite */
* POSTGRES directory path definitions. *
*****************************************************************************/
extern char *DatabaseName;
extern char *DatabasePath;
/* in utils/misc/database.c */
extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
extern int GetDatabaseInfo(char *name, Oid *owner, char *path);
extern char *ExpandDatabasePath(char *path);
/* now in utils/init/miscinit.c */
extern const char *GetDatabasePath(void);
extern const char *GetDatabaseName(void);
extern void SetDatabaseName(char *name);
extern void SetDatabasePath(char *path);
extern char *getpgusername(void);