Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita194574

Browse files
committed
> If read or write fails. Position will left the same. This
> situation is already tracked in File routines, but a little bit> incorrectly.> After small survey in Linux kernel code, I am not sure about> it. New patch set pos to unknown in the case of read/write> fails. And do lseek again.> Here is the full patch for this. This patch reduce amount of> lseek call ten ti mes for update statement and twenty times for> select statement. I tested joined up date and count(*) select> for table with rows > 170000 and 10 indices. I think this is> worse of trying. Before lseek calls account for more than 5% o> f time. Now they are 0.89 and 0.15 respectevly.>> Due to only one file modification patch should be applied in> src/backedn/stora ge/file/ dir.-- Sincerely Yours,Denis Perchine
1 parent434adee commita194574

File tree

1 file changed

+26
-5
lines changed
  • src/backend/storage/file

1 file changed

+26
-5
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 26 additions & 5 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.59 2000/06/02 15:57:24 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.60 2000/06/14 03:19:24 momjian Exp $
1111
*
1212
* NOTES:
1313
*
@@ -95,6 +95,8 @@
9595

9696
#defineFileIsNotOpen(file) (VfdCache[file].fd == VFD_CLOSED)
9797

98+
#defineFileUnknownPos (-1)
99+
98100
typedefstructvfd
99101
{
100102
signed shortfd;/* current FD, or VFD_CLOSED if none */
@@ -790,6 +792,8 @@ FileRead(File file, char *buffer, int amount)
790792
returnCode=read(VfdCache[file].fd,buffer,amount);
791793
if (returnCode>0)
792794
VfdCache[file].seekPos+=returnCode;
795+
else
796+
VfdCache[file].seekPos=FileUnknownPos;
793797

794798
returnreturnCode;
795799
}
@@ -806,11 +810,12 @@ FileWrite(File file, char *buffer, int amount)
806810

807811
FileAccess(file);
808812
returnCode=write(VfdCache[file].fd,buffer,amount);
809-
if (returnCode>0)
813+
if (returnCode>0) {
810814
VfdCache[file].seekPos+=returnCode;
811-
812815
/* mark the file as needing fsync */
813816
VfdCache[file].fdstate |=FD_DIRTY;
817+
}else
818+
VfdCache[file].seekPos=FileUnknownPos;
814819

815820
returnreturnCode;
816821
}
@@ -840,10 +845,26 @@ FileSeek(File file, long offset, int whence)
840845
default:
841846
elog(ERROR,"FileSeek: invalid whence: %d",whence);
842847
break;
843-
}
844848
}
845-
else
849+
}else
850+
switch (whence) {
851+
caseSEEK_SET:
852+
if (offset<0)
853+
elog(ERROR,"FileSeek: invalid offset: %ld",offset);
854+
if (VfdCache[file].seekPos!=offset)
855+
VfdCache[file].seekPos=lseek(VfdCache[file].fd,offset,whence);
856+
break;
857+
caseSEEK_CUR:
858+
if ((offset!=0)|| (VfdCache[file].seekPos==FileUnknownPos));
846859
VfdCache[file].seekPos=lseek(VfdCache[file].fd,offset,whence);
860+
break;
861+
caseSEEK_END:
862+
VfdCache[file].seekPos=lseek(VfdCache[file].fd,offset,whence);
863+
break;
864+
default:
865+
elog(ERROR,"FileSeek: invalid whence: %d",whence);
866+
break;
867+
}
847868
returnVfdCache[file].seekPos;
848869
}
849870

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp