Skip to content

Commit 6d1ae0c

Browse files
committed
Fix typo (extraneous semicolon) in fd.c patch to avoid excess seeks.
Now it skips useless SEEK_CUR 0 calls too, as intended.
1 parent 98fe670 commit 6d1ae0c

File tree

1 file changed

+17
-9
lines changed
  • src/backend/storage/file

1 file changed

+17
-9
lines changed

src/backend/storage/file/fd.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.61 2000/06/15 04:10:00 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.62 2000/07/05 21:10:05 tgl Exp $
1111
*
1212
* NOTES:
1313
*
@@ -809,11 +809,13 @@ FileWrite(File file, char *buffer, int amount)
809809

810810
FileAccess(file);
811811
returnCode = write(VfdCache[file].fd, buffer, amount);
812-
if (returnCode > 0) {
812+
if (returnCode > 0)
813+
{
813814
VfdCache[file].seekPos += returnCode;
814-
/* mark the file as needing fsync */
815-
VfdCache[file].fdstate |= FD_DIRTY;
816-
} else
815+
/* mark the file as needing fsync */
816+
VfdCache[file].fdstate |= FD_DIRTY;
817+
}
818+
else
817819
VfdCache[file].seekPos = FileUnknownPos;
818820

819821
return returnCode;
@@ -832,6 +834,8 @@ FileSeek(File file, long offset, int whence)
832834
switch (whence)
833835
{
834836
case SEEK_SET:
837+
if (offset < 0)
838+
elog(ERROR, "FileSeek: invalid offset: %ld", offset);
835839
VfdCache[file].seekPos = offset;
836840
break;
837841
case SEEK_CUR:
@@ -844,18 +848,21 @@ FileSeek(File file, long offset, int whence)
844848
default:
845849
elog(ERROR, "FileSeek: invalid whence: %d", whence);
846850
break;
851+
}
847852
}
848-
} else
849-
switch (whence) {
853+
else
854+
{
855+
switch (whence)
856+
{
850857
case SEEK_SET:
851858
if (offset < 0)
852859
elog(ERROR, "FileSeek: invalid offset: %ld", offset);
853860
if (VfdCache[file].seekPos != offset)
854861
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
855862
break;
856863
case SEEK_CUR:
857-
if ((offset != 0) || (VfdCache[file].seekPos == FileUnknownPos));
858-
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
864+
if (offset != 0 || VfdCache[file].seekPos == FileUnknownPos)
865+
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
859866
break;
860867
case SEEK_END:
861868
VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence);
@@ -864,6 +871,7 @@ FileSeek(File file, long offset, int whence)
864871
elog(ERROR, "FileSeek: invalid whence: %d", whence);
865872
break;
866873
}
874+
}
867875
return VfdCache[file].seekPos;
868876
}
869877

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy