From 6d1ae0c91bb1909e6bc3b2d9b7e454d1ca754d0c Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed, 5 Jul 2000 21:10:05 +0000
Subject: [PATCH] Fix typo (extraneous semicolon) in fd.c patch to avoid excess
 seeks. Now it skips useless SEEK_CUR 0 calls too, as intended.

---
 src/backend/storage/file/fd.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 73d0788d607..6a4ecb63dc2 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -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;
 }
 
-- 
GitLab