fd.diffs
application/octet-stream
*** postgresql-9.2beta1/src/backend/storage/file/fd.c 2012-05-10 15:35:09.000000000 -0700
--- postgresql-9.2beta1/src/backend/storage/file/fd.c.modified 2012-05-29 13:34:30.000000000 -0700
***************
*** 2021,2038 ****
struct dirent *temp_de;
char rm_path[MAXPGPATH];
temp_dir = AllocateDir(tmpdirname);
if (temp_dir == NULL)
{
/* anything except ENOENT is fishy */
if (errno != ENOENT)
elog(LOG,
"could not open temporary-files directory \"%s\": %m",
! tmpdirname);
return;
}
while ((temp_de = ReadDir(temp_dir, tmpdirname)) != NULL)
{
if (strcmp(temp_de->d_name, ".") == 0 ||
strcmp(temp_de->d_name, "..") == 0)
--- 2021,2060 ----
struct dirent *temp_de;
char rm_path[MAXPGPATH];
+ #ifdef WIN32
+ /* On Win32, iterating over all files in a directory that match a pattern
+ * can be much faster than iterating over all files in the directory, if
+ * the file names that match the pattern are a small subset of all files.
+ */
+ char tempdirpattern[MAXPGPATH];
+
+ snprintf(tmpdirpattern, MAXPGPATH, "%s/%s*", tmpdirname, PG_TEMP_FILE_PREFIX);
+ temp_dir = AllocateDir(tmpdirpattern);
+ #else
temp_dir = AllocateDir(tmpdirname);
+ #endif
+
if (temp_dir == NULL)
{
/* anything except ENOENT is fishy */
if (errno != ENOENT)
elog(LOG,
+ #ifdef WIN32
+ "could not open temporary-files directory using pattern \"%s\": %m",
+ tmpdirpattern
+ #else
"could not open temporary-files directory \"%s\": %m",
! tmpdirname
! #endif
! );
return;
}
+ #ifdef WIN32
+ while ((temp_de = ReadDir(temp_dir, tmpdirpattern)) != NULL)
+ #else
while ((temp_de = ReadDir(temp_dir, tmpdirname)) != NULL)
+ #endif
{
if (strcmp(temp_de->d_name, ".") == 0 ||
strcmp(temp_de->d_name, "..") == 0)
***************
*** 2103,2119 ****
struct dirent *de;
char rm_path[MAXPGPATH];
dbspace_dir = AllocateDir(dbspacedirname);
if (dbspace_dir == NULL)
{
/* we just saw this directory, so it really ought to be there */
elog(LOG,
"could not open dbspace directory \"%s\": %m",
! dbspacedirname);
return;
}
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
{
if (!looks_like_temp_rel_name(de->d_name))
continue;
--- 2125,2158 ----
struct dirent *de;
char rm_path[MAXPGPATH];
+ #ifdef WIN32
+ char dbspacedirpattern[MAXPGPATH];
+
+ snprintf(dbspacedirpattern, MAXPGPATH, "%s/t*", dbspacedirname);
+ dbspace_dir = AllocateDir(dbspacedirpattern);
+ #else
dbspace_dir = AllocateDir(dbspacedirname);
+ #endif
if (dbspace_dir == NULL)
{
/* we just saw this directory, so it really ought to be there */
elog(LOG,
+ #ifdef WIN32
+ "could not open dbspace directory using pattern \"%s\": %m",
+ dbspacedirpattern
+ #else
"could not open dbspace directory \"%s\": %m",
! dbspacedirname
! #endif
! );
return;
}
+ #ifdef WIN32
+ while ((de = ReadDir(dbspace_dir, dbspacedirpattern)) != NULL)
+ #else
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
+ #endif
{
if (!looks_like_temp_rel_name(de->d_name))
continue;