Fix typo (extraneous semicolon) in fd.c patch to avoid excess seeks.

Now it skips useless SEEK_CUR 0 calls too, as intended.
This commit is contained in:
Tom Lane 2000-07-05 21:10:05 +00:00
parent 98fe670360
commit 6d1ae0c91b
1 changed files with 17 additions and 9 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.61 2000/06/15 04:10:00 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.62 2000/07/05 21:10:05 tgl Exp $
*
* NOTES:
*
@ -809,11 +809,13 @@ FileWrite(File file, char *buffer, int amount)
FileAccess(file);
returnCode = write(VfdCache[file].fd, buffer, amount);
if (returnCode > 0) {
if (returnCode > 0)
{
VfdCache[file].seekPos += returnCode;
/* mark the file as needing fsync */
VfdCache[file].fdstate |= FD_DIRTY;
} else
/* mark the file as needing fsync */
VfdCache[file].fdstate |= FD_DIRTY;
}
else
VfdCache[file].seekPos = FileUnknownPos;
return returnCode;
@ -832,6 +834,8 @@ FileSeek(File file, long offset, int whence)
switch (whence)
{
case SEEK_SET:
if (offset < 0)
elog(ERROR, "FileSeek: invalid offset: %ld", offset);
VfdCache[file].seekPos = offset;
break;
case SEEK_CUR:
@ -844,9 +848,12 @@ FileSeek(File file, long offset, int whence)
default:
elog(ERROR, "FileSeek: invalid whence: %d", whence);
break;
}
}
} else
switch (whence) {
else
{
switch (whence)
{
case SEEK_SET:
if (offset < 0)
elog(ERROR, "FileSeek: invalid offset: %ld", offset);
@ -854,8 +861,8 @@ FileSeek(File file, long offset, int whence)
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
break;
case SEEK_CUR:
if ((offset != 0) || (VfdCache[file].seekPos == FileUnknownPos));
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
if (offset != 0 || VfdCache[file].seekPos == FileUnknownPos)
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
break;
case SEEK_END:
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
@ -864,6 +871,7 @@ FileSeek(File file, long offset, int whence)
elog(ERROR, "FileSeek: invalid whence: %d", whence);
break;
}
}
return VfdCache[file].seekPos;
}