Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitced2ee8

Browse files
author
Thomas G. Lockhart
committed
Clean up path handling esp. when interpreting environment variables.
Remove unused old code.
1 parentfe36d46 commitced2ee8

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

‎src/backend/parser/dbcommands.c

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/dbcommands.c,v 1.10 1997/11/07 06:37:55 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/dbcommands.c,v 1.11 1997/11/10 15:17:44 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -74,6 +74,11 @@ createdb(char *dbname, char *dbpath)
7474

7575
lp=ExpandDatabasePath(loc);
7676

77+
if (lp==NULL)
78+
elog(WARN,"Unable to locate path '%s'"
79+
"\n\tThis may be due to a missing environment variable"
80+
" in the server",loc);
81+
7782
if (mkdir(lp,S_IRWXU)!=0)
7883
elog(WARN,"Unable to create database directory %s",lp);
7984

@@ -101,11 +106,6 @@ destroydb(char *dbname)
101106
char*path;
102107
chardbpath[MAXPGPATH+1];
103108
charbuf[512];
104-
charloc[512];
105-
text*dbtext;
106-
107-
Relationdbrel;
108-
HeapTupledbtup;
109109

110110
/*
111111
* If this call returns, the database exists and we're allowed to
@@ -121,34 +121,11 @@ destroydb(char *dbname)
121121
/* stop the vacuum daemon */
122122
stop_vacuum(dbpath,dbname);
123123

124-
#ifFALSE
125-
dbrel=heap_openr(DatabaseRelationName);
126-
if (!RelationIsValid(dbrel))
127-
elog(FATAL,"%s: cannot open relation \"%-.*s\"",
128-
"destroydb",DatabaseRelationName);
129-
130-
dbtup=get_pg_dbtup("destroydb",dbname,dbrel);
131-
132-
if (!HeapTupleIsValid(dbtup))
133-
elog(NOTICE,"destroydb: pg_database entry not found %s",dbname);
134-
135-
dbtext= (text*)heap_getattr(dbtup,InvalidBuffer,
136-
Anum_pg_database_datpath,
137-
RelationGetTupleDescriptor(dbrel),
138-
(char*)NULL);
139-
memcpy(loc,VARDATA(dbtext), (VARSIZE(dbtext)-VARHDRSZ));
140-
*(loc+(VARSIZE(dbtext)-VARHDRSZ))='\0';
141-
142-
#ifFALSE
143-
if (*loc!=SEP_CHAR)
144-
{
145-
sprintf(buf,"%s/base/%s",DataDir,loc);
146-
strcpy(loc,buf);
147-
}
148-
#endif
149-
150-
heap_close(dbrel);
151-
#endif
124+
path=ExpandDatabasePath(dbpath);
125+
if (path==NULL)
126+
elog(WARN,"Unable to locate path '%s'"
127+
"\n\tThis may be due to a missing environment variable"
128+
" in the server",dbpath);
152129

153130
/*
154131
* remove the pg_database tuple FIRST, this may fail due to
@@ -162,7 +139,6 @@ destroydb(char *dbname)
162139
* remove the data directory. If the DELETE above failed, this will
163140
* not be reached
164141
*/
165-
path=ExpandDatabasePath(dbpath);
166142

167143
sprintf(buf,"rm -r %s",path);
168144
system(buf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp