5
5
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
6
6
*
7
7
* IDENTIFICATION
8
- * $PostgreSQL: pgsql/contrib/dbsize/dbsize.c,v 1.18 2005/06/19 21:34:00 tgl Exp $
8
+ * $PostgreSQL: pgsql/contrib/dbsize/dbsize.c,v 1.19 2005/07/04 04:51:43 tgl Exp $
9
9
*
10
10
*/
11
11
24
24
#include "utils/syscache.h"
25
25
26
26
27
- /* hack to make it compile under Win32 */
28
- extern DLLIMPORT char * DataDir ;
29
-
30
27
Datum pg_tablespace_size (PG_FUNCTION_ARGS );
31
28
Datum pg_database_size (PG_FUNCTION_ARGS );
32
29
Datum pg_relation_size (PG_FUNCTION_ARGS );
@@ -91,11 +88,11 @@ calculate_database_size(Oid dbOid)
91
88
/* Shared storage in pg_global is not counted */
92
89
93
90
/* Include pg_default storage */
94
- snprintf (pathname , MAXPGPATH , "%s/ base/%u" , DataDir , dbOid );
91
+ snprintf (pathname , MAXPGPATH , "base/%u" , dbOid );
95
92
totalsize += db_dir_size (pathname );
96
93
97
94
/* Scan the non-default tablespaces */
98
- snprintf (pathname , MAXPGPATH , "%s/ pg_tblspc" , DataDir );
95
+ snprintf (pathname , MAXPGPATH , "pg_tblspc" );
99
96
dirdesc = AllocateDir (pathname );
100
97
101
98
while ((direntry = ReadDir (dirdesc , pathname )) != NULL )
@@ -104,8 +101,8 @@ calculate_database_size(Oid dbOid)
104
101
strcmp (direntry -> d_name , ".." ) == 0 )
105
102
continue ;
106
103
107
- snprintf (pathname , MAXPGPATH , "%s/ pg_tblspc/%s/%u" ,
108
- DataDir , direntry -> d_name , dbOid );
104
+ snprintf (pathname , MAXPGPATH , "pg_tblspc/%s/%u" ,
105
+ direntry -> d_name , dbOid );
109
106
totalsize += db_dir_size (pathname );
110
107
}
111
108
@@ -134,11 +131,11 @@ pg_tablespace_size(PG_FUNCTION_ARGS)
134
131
struct dirent * direntry ;
135
132
136
133
if (tblspcOid == DEFAULTTABLESPACE_OID )
137
- snprintf (tblspcPath , MAXPGPATH , "%s/ base" , DataDir );
134
+ snprintf (tblspcPath , MAXPGPATH , "base" );
138
135
else if (tblspcOid == GLOBALTABLESPACE_OID )
139
- snprintf (tblspcPath , MAXPGPATH , "%s/ global" , DataDir );
136
+ snprintf (tblspcPath , MAXPGPATH , "global" );
140
137
else
141
- snprintf (tblspcPath , MAXPGPATH , "%s/ pg_tblspc/%u" , DataDir , tblspcOid );
138
+ snprintf (tblspcPath , MAXPGPATH , "pg_tblspc/%u" , tblspcOid );
142
139
143
140
dirdesc = AllocateDir (tblspcPath );
144
141
@@ -208,12 +205,12 @@ calculate_relation_size(Oid tblspcOid, Oid relnodeOid)
208
205
tblspcOid = MyDatabaseTableSpace ;
209
206
210
207
if (tblspcOid == DEFAULTTABLESPACE_OID )
211
- snprintf (dirpath , MAXPGPATH , "%s/ base/%u" , DataDir , MyDatabaseId );
208
+ snprintf (dirpath , MAXPGPATH , "base/%u" , MyDatabaseId );
212
209
else if (tblspcOid == GLOBALTABLESPACE_OID )
213
- snprintf (dirpath , MAXPGPATH , "%s/ global" , DataDir );
210
+ snprintf (dirpath , MAXPGPATH , "global" );
214
211
else
215
- snprintf (dirpath , MAXPGPATH , "%s/ pg_tblspc/%u/%u" ,
216
- DataDir , tblspcOid , MyDatabaseId );
212
+ snprintf (dirpath , MAXPGPATH , "pg_tblspc/%u/%u" ,
213
+ tblspcOid , MyDatabaseId );
217
214
218
215
for (segcount = 0 ;; segcount ++ )
219
216
{
0 commit comments